Date: Fri, 4 Jul 2008 03:56:04 -0700
Reply-To: domenico <stataDat@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: domenico <stataDat@GMAIL.COM>
Organization: http://groups.google.com
Subject: do-while and proc iml
Content-Type: text/plain; charset=ISO-8859-1
The macro below is an exercise that I am doing to better understand
sas / iml + macro (I am newbie, the macro perhaps it seems that it
makes little sense, but is only an exercise).
In particular, an element of (x_ij & m) gives me a value equal to 1 if
the corresponding elements of x_ij and m are both different from 0.
Then sum (x_ij & m) will be equal to 2500 after 2500 loops, but I get
an error in correspondence to:
%let h = %eval (sum (x_ij & m));
Someone can give me some suggestions?
thank you
domenico
/*---------------------------------------
macro----------------------------------------------------------------
*/
%macro test;
%let k=1;
%let h=0;
proc iml;
x_i=j(50,1,0);
x_ij=I(50);
m=j(50,50,1);
%do %while(&h<2500);
x_i[&k,1]=&k+1;
x_ij=x_ij + x_i*t(x_i);
%let k=%eval(&k+1);
%let h=%eval(sum(x_ij & m));
%end;
quit;
%mend test;
%test;
|