Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Map logical operator across varlist?


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Map logical operator across varlist?
Date   Wed, 17 Jan 2007 21:30:59 -0000

This underlines to me that my own first reply confuses quite 
different problems. Joel wants a listing 

	if any variable is not missing, 

not 

	only if all variables are not missing. 

Phil has indicated the best -egen- route: my first reply 
indicates an alternative from first principles. Sorry about 
any confusion. 

Nick 
[email protected] 

Phil Schumm
 
> On Jan 17, 2007, at 2:01 PM, Joel J. Adamson wrote:
> > I want to list a set of variables, only if an observation  is not  
> > missing for the variables in question.  We usually handle this by  
> > constructing a small logical expression:
> >
> > l med1 med2 if (med1~=.|med2~=.)
> >
> > However, if I have six, or a hundred "med" variables (med*), it  
> > would be easier (less error-prone) to type:
> >
> > l med* if |(med*~=.)
> >
> > Where the "|" before the "(" maps the operation onto the expanded  
> > list of variables.
> 
> 
> egen foo = rownonmiss(med*), [strok]
> li med* if foo
> 
> 
> where the -strok- option is necessary if one or more vars are 
> of type  
> string.

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