Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Missing values and listing IDs


From   Neil Shephard <nshephard@nhs.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Missing values and listing IDs
Date   Thu, 13 Nov 2008 12:57:20 +0000

Sham Lal wrote:
> Dear statalist,
> I wish to list the ID numbers of those individuals in my dataset that have at least one missing value out any six variables (x1-x6). At the moment I have used the following logic: 
>  
> list responder_status ID if  x1==. | x2==. | ///
> x3==. | x4==. | x5==. | x6==.
>
> But I'm not sure if this is correct, so I did the following which I think is.
>
> gen miss=0 
> recode miss 0=1 if x1==.
> recode miss 0=1 if x2==.
> recode miss 0=1 if x3==. 
> recode miss 0=1 if x4==.
> recode miss 0=1 if x5==.
> recode miss 0=1 if x6==.
>
>
> However is there a more succinct way to write this code, instead of 7 lines?
>
>   
There are multiple ways of approaching this, one is to use -egen-

egen miss = rowmiss(x1 x2 x3 x4 x5 x6)
list responder_status ID if(miss >= 1)

Neil

-- 
"We should make things as simple as possible, but not simpler" - Anon (not Albert Einstein)


***********************************************************************
This  message  may  contain  confidential and  privileged  information.
If you  are not the  intended recipient  you should not  disclose, copy
or distribute information in this e-mail or take any action in reliance
on its contents.  To do so is strictly  prohibited and may be unlawful.
Please  inform  the  sender that  this  message has  gone astray before
deleting it.  Thank you.

2008 marks the 60th anniversary of the NHS.  It's an opportunity to pay
tribute to the NHS staff and volunteers who help shape the service, and
celebrate their achievements.

If you work for the NHS  and  would like  an NHSmail  email account, go
to: www.connectingforhealth.nhs.uk/nhsmail
***********************************************************************

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