%env3
%put ** In open code: **;
%put _user_;
data temp;
y="&myvar3";
run;
In this case, the DATA step is complete and executes within the macro, but the local
symbol table is empty. So, CALL SYMPUT creates MYVAR3 in the closest available
nonempty symbol table—the global symbol table. Both %PUT statements show that
MYVAR3 exists in the global symbol table:
** Inside the macro: **
GLOBAL MYVAR3 a token
** In open code: **
GLOBAL MYVAR3 a token
Example Using CALL SYMPUT with SYSPBUFF and an Empty Local
Symbol Table
In the following example, the presence of the SYSPBUFF automatic macro variable
causes CALL SYMPUT to behave as if the local symbol table were not empty, even
though the macro ENV4 has no parameters or local macro variables:
%macro env4 /parmbuff;
data _null_;
x = 'a token';
call symput('myvar4',x);
run;
%put ** Inside the macro: **;
%put _user_;
%put &syspbuff;
%mend env4;
%env4
%put ** In open code: **;
%put _user_;
%put &syspbuff;
data temp;
y="&myvar4"; /* ERROR - MYVAR4 is not available in open code */
run;
The presence of the /PARMBUFF specification causes the SYSPBUFF automatic macro
variable to be created. So, when you call macro ENV4, CALL SYMPUT creates the
macro variable MYVAR4 in the local symbol table (that is, in ENV4's). This action
happens even though the macro ENV4 has no parameters and no local variables.
The results of the %PUT statements prove the following:
• the score of MYVAR4 is listed as ENV4
• the reference to SYSPBUFF does not resolve in the open code %PUT statement
because SYSPBUFF is local to ENV4
Special Cases of Scope with the CALL SYMPUT Routine 71