I am experiencing a syntax problem. I would like to call a global variable base on a string create through a loop made up with several strings. I cannot get the syntax to call the global variable right. Would you be able to correct my mistake?
Code:
* Global variables I am trying to call global N_BUY_LNASCOMP=12 global N_BUY_LS&PCOMP=5 global N_BUY_LS&P600I=5 global N_BUY_LDJCMP65=2 foreach universe in "LS&PCOMP" "LDJCMP65" "LNASCOMP" "LS&P600I" { use http://www.stata-press.com/data/r9/autornd.dta, clear gen rank=_n keep rank * This is where I need help changing the ${N_BUY_"`universe'"} syntax keep if rank<=${N_BUY_"`universe'"} }
0 Response to Add local variable string to a string to call global variable in a loop
Post a Comment