Hello!
I´m programming several combinations of regressions. In order to streamline the code and avoid unnecessary work when changes to the regressions are need, I decided to define the regression models inside programs, and then call the necessary program using if and else statements inside the loops. My problem comes from Stata not executing the code inside the program as I expected. I made the following very simplified example to demonstrate what I would expect to happen:
Thus, I expected that in the first and second time the loop runs, the output to be:
But what I get is:
I appreciate any insights on how I can make this work or if you can link me to any guides that addresses this problem or other solutions regarding loops over loops or loops with programs.
Thanks for your help!
Best,
Hélder
I´m programming several combinations of regressions. In order to streamline the code and avoid unnecessary work when changes to the regressions are need, I decided to define the regression models inside programs, and then call the necessary program using if and else statements inside the loops. My problem comes from Stata not executing the code inside the program as I expected. I made the following very simplified example to demonstrate what I would expect to happen:
Code:
capture program drop myprog1 program define myprog1 di "var is: `size'" end local vars all size_class foreach myvars of local vars { myprog1 }
Code:
var is: all var is: size_class
Code:
var is: var is:
Thanks for your help!
Best,
Hélder
Comment