Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: if in loop not working
From
Paula Smith <[email protected]>
To
[email protected]
Subject
st: if in loop not working
Date
Mon, 23 Apr 2012 14:43:16 +0100
Hi,
I'm having trouble with this bit of code and am wondering if anyone can
help me. The 'if' within the loop if causing the program to stall and
I'm getting an 'if not found' error.
gen t = 20 if agecat == 1
replace t = 5 if agecat >= 2 & agecat <= 11
replace t = 10 if agecat == 12
gen s = .
gen r = .
gen q = .
gen p = .
qui forvalues t = 1/12 {
replace s = `s`t'' if agecat == `t'
replace r = `r`t'' if agecat == `t'
replace q = `q`t'' if agecat == `t'
replace p = `p`t'' if agecat == `t'
}
*
* 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/