Bookmark and Share

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: Dropping variables with mostly missing values again


From   <[email protected]>
To   [email protected]
Subject   Re: st: Dropping variables with mostly missing values again
Date   Fri, 7 Feb 2014 22:04:42 -0500 (GMT-05:00)

Eric wrote me privately and I tried to respond to Statalist but the message was bounced; so ...

1. don't write privately unless you want to hire me for consulting

2. here is a more explicit answer as what you tried won't work:

foreach var of varlist a-b {
   qui su `var', meanonly
   if `r(N)'<20 drop `var'
}

replace 20 with whatever rule you want
note that this will not work for string variables (use -tabulate- instead of -summarize-

Rich


-----Original Message-----
>From: "Eric M. Uslaner" <[email protected]>
>Sent: Feb 7, 2014 9:00 PM
>To: "[email protected]" <[email protected]>
>Subject: st: Dropping variables with mostly missing values again
>
>Thanks to Rich, Amirsa, Jeph, and Nick.  It is likely my ignorance but I can't get this resolved.  For the solutions of Rich, Amirsa, and Jeph, I get all missing values.  For Nick's suggestion, I have:
>
>foreach V of varlist elecprod1750-visitorrooms2003 {
>	npresent,min(20)
>	keep `r(`V')' 
>}   
>
>And I see the npresent results as he suggested.  But the do file  I constructed above after the last variable leads to:
>
>varlist or in range required
>r(100);
>
>end of do-file
>
>r(100);
>
>And no values are changed.  What, please, am I doing wrong?  Thanks.
>
>Ric
>
>
>*
>*   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/

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index