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: Overlapping Loops
From 
 
Bader Alhashel <[email protected]> 
To 
 
statalist <[email protected]> 
Subject 
 
st: Overlapping Loops 
Date 
 
Wed, 18 Jan 2012 14:26:50 -0500 
I am trying to write two over lapping "foreach" loops however I keep
getting an invalid syntax error. I don't know why but I am guessing it
is because of the local macro in the first loop is not recognized in
the second loop. This is the code I am trying to run.
forvalues i = 1/17 {
gen ceo_photo`i'=0 if photo`i'==1
forvalues j=1/numberofpeople`i' {
replace ceo_photo`i'=1 if ceo == name`j'_photo`i' & ceo_photo`i'==0
}
}
Your help would be greatly appreciated,
Bader
*
*   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/