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: detecting a complete data set


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: detecting a complete data set
Date   Tue, 16 Nov 2010 14:13:04 +0000

"Does this mean...?" 

No, it does not. A little experiment would show the difference, but in any case: 

totmis == 0 evaluates as 1 or 0, according to whether it is the case that totmis == 0. Even if -totmis- were missing, it is then still not 0 and the result would still be 0. 

1 if totmis == 0 evaluates as 1 or missing.  If -totmis- is not 0, Stata has no instructions on what to do, shrugs its shoulders and returns missing. 

For more detail: 

FAQ     . . . . . . . . . . . . . . . . . . . . . . .  True and false in Stata
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        2/03    What is true and false in Stata?
                http://www.stata.com/support/faqs/data/trueorfalse.html

Nick 
[email protected] 

Donald Spady

  Seems to work. The result makes sense. I assume that if complete takes the value 0 that there are missing data, and if it takes the value 1 then the data are complete.
I am unsure about the grammer of "gen byte complete = totmis == 0"  Does this mean "generate complete = 1 IF totmis == 0"

On 2010-11-16, at 6:44 AM, Maarten buis wrote:

> --- Donald Spady wrote:
>> I want to detect the ID that has no data missing for ALL Levels
>> within that ID.  In this case ID 2 fits the bill, ID 1 has data
>> missing in levels 2 and 3
> 
> *---------- begin example -------------
> drop _all
> input id level a b c d
> 1  1  1  1  1  1
> 1  2  1  0  .  0
> 1  3  .  1  0  .
> 1  4  1  0  1  1
> 2  1  1  0  1  1
> 2  2  0  0  0  1
> 2  3  0  1  1  1
> 2  4  1  1  1  1 
> end
> gen byte mis = missing(a, b, c, d)
> bys id : egen int totmis = total(mis)
> gen byte complete = totmis == 0
> drop mis totmis
> list , sepby(id)
> *------------ end example ------------
> (For more on examples I sent to the Statalist see: 
> http://www.maartenbuis.nl/example_faq )
> 

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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