Figure 5.7 Symbol Tables Showing Two Levels of Nesting
Notice that the placement of a macro invocation is what creates a nested scope, not the
placement of the macro definition. For example, invoking CONDITN from within
NAME3 creates the nested scope. It is not necessary to define CONDITN within
NAME3.
Forcing a Macro Variable to Be Local
At times that you need to ensure that the macro processor creates a local macro variable
rather than changing the value of an existing macro variable. In this case, use the
%LOCAL statement to create the macro variable.
Always make all macro variables created within macros local when you do not need
their values after the macro stops executing. Debugging the large macro programs is
easier if you minimize the possibility of inadvertently changing a macro variable's value.
Also, local macro variables do not exist after their defining macro finishes executing, but
global variables exist for the duration of the SAS session. Therefore, local variables use
less overall storage.
Examples of Macro Variable Scopes 61