Bookmark and Share

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]

Re: st: if in loop not working


From   Ronnie Babigumira <[email protected]>
To   [email protected]
Subject   Re: st: if in loop not working
Date   Mon, 23 Apr 2012 16:15:18 +0200

What is the expression - replace s = `s`t'' if agecat == `t' - supposed to be doing?


-- 
010100100110111101101110011011100110100101100101




On Monday, April 23, 2012 at 3:43 PM, Paula Smith wrote:

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



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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index