Syntax, %GLOBAL statement:
%GLOBAL macro-variable-1 <...macro-variable-n>;
macro-variable
is either the name
of a macro variable or a text expression that generates a macro variable
name.
|
%macro printdsn; %global dsn vars; %let dsn=certadv.courses; %let vars=course_title course_code days; proc print data=&dsn; var &vars; title "Listing of &dsn data set"; run; %mend printdsn; %printdsn
%symdel dsn;
Syntax, %LOCAL statement:
%LOCAL macro-variable-1 <...macro-variable-n>;
macro-variable
is either the name
of a macro variable or a text expression that generates a macro variable
name.
|
CertAdv.Courses
to
it.Certadv.Register
to the local variable
Dsn.%let dsn=certadv.courses; %macro printdsn; %local dsn; %let dsn=certadv.register; %put The value of DSN inside Printdsn is &dsn; %mend; %printdsn %put The value of DSN outside Printdsn is &dsn;
199 %let dsn=certadv.courses; 200 201 %macro printdsn; 202 %local dsn; 203 %let dsn=certadv.register; 204 %put The value of DSN inside Printdsn is &dsn; 205 %mend; 206 207 %printdsn The value of DSN inside Printdsn is certadv.register 208 %put The value of DSN outside Printdsn is &dsn; The value of DSN outside Printdsn is certadv.courses
%macro test; %local x; /*1*/ %let x=FALSE; /*2*/ %macro test; %test;
1 | The macro variable, X, is defined with a %LOCAL statement. When the %LOCAL statement executes, a local symbol table is created for the test macro, and the macro variable, X, is created in this local table. |
2 | When the macro processor executes the %LET statement, it searches the test macro's local table for a macro variable named X. It finds X in this local table and sets its value to False. |