numberofpeople`i' is not a number.
Have locals numberofpeople1 - numberofpeople17 previously been defined?
Perhaps something like this:
local number1 = 2
local number2= 3
local number3= 1
forvalues i = 1/3 {
forvalues j=1/`number`i'' {
disp `i' " " `j'
}
}
Scott
On Wed, Jan 18, 2012 at 1:26 PM, Bader Alhashel <balhashel@gmail.com> wrote:
> 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/
*
* 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/