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   Sergiy Radyakin <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Dropping variables with mostly missing values again
Date   Fri, 7 Feb 2014 21:56:31 -0500

Eric, in your case the following statement
   keep `r(`V')'
was reduced to
   keep
which can't be understood by Stata. Perhaps no variable has at least
20 non-missing values. Instead I would write:
   local keeplist `"`r(`V')'"'
   if missing(`"`keeplist'"') error 2000
   else keep `keeplist'
which in the same situation would give you a well understood "No
observations" error.

Best, Sergiy Radyakin

On Fri, Feb 7, 2014 at 9:00 PM, Eric M. Uslaner <[email protected]> wrote:
> 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