The SAS Output Delivery System and reporting techniques

How can I create a data set from a loop in Proc IML?

Reply
N/A
Posts: 0

How can I create a data set from a loop in Proc IML?

I am using an IML program which is basically a lot of simulation inside a DO loop. The result of each simulation in the DO loop is a 1x1 matrix or scalar (name is s). I would like to create a single file which contains these values for each simulation. I have used the Create and append but it give me the result from the last iteration.
The program looks something like this:

data mat3;
input i L1 L2 L3 U1 U2 U3 L12;
datalines;
1 624 576 586 34 50 11 321
2 562 513 633 51 55 3 286
;
proc iml;
use Mat3;
show datasets;
show contents;
list all;
use mat3 var{L1 L12 L12};
read all var _num_ into x;
use mat3 var{L12 L2 L12};
read all var _num_ into y;
use mat3 var{L12 L12 L3};
read all var _num_ into w;
use mat3 var{U1 U2 U3};
read all var _num_ into z;
do i=1 to 2;
m=x[i,];
n=y[i,];
r=w[i,];
c=insert(n,m,1,0);
b=insert(r,c,1,0);
v=z[i,];
s= v*inv(b)*v`;
print s;
end;
run;



The output is



The SAS System 13:44 Friday, September 10, 2004 72

LIBNAME MEMNAME OPEN MODE STATUS
-------- -------------------------------- --------- --------
WORK MAT3 Input Current Input

DATASET : WORK.MAT3.DATA

VARIABLE TYPE SIZE
-------------------------------- ---- ----
i num 8
L1 num 8
L2 num 8
L3 num 8
U1 num 8
U2 num 8
U3 num 8
L12 num 8

Number of Variables : 8
Number of Observations: 2

OBS i L1 L2 L3 U1 U2 U3 L12
------ --------- --------- --------- --------- --------- --------- --------- ---------
1 1.0000 624.0000 576.0000 586.0000 34.0000 50.0000 11.0000 321.0000
2 2.0000 562.0000 513.0000 633.0000 51.0000 55.0000 3.0000 286.0000



S

5.4043453

S
9.5979905

I would like to put s=5.4 and s=9.59 in the single file (as a data set).
Can someone please tell me how to get the file I want?
Thanks
Peyman
Super Contributor
Posts: 281

Re: How can I create a data set from a loop in Proc IML?

Posted in reply to deleted_user
Have you tried placing the append statement inside the loop, after you calculate S?
Ask a Question
Discussion stats
  • 1 reply
  • 105 views
  • 0 likes
  • 2 in conversation