Created
December 30, 2015 20:53
-
-
Save crherlihy/59c7520a9cfea330e3f2 to your computer and use it in GitHub Desktop.
Appending variables to a global macro in STATA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Generate temporary variables | |
gen temp_1 = 1 | |
gen temp_2 = 2 | |
gen temp_ 3 = 3 | |
//Initialize global macro | |
global mylist test | |
//Find all vars that start with var_ and append them to the global macro | |
foreach var of varlist var_* { | |
global mylist "$mylist `var'" | |
} | |
//Test to make sure it worked | |
foreach x of global mylist{ | |
disp "`x'" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment