Hi all,
I have been having an issue with using for loop and if statements
together with a semi-colon delimiter. The following is some example
code for the problem I've come across:
# delimit ;
local j = 1;
foreach x of varlist var1-var3{;
forval i = 1/12{;
if(`j'<3){;
replace `x' = `x'[`i']-`x'[`j'] in `i';
local j = `j' + 1;
};
else{;
replace `x' = `x'[`i']-`x'[`j'] in `i';
local j = 3;
};
};
};
Whenever I try running this I get an error on my if statement, where
Stata interprets "< 3" as a variable name. Any suggestions for loops
and if statements using delimiters would be greatly appreciated.
Thanks for your time,
Ryan Stevens
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/