Date: Wed, 14 Jun 2000 19:27:29 -0400
Reply-To: Richard.Graham@INTELLICISIONS.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard W. Graham" <Richard.Graham@INTELLICISIONS.COM>
Subject: Re: macro variables
Content-type: multipart/mixed;
Boundary="0__=dP1BxIjh7pJ3ipXknIXjHRgopsbgPjbAo0Wm9jur5ggqxW9mTAMGEhUl"
Hi Annie,
The most straigtforward way I know of to process would be the following:
%MACRO sumfunc;
data _null_;
sum = sum(of %do i = 1 %to 200; &&var&i %end;);
run;
%MEND sumfunc;
%sumfunc;
But to make it more dynamic you could keep a counter of the number of macro
variables within another macro variable (i.e., numvars), then change the
200 above to &numvars.
Richard W. Graham
Senior Consultant, Technology Delivery
Intellicisions Data Inc.
2000 Regency Parkway, Suite 355
Cary, NC 27511
(919) 467-0505
(Embedded image moved to file: pic24121.gif)
Annie Chang
<chang5a@YAHOO To: SAS-L@LISTSERV.UGA.EDU
.COM> cc: (bcc: Richard Graham/Tech/Intellicisions)
Sent by: Subject: macro variables
"SAS(r)
Discussion"
<SAS-L@LISTSER
V.UGA.EDU>
06/14/00 06:25
PM
Please respond
to Annie Chang
Hi,
I have a question about use of variables. I created
200 macro variables, say, called 'var1, var2, ...,
var200'. Now I need to do a calculatin on it. For
example,
data _null_;
sum = &var1 + &var2 + ... + &var200;
run;
Obviously, I couldn't use the '...'. Well, I know I
can type those 200 variables but I bet there got to be
a better way and you know it!
Thank you.
P.S. BTW, a couple of weeks ago, I asked another
question and got quite a few answers. Most of them
work fine and solved my problem. Thank you all! This
is a great place and I couldn't resist to think about
this list when I got a problem (I'll try very hard
first to avoid asking you too trivial ones.)
__________________________________________________
Do You Yahoo!?
Yahoo! Photos -- now, 100 FREE prints!
http://photos.yahoo.com
pic24121.gif [image/gif]