Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: na.omit synonym


From   "Neil Shephard" <[email protected]>
To   [email protected]
Subject   Re: st: na.omit synonym
Date   Wed, 20 Jun 2007 13:23:49 +0100

On 6/20/07, bunny , lautloscrew.com <[email protected]> wrote:
HI everybody,

i have several non-response in my dataset that are coded -1 .
i�d like to drop any observation (row) where one or more columns
contains a -1.

In R there's na.omit to the job. is there a similiar syntax in stata ?

To echo Nick Cox's comment the other day with regards to similar
constructs between Stata and R (see
http://www.stata.com/statalist/archive/2007-06/msg00382.html)

"In general, there is no more reason to expect R syntax to work in
Stata than there is to expect Stata syntax to work in R."


Looping over the observations will do it...

* Convert -1 to Stata's internal missing for your variables
mvdecode a b c d, mv(-1)

* Loop over variables and drop if they are missing
foreach x in varlist a b c d{
 drop if(`x' == .)
}

Neil
--
"In mathematics you don't understand things. You just get used to
them."  - Johann von Neumann

Email - [email protected] / [email protected]
Website - http://slack.ser.man.ac.uk/
Photos - http://www.flickr.com/photos/slackline/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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