Skip to content

Instantly share code, notes, and snippets.

@crherlihy
Created December 30, 2015 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crherlihy/59c7520a9cfea330e3f2 to your computer and use it in GitHub Desktop.
Save crherlihy/59c7520a9cfea330e3f2 to your computer and use it in GitHub Desktop.
Appending variables to a global macro in STATA
//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