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

RE: st: Shorthand way of applying an IF to several variables.


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Shorthand way of applying an IF to several variables.
Date   Wed, 19 Nov 2003 11:53:47 -0000

Another way to do it: 

You can identify any observations with zeros with 

. egen zero = eqany(v1-v300), v(0) 

and any with missings with 

. egen miss = rmiss(v1-v300) 

allowing 

. tabstat v1-v300 if !zero & !miss 

That leaves your original variables unchanged. 

Nick 
[email protected] 

P.S. for wider context and some related problems, see

http://www.stata.com/support/faqs/data/selectid.html

and 

http://www.stata.com/support/faqs/data/characteristics.html

Ulrich Kohler
 
> Something like
> 
> . mvdecode v1-v300, mv(0)
> . mark touse
> . markout touse v1-v300
> . tabstat varlist if touse
 
Rod Hunter 

> > I have, say, 500 observations and 300 variables. I want 
> to do a TABSTSAT
> > that has an IF condition such that any observation is not 
> to be included
> > in the tabstat if the value of any variable is zero or 
> missing. I know
> > how I can do this the long way, but could someone tell me 
> how, or where
> > I can find out how I can use an operaion that would save 
> me having to
> > list each of the 300 variables in the IF condition?

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