Dear all,
I am writing to ask for help in using macro variables in loops.
My code is something as follows. The reason I define a global ind_var is that I want to use different sets of ind_var so that I can just uncomment one of them and comment the rest to reuse the program.
However it does not seem to work - stata seems to ignore `type' in the regression.
Anyone know how to get this to work? or is it not possible to use macro variables in loop? Any advice or comment is highly appreciated.
global controls control1 control2 control3
global ind_var iv1`type' iv2`type' iv3`type' iv4`type'
*global ind_var iv1`type' iv2`type' iv3`type'
*global ind_var iv1`type' iv2`type' iv5`type'
*global ind_var iv1`type' iv2`type' iv6`type'
foreach type in type1 type2 type3 type4{
reg dv $ind_var $controls, fe
}
Related Posts with using macro variables in loop
Error reshaping from wide to longI am getting an error message as 'variable id does not uniquely identify the observations' while res…
How can I view/show previously entered commands from a saved .dta file when operating in new Stata window?I am having trouble location & showing the commands I had entered in a saved .dta file when I op…
max sizedeall all I big data I hope to extend it to max do you guys know the code? Thanks …
VAR model with population weightsDear all, I am about to re-estimate a VAR model from a published paper with 23 countries over 30 ye…
Storage type of a new variable. clear all . set obs 1 . gen var=20190417 // today's date in a custom format . format var %10.0g //…
Subscribe to:
Post Comments (Atom)
0 Response to using macro variables in loop
Post a Comment