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

st: RE: repeating same command for a number of variables


From   "Nick Winter" <[email protected]>
To   <[email protected]>
Subject   st: RE: repeating same command for a number of variables
Date   Thu, 11 Jul 2002 12:21:36 -0400

local vars "other1c other2c other3c other4c"
gen bad=0
foreach v of varlist `vars' {
	replace bad=1 if `v'>22 & `v'!=.
}
list `vars' if bad


> -----Original Message-----
> From: Babigumira Ronnie [mailto:[email protected]] 
> Sent: Thursday, July 11, 2002 12:11 PM
> To: [email protected]
> Subject: st: repeating same command for a number of variables
> 
> 
> Dear listers
> There must be an easier way of doing this, please help
> 
> I am looking survey data and in this particular section, 
> respondents have
> given reasons for saving. I allow for upto four reasons and 
> as such have
> four variables (other1c other2c other3c other4c). Having coded all the
> responses, I have upto 22 reasons and I would now like to flash out
> illegal entries (exceed the codebook limits). I have a crude 
> syntax (which
> lists values greater than the codebook limit of 22 but are 
> not missing)
> 
> list houscode other1c other2c other3c other4c if (other1c >22 &   /*
> */ other1c ~=.)|(other2c >22 & other2c ~=.)|(other3c > 22 & 
> other3c /*	
> */ ~=.) |(other4c > 22 & other4c ~=.)
> 
> Is there an easier (more elegant or less repetitive) way of 
> doing this 
> 
> Roni
> 
> __________________________________________________
> Do You Yahoo!?
> Sign up for SBC Yahoo! Dial - First Month Free
> http://sbc.yahoo.com
> *
> *   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