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 (May 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 4 May 2007 11:49:09 -0400
Reply-To:   Wensui Liu <liuwensui@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Wensui Liu <liuwensui@GMAIL.COM>
Subject:   Re: Call Macro in a loop
Comments:   To: manotickgirl@gmail.com
In-Reply-To:   <1178287788.298115.32960@l77g2000hsb.googlegroups.com>
Content-Type:   text/plain; charset=ISO-8859-1; format=flowed

see if the following is what you are looking for. data test; input m $ v $ s $; datalines; V1 M1 S1 V2 M1 S1 V3 M1 S1 V4 M2 S2 V5 M2 S2 V6 M2 S2 V7 M3 S3 ; run;

%macro test(m, v, s); %put &m &v &s; %mend;

data _null_; do until (eof); set test end = eof; call execute('%test('||m||', '||v||', '||s||')'); end; run;

On 5/4/07, manotickgirl@gmail.com <manotickgirl@gmail.com> wrote: > Hello, > I have a table: > V1 M1 S1 > V2 M1 S1 > V3 M1 S1 > V4 M2 S2 > V5 M2 S2 > V6 M2 S2 > V7 M3 S3 > ... > > I have a macro that accepts parameters V&i, M&i, S&i and uses them in > a formula. > My goal is to form variables V&I, M&i, S&i in a loop: i=1 to n. > Is it possible to do smth like this: > > data _null_; > do i=1 to &n; > V=cat('V',i); > if (i) in &subj then do; > counter+1; > m=cat('m',counter); > s=cat('s',counter); > call symput('V',V); > end; > %macro2(V,M,S); > > end; > run; > > Or: > > %macro macro1; > %do i=1 %to &n; > V=V&i; > %if (&i-1) in &subj %then %do; > &counter+1; > m=m&counter; > s=s&counter; > %macro2(V,M,S); > %end; > run; > %mend macro1; > > I get errors in both cases. > > Please, help me. >

-- WenSui Liu A lousy statistician who happens to know a little programming (http://spaces.msn.com/statcompute/blog)


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