BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
1 REPLY 1
Paige
Quartz | Level 8
Have you tried placing the append statement inside the loop, after you calculate S?

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 566 views
  • 0 likes
  • 2 in conversation