Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Dropping all missing values


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Dropping all missing values
Date   Mon, 14 Dec 2009 16:36:23 -0000

Note first that the code you quote is illegal. Also, even with a typo
fix it does not cover string missings. 

More generally, be careful what you ask for. 

Dropping all missing values means dropping all observations with any
missing values on any variable. This can often be much more savage than
a researcher really wants. 

You could do that by 

foreach v of var * { 
	drop if missing(`v') 
}

But sometimes it's best to drop one or a few variables with lots of
missing values first. You need to look carefully at the structure of
missing values. 

Thus asking for the shortest syntax betrays an urge to do this in a
hurry, and that can be highly counter-productive. 

Check out -misstable- (Stata 11) and -nmissing- (Stata Journal). 

Nick 
n.j.cox@durham.ac.uk 

Mosi A. Ifatunji, Ph.D. Candidate

I am at the final stage of dataset preparation and would like to
remove all missing values. I know that I can drop all missing values
with the following syntax:

drop x1 if == .
drop x2 if == .

But, because I am going to have quite a few variables in the final
dataset, I would prefer as short a command syntax as possible. Of
course the goals of such an exercise is to ensure that all of my
analysis for this study is based on the same cases.
 

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index