Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Dropping variables with all observations missing


From   Joseph Coveney <jcoveney@bigplanet.com>
To   Statalist <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Dropping variables with all observations missing
Date   Mon, 25 Apr 2005 19:51:24 +0900

Kim Gradel wrote:

After having merged and reshaped a few datasets I ended up with a
dataset of 150 observations and 955 variables. I want to drop the
numerous variables that have only missing observations. It's tedious to
look through all these variables to find those with 150 missing
observations, and I wonder if there is a short and conveniant command
related to "drop" or "keep" that I can use to drop all variables where
all observations are missing.

----------------------------------------------------------------------------
----

-dropmiss- will do it.  Or you can write a routine easily enough.

Joseph Coveney

foreach var of varlist _all {
    capture assert mi(`var')
    if !_rc {
       drop `var'
    }
}


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