Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: St: Dropping variables with mostly missing values
From
<[email protected]>
To
[email protected]
Subject
Re: st: St: Dropping variables with mostly missing values
Date
Fri, 7 Feb 2014 15:25:58 -0500 (GMT-05:00)
you don't say what kind of variables these are but try the following
1. make sure all the variables you want to test in this way are in consecutive order (see -h order-)
2. if all numeric, put into a foreach loop (e.g., -foreach var of varlist a-d { -
3. qui summarize each var using the "mean only" option for speed if you want
4. test the returned value in r(N) to see if it is present often enough to use (clearly make that decision first)
5. either drop the variable or move on (use -drop if ...-)
if some of the variables are categorical but you are sure that none have more than 2000 distinct values, substitute tabulate for summarize above
Rich
-----Original Message-----
>From: "Eric M. Uslaner" <[email protected]>
>Sent: Feb 7, 2014 3:11 PM
>To: "[email protected]" <[email protected]>
>Subject: st: St: Dropping variables with mostly missing values
>
>I know that this has been discussed before, but a long search doesn't find a solution for me (my own fault in searching, most likely).
>
>I have a data set (not my own) with 161 cases over a long time period. But most of the variables are largely made up of missing values (information wasn't available a long time ago). I have used Nick Cox's dropmiss (from SSC) to drop variables with all missing values. But a large number of variables remain with few observations. I would like to delete any variable with fewer than 20 cases. But I can't figure out how to do this (especially since I have a large number of variables, most of which have very few cases). Any help would be appreciated.
>
>Ric Uslaner
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/