I'm trying to construct a foreach loop where I am using a few words as the phrase to loop over to specify the regression variables, graph title and saved graph name. However, there is an invalid syntax error, which I think has to do with STATA either not recognizing the "" or the spaces. How do I specify that correctly?
Here is an example below that would result in that error:
Code:
foreach `x' in "y x" "y z" { reg `x' i.year twoway (connected `x') /// , title(`x'- model, size(medsmall)) graph export C:\Documents\model-diagnostic\`x'- model.pdf, replace }
Code:
reg y x i.year twoway (connected y x) /// , title(y x- model, size(medsmall)) graph export C:\Documents\model-diagnostic\y x- model.pdf, replace
Thank you in advance!
0 Response to Getting STATA to loop phrases (2 or more words with spaces in between)
Post a Comment