Hey!
I am declaring a global macro with a list of variables to do a loop, and then keep only those variables. While the global option is working on the loop, it is not working with the keep command. Any ideas why?
The error I am getting is:
varlist, if exp, or in range required
Which I assume Stata is not understanding that my global `variables' is a varilist. What am I doing wrong?
Thanks!!
I am declaring a global macro with a list of variables to do a loop, and then keep only those variables. While the global option is working on the loop, it is not working with the keep command. Any ideas why?
Code:
global variables risk_general risk_driving risk_finances foreach var of global variables { gen `var' = `var'_2010 if `var'_2010 >= 0 replace `var' = `var'_2011 if `var'_2011 >= 0 } keep `variables'
varlist, if exp, or in range required
Which I assume Stata is not understanding that my global `variables' is a varilist. What am I doing wrong?
Thanks!!
Comment