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 (March 2002, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 29 Mar 2002 09:27:23 -0800
Reply-To:     shiling zhang <shiling99@YAHOO.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         shiling zhang <shiling99@YAHOO.COM>
Organization: http://groups.google.com/
Subject:      Re: Macro-Problem: Writing macro-variables into a data-set
Content-Type: text/plain; charset=ISO-8859-1

Why not use the Peter's suggestion. All the information you want is already in sashelp.macros.

197 %macro testit(dummy); 198 %let y1=1; 199 %let y2=2; 200 %let y3=3; 201 %let y4=4; 202 203 data _null_; 204 set sashelp.vmacro; 205 mvar=value; 206 put mvar=; 207 where upcase(scope)='TESTIT' and upcase(name) in : ('Y'); 208 run; 209 210 %mend; 211 %testit();

mvar=1 mvar=2 mvar=3 mvar=4 NOTE: There were 4 observations read from the data set SASHELP.VMACRO. WHERE (scope='TESTIT') and UPCASE(name) in: ('Y'); NOTE: DATA statement used: real time 0.01 seconds cpu time 0.01 seconds

olaf.kruse@VST-GMBH.DE (Dr Olaf Kruse) wrote in message news:<416A07CFC6C1D311A796000083295C33FA62@VSTPC04>... > Many thanks to Jim, Peter, Dennis and Carsten > for their helpfull suggestions. > > The easiest solution for my example seems to be: > > data mydata; > %do i=1 %to 4; > Result=&&x&i; > output; > %end > > It works fine, but in my real-world-problem &x > is a macro-variable itself. > > /*******************/ > %let b=x ; > > data mydata; > %do i=1 %to 4; > Result=&&b&i; > output; > %end; > > /********************/ > > > I this case (see code above) &&b&i doesn't resolve to x1 etc. So I have to > stick to my cumbersome solution: > > /********************/ > data mydata; > do i=1 to 4; > call symput('j',trim(left(i))); > Result=resolve('&&x&j'); > output; > end; > /********************/ > > > Thanks again, > > Olaf > > (I'm out of office for the next 10 days, so I cannot comment any > further replies in time)


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