set all_dogs;
where dogtype="&type" and dogorig="&origin";
put breed " is for &type.";
run;
%put _user_;
%mend dogs;
%dogs(type=work)
The %PUT statement preceding the %MEND statement writes to the SAS log the
scopes, names, and values of all user-generated macro variables:
DOGS TYPE work
GLOBAL ORIGIN North America
Because TYPE is a macro parameter, TYPE is local to the macro DOGS, with value
work. Because ORIGIN is defined in open code, it is global.
How Macro Variables Are Assigned and Resolved
Before the macro processor creates a variable, assigns a value to a variable, or resolves a
variable, it searches the symbol tables to determine whether the variable already exists.
The search begins with the most local scope and, if necessary, moves outward to the
global scope. The request to assign or resolve a variable comes from a macro variable
reference in open code (outside a macro) or within a macro.
The following figure illustrates the search order the macro processor uses when it
receives a macro variable reference that requests a variable be created or assigned. The
figure below illustrates the process for resolving macro variable references. Both of
these figures represent the most basic type of search and do not apply in special cases,
such as when a %LOCAL statement is used or the variable is created by CALL
SYMPUT.
54 Chapter 5 Scopes of Macro Variables
Figure 5.3 Search Order When Assigning or Creating Macro Variables
How Macro Variables Are Assigned and Resolved 55
Figure 5.4 Search Order When Resolving Macro Variable References
56 Chapter 5 Scopes of Macro Variables
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset