Statalist The Stata Listserver


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

st: na.omit synonym


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: na.omit synonym
Date   Wed, 20 Jun 2007 09:11:12 -0400

Neil said

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' == .)
}


For one thing I would not describe this as 'looping over the observations'. It is not an explicit loop (which is generally to be avoided).

You might also consider something like

egen check=anymatch(price-foreign),val(-1)
drop if check

Note that a -varlist- may contain a hyphenated list of variables, so need not include each varname. The list is in the order of the variables in the dataset (or in the Variables window), which can be modified with -order-.



Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


*
* 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