Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: displaying variable names for which obs are missing, by row


From   "Nick Winter" <[email protected]>
To   <[email protected]>
Subject   st: RE: displaying variable names for which obs are missing, by row
Date   Tue, 6 May 2003 14:38:37 -0400

This will be slow, but:

local n=_N
forval obs=1/`n' {
	di
	di id[`obs']
	foreach var of varlist * {
		if `var'[`obs']>=. {
			di "`var' " _c
		}
	}
}

Nick Winter


-----------------------------------------------------------
 Nicholas Winter, Ph.D.                     P 202.939.5343
 Policy Studies Associates                  F 202.939.5732
 1718 Connecticut Avenue, NW     [email protected]
 Washington, DC 20009-1148           www.policystudies.com
----------------------------------------------------------- 

> -----Original Message-----
> From: Radu Ban [mailto:[email protected]] 
> Sent: Tuesday, May 06, 2003 2:31 PM
> To: [email protected]
> Subject: st: displaying variable names for which obs are 
> missing, by row
> 
> 
> dear all,
> 
> i want to obtain a listing of the variables that have missing
> observations, by row. more explicitly, the dataset looks like 
> (on a much
> larger scale)
> 
> id 	var1	var2	var3
> a1	x	.	.
> a2	y	z	.
> a3	.	t	u
> 
> so i want to obtain an output of the form:
> 
> a1
> var2
> var3
> 
> a2
> var3
> 
> a3
> var1
> 
> i tried with the following piece of code:
> 
> local N = _N
> forvalues i = 1/`N' {
> 	l accid in `i', noobs
> 	foreach j of local vlist {
> 		l `j' if `j' == . in `i', noobs
> 	}
> }
> 
> 
> but the problem is that this code lists all the variables for each id,
> even if they are not missing. the only difference is that when the
> variable is missing the actual "." is listed, while when it's 
> not missing
> only the name is listed. thus it is hard to pick up the 
> desired variables
> just by looking at the log file.
> 
> does anyone have any suggestions?
> 
> thanks in advance,
> 
> radu ban
> 
> 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index