LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: sas-l@uga.edu
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".


Back to: Top of message | Previous page | Main SAS-L page