Date: Wed, 22 Jul 1998 08:54:34 -0400
Reply-To: WHITLOI1 <WHITLOI1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: WHITLOI1 <WHITLOI1@WESTAT.COM>
Subject: Re: Local macro variables
Content-Type: text/plain; charset=US-ASCII
Subject: Local macro variables
Sumary: CALL EXECUTE can be used to delay macro invocation until
after the DATA step has finished.
Respondent: Ian Whitlock <whitloi1@westat.com>
Several days ago I responded to Seidl Zdenek's <SeidlZ@TESCOSW.CZ>
question about why his code was not working without giving a good
solution.
> %macro sample;
> %local xxx;
> data _null_;
> call symput("xxx","TEST");
> run;
> %put _all_;
> %mend sample;
>
> data _null_;
> call execute('%sample;');
> run;
The problem is that %SAMPLE executes, i.e. generates code, during the
DATA step. The solution is to delay the invocation of the macro until
after the DATA step has finished so that the macro executes in the normal
manner.
data _null_;
call execute('%nrstr(%sample;)');
run;
With the surrounding %NRSTR the macro facility dumps the macro
invocation into the input stack instead of the code generated by the
macro.
Ian Whitlock <whitloi1@westat.com>