[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st:delete all the obervations with negative values
From
Martin Weiss <[email protected]>
To
[email protected]
Subject
Re: st:delete all the obervations with negative values
Date
Sat, 2 Aug 2008 22:59:54 +0200
I take it form your subject line and example that you want to delete
obs whenever there is one NEGATIVE (and not missing) value, regardless
of which var is concerned.
Just
*********
egen rmin=rowmin(var1 - var50)
drop if rmin<0
*********
HTH
Martin
Quoting Man Jia <[email protected]>:
Hi all,
Could anyone could give me some hint on how to delete all the
observations with missing values for at least one variable? I know it's
a quite simple question. But I havn't figured out a good way to deal
with this.
Here's an example to show this:
----------------------------------------------------------
ID var1 var2 var3
1 0 2 1
2 -2 1 3
3 0 -4 9
4 1 0 1
---------------------------------------------------------
What I want to do is to drop observation whose ID is 2 and 3.
If there are not many variables in the data set, I know I could do:
. drop if var1<0| var2<0 | var3<0
But this way is inconvenient if there are a lot of variables (like 50
variables) in the data set.
Thanks for your kind help!
Have a nice weekend,
Mandy
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |