Date: Tue, 10 Jun 2008 04:01:59 -0700
Reply-To: RolandRB <rolandberry@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: RolandRB <rolandberry@HOTMAIL.COM>
Organization: http://groups.google.com
Subject: Re: Macro variable not resolving outside macro program
Content-Type: text/plain; charset=ISO-8859-1
On Jun 10, 12:44 pm, guya.carpen...@gmail.com wrote:
> The macro program below works. The %put within the program shows that
> a macro variable (buzz1 buzz2 etc) is created with the data that I
> want.
>
> However, the %puts outside the macro program do not work. Can anybody
> see a silly error I have made with this?
>
> Thanks.
>
> %macro buzz (randno,var);
> data _null_;
> set buzzwords (where=(count=&&rand&randno));
> call symputx("buzz&randno",&var);
> run;
> %put !BUZZ&randno! = !&&buzz&randno!;
> %mend buzz;
> %buzz (1,first)
> %buzz (2,second)
> %buzz (3,third)
> %buzz (4,fourth);
>
> %put &buzz1 &buzz2 &buzz3 &buzz4..;
You have not made a mistake. This is due to the scope of the macro
variable. The macro variables created inside a macro are not
accessible outside the macro unless you declare them as "global".
|