Macros
Contents
Globals
Global macros are declared with the global command. Generally these are discouraged, because their very nature (i.e. globally available) creates side-effects.
global COHORT 1
generate number=${COHORT}
generate string="${COHORT}"To loop over words in a global macro, see here.
Locals
Local macros are declared with the local command, and only exist in the local scope.
local stringvars var1 var2 destring `stringvars', force
To loop over words in a local macro, see here.
Note that looping creates local macros to store the current word. These local macros are accessed in the same manner
foreach v of local stringvars {
destring `v', force
}
Evaluation
If a macro definition includes an equals sign (=), then what follows is evaluated as an expression.
. local count1 = _N . local count2 _N . display "`count1' vs. `count2'" 100 vs. _N . display "`count1' vs. " `count2' 100 vs. 100
