Date: Fri, 4 May 2007 19:49:46 +0000
Reply-To: iw1junk@COMCAST.NET
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <iw1junk@COMCAST.NET>
Subject: Re: Call Macro in a loop
Summary: Use arrays!
#iw-value=1
manotickgirl,
data out (drop = i j);
set in ;
array v (30) ;
array m (4) ;
array s (4) ;
array r (*) r1-r30 ;
do i = 1 to dim(r) ;
if i in ( 1, .... ) then j + 1 ;
r[i] = (v[i] - m[j])/ s[j] ;
end ;
run ;
Sorry for the dots but you are not trying very hard to be clear about
&I in &SUBJ. Unrolling the array with a macro should have minimal affect
on the execution time.
If you insist on trying it then try
%macro q ;
%local i j ;
%do i = 1 %to 30 ;
%if &i .... %then
%let j = %eval(&j + 1) ;
r&i = (v&i-m&j) / s&j ;
%end ;
%mend q ;
data out ;
set in ;
%q
run ;
If you find the time significantly different, please let us know.
Ian Whitlock
================
Date: Fri, 4 May 2007 11:11:11 -0700
Reply-To: manotickgirl@GMAIL.COM
Sender: "SAS(r) Discussion"
From: manotickgirl@GMAIL.COM
Organization: http://groups.google.com
Subject: Re: Call Macro in a loop
Comments: To: sas-l
In-Reply-To:
<050420071651.27534.463B64920006299E00006B8E220702085305029A06CE9907@comcas
t.net>
Content-Type: text/plain; charset="iso-8859-1"
I didn't explain it well, sorry, I'll try it again: Table: V1 V2...M1
M2...S1 S2... R1 R2... Gene1 .....(values)... (values) Gene2
.....(values)... (values)
I add variables R1 R2... as follows: R1=(V1-M1)/S1, R2=(V2-M1)/S1... R30=
(V30-M4)/S4... I wanna optimize this, I can pass parameters R&I, V&I, M&I
and S&I to macro2: %macro macro2(R,V,M,S); data test2; set test1; &R=
(&V-&m)/(&s;) run; %mend macro2;
What I need is to go from i=1 to n and form parameters like (R1, V1, M1,
S1), (R2, V2, M1, S1) ... with a jump in a counter for m and s every time I
find &i in an array &subj.