<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I create a data set from a loop in Proc IML? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-create-a-data-set-from-a-loop-in-Proc-IML/m-p/55267#M6764</link>
    <description>Have you tried placing the append statement inside the loop, after you calculate S?</description>
    <pubDate>Mon, 20 Oct 2008 12:48:19 GMT</pubDate>
    <dc:creator>Paige</dc:creator>
    <dc:date>2008-10-20T12:48:19Z</dc:date>
    <item>
      <title>How can I create a data set from a loop in Proc IML?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-create-a-data-set-from-a-loop-in-Proc-IML/m-p/55266#M6763</link>
      <description>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. &lt;BR /&gt;
The program looks something like this:&lt;BR /&gt;
&lt;BR /&gt;
data mat3;&lt;BR /&gt;
input i L1 L2 L3 U1 U2 U3 L12;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 624 576 586 34 50 11 321&lt;BR /&gt;
2 562 513 633 51 55 3  286&lt;BR /&gt;
;&lt;BR /&gt;
proc iml;&lt;BR /&gt;
use Mat3;&lt;BR /&gt;
show datasets;&lt;BR /&gt;
show contents;&lt;BR /&gt;
list all;&lt;BR /&gt;
use mat3 var{L1 L12 L12};&lt;BR /&gt;
read all var _num_ into x;&lt;BR /&gt;
use mat3 var{L12 L2 L12}; &lt;BR /&gt;
read all var _num_ into y;&lt;BR /&gt;
use mat3 var{L12 L12 L3};&lt;BR /&gt;
read all var _num_ into w;&lt;BR /&gt;
use mat3 var{U1 U2 U3};&lt;BR /&gt;
read all var _num_ into z;&lt;BR /&gt;
do i=1 to 2;&lt;BR /&gt;
m=x[i,];&lt;BR /&gt;
n=y[i,];&lt;BR /&gt;
r=w[i,];&lt;BR /&gt;
c=insert(n,m,1,0);&lt;BR /&gt;
b=insert(r,c,1,0);&lt;BR /&gt;
v=z[i,];&lt;BR /&gt;
s= v*inv(b)*v`;&lt;BR /&gt;
print s;&lt;BR /&gt;
end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The output is &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
       The SAS System        13:44 Friday, September 10, 2004  72&lt;BR /&gt;
&lt;BR /&gt;
LIBNAME  MEMNAME                          OPEN MODE   STATUS&lt;BR /&gt;
-------- -------------------------------- ---------   --------&lt;BR /&gt;
WORK     MAT3                             Input       Current Input&lt;BR /&gt;
&lt;BR /&gt;
DATASET : WORK.MAT3.DATA&lt;BR /&gt;
&lt;BR /&gt;
 VARIABLE                          TYPE  SIZE&lt;BR /&gt;
 --------------------------------  ----  ----&lt;BR /&gt;
 i                                 num      8&lt;BR /&gt;
 L1                                num      8&lt;BR /&gt;
 L2                                num      8&lt;BR /&gt;
 L3                                num      8&lt;BR /&gt;
 U1                                num      8&lt;BR /&gt;
 U2                                num      8&lt;BR /&gt;
 U3                                num      8&lt;BR /&gt;
 L12                               num      8&lt;BR /&gt;
&lt;BR /&gt;
Number of Variables   : 8&lt;BR /&gt;
Number of Observations: 2&lt;BR /&gt;
&lt;BR /&gt;
   OBS         i        L1        L2        L3        U1        U2        U3       L12&lt;BR /&gt;
------ --------- --------- --------- --------- --------- --------- --------- ---------&lt;BR /&gt;
     1    1.0000  624.0000  576.0000  586.0000   34.0000   50.0000   11.0000  321.0000&lt;BR /&gt;
     2    2.0000  562.0000  513.0000  633.0000   51.0000   55.0000    3.0000  286.0000&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
                                                  S&lt;BR /&gt;
&lt;BR /&gt;
                                              5.4043453&lt;BR /&gt;
&lt;BR /&gt;
                                                  S&lt;BR /&gt;
                                             9.5979905&lt;BR /&gt;
&lt;BR /&gt;
I would like to put s=5.4 and s=9.59 in the single file (as a data set). &lt;BR /&gt;
Can someone please tell me how to get the file I want?&lt;BR /&gt;
Thanks&lt;BR /&gt;
Peyman</description>
      <pubDate>Fri, 17 Oct 2008 14:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-create-a-data-set-from-a-loop-in-Proc-IML/m-p/55266#M6763</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-17T14:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create a data set from a loop in Proc IML?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-create-a-data-set-from-a-loop-in-Proc-IML/m-p/55267#M6764</link>
      <description>Have you tried placing the append statement inside the loop, after you calculate S?</description>
      <pubDate>Mon, 20 Oct 2008 12:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-I-create-a-data-set-from-a-loop-in-Proc-IML/m-p/55267#M6764</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2008-10-20T12:48:19Z</dc:date>
    </item>
  </channel>
</rss>

