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
Redirecting All Ado Paths to New Drive & FolderAt some unfortunate time, I named my partitioned drive with the letter "B". I am setting up a new co…
Time series operators not allowed?Dear All, I would like to create a 5 month *follow up period* after a specific variable takes a valu…
Solve a system of equationsHello everybody! I would like to solve in Stata ( or maybe Mata? I never used it) this system of equ…
Dropping all companies with no observation at the start of the time periodHi Statalist, I have a database of a lot of companies for 7 years: 01-2013 to 01-2019. However, in …
How to use a Cox regression model for time-to-event analysis using different years as controlGood day Background: I am trying to conduct a retrospective epidemiological study looking at the in…
Subscribe to:
Post Comments (Atom)
0 Response to using macro variables in loop
Post a Comment