Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Overlapping Loops

From   Bader Alhashel <>
To   statalist <>
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,
*   For searches and help try:

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