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
Create a variable counting occurrencesHello, I'm using Stata for the first time and encountered some difficulties. I'm working with Stat…
panel data analysisHello, I am performing analysis on an unbalanced panel dataset, of 160 firms which have data availa…
Matrix of matricesDears I would like to create a matrix containing the results of other matrices generated after the …
Difference-in-difference fixed effects for discontinued treatmentDear all, I am trying to run a difference-in-difference fixed-effects model to estimate the effect …
Converting annual to quarterly GDPHello everyone. I am trying to convert annual data to quarterly data. In particular, I have annual G…
Subscribe to:
Post Comments (Atom)
0 Response to using macro variables in loop
Post a Comment