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   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Dropping variables with all observations missing
Date   Mon, 25 Apr 2005 12:32:05 +0100

-dropmiss- is a user-written command, 
so you would need to install it. 

. search dropmiss 

is the way to start that. 

Nick 
[email protected] 

Joseph Coveney replied to Kim Gradel 

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