Date: Wed, 12 May 2004 04:46:43 -0400
Reply-To: Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Subject: Re: Scope of Macro Variables
...use the %global statement:
%macro a;
%global x;
%let x=1;
%mend;
%a;
%put &x;
or in your case:
%global mynumber;
On Tue, 11 May 2004 23:45:51 -0400, PCW <walker.627@COMCAST.NET> wrote:
>I want to create a macro variable during a macro execution using call
>symput. Then, I want this macro variable to be available AFTER the macro
>has executed, say for use in a second macro. IS THIS POSSIBLE?
>
>For sake of illustration, here is some code. Suppose that the following
>macro %first is stored in an autocall library (important).
>
>%macro first;
> data temp;
> x=257;
> run;
>
> data _null_;
> set temp;
> call symput('mynumber',x);
> run;
>%mend first;
>
>Now suppose that I call the macro.
>
> %first
>
>Now suppose that I want to see what macro variables are available on the
>macro symbol table.
>
> %put _all_;
>
>I find that the macro variable &mynumber is not available. Even if I add
>the line "%global mynumber;" to the macro definition, &mynumber is still
>not available outside of the macro.
>
>Is there a way to make &mynumber available for later use outside of the %
>first macro???
|