| Date: | Wed, 22 Jul 1998 09:22:52 -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 |
(This is not a duplicate of a previous message. I say so because it
appeared to be rejected by the listserver on that basis.)
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>
|