<?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: Convert a table into a matrix for use with PROC IML in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453924#M284074</link>
    <description>&lt;P&gt;You can use &lt;A href="http://go.documentation.sas.com/?docsetId=imlug&amp;amp;docsetTarget=imlug_langref_sect151.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_self"&gt;the FULL function&lt;/A&gt; in SAS/IML to convert the data into a rectangular form:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
input I      J       tot;
datalines;
1     1      250
1     2      545
1     3      654
2     1       54
2     2      458
2     3      878
3     1       87
3     2      447
3     3      562
;

 proc iml;
use Have;
read all var {tot i j} into S;
close;

X = full(S);
print X;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 Apr 2018 14:20:29 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2018-04-13T14:20:29Z</dc:date>
    <item>
      <title>Convert a table into a matrix for use with PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453712#M284071</link>
      <description>&lt;P&gt;I have a table that that has the 'i', 'j',&amp;nbsp;'tot' columns and I want to convert this table into a 2x2 matrix with i as the row index and j as the column index and assign the tot as&amp;nbsp;value. Is there a PROC that i can use? i, j range from 1 to 26.&lt;/P&gt;&lt;P&gt;I need to do this so that&amp;nbsp;I can use the resultant matrix and perform matrix operations with PROC IML.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; J&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tot&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 250&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 545&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 654&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 54&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 458&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;878&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 87&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 447&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 562&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my output should be like :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; 250&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 545&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 654&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp; 54&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;458&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 878&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp; 87&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 447&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 562&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 13:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453712#M284071</guid>
      <dc:creator>SC_1991</dc:creator>
      <dc:date>2018-04-13T13:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a table into a matrix for use with PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453716#M284072</link>
      <description>&lt;P&gt;PROC REPORT will do this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Define variable I as a GROUP variable and J as an across variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are functions in PROC IML (such as the SHAPE function) that should be able to do this as well, meaning you can skip the intermediate step and go straight to PROC IML.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 19:09:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453716#M284072</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-04-12T19:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a table into a matrix for use with PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453909#M284073</link>
      <description>&lt;P&gt;Calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 13:58:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453909#M284073</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-04-13T13:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a table into a matrix for use with PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453924#M284074</link>
      <description>&lt;P&gt;You can use &lt;A href="http://go.documentation.sas.com/?docsetId=imlug&amp;amp;docsetTarget=imlug_langref_sect151.htm&amp;amp;docsetVersion=14.3&amp;amp;locale=en" target="_self"&gt;the FULL function&lt;/A&gt; in SAS/IML to convert the data into a rectangular form:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
input I      J       tot;
datalines;
1     1      250
1     2      545
1     3      654
2     1       54
2     2      458
2     3      878
3     1       87
3     2      447
3     3      562
;

 proc iml;
use Have;
read all var {tot i j} into S;
close;

X = full(S);
print X;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Apr 2018 14:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453924#M284074</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-04-13T14:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a table into a matrix for use with PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453926#M284075</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input I      J       tot;
cards;
1     1       250
1     2      545
1     3      654
2     1         54
2     2       458
2     3         878
3     1         87
3     2         447
3     3        562
;

proc iml;
use have;
read all var {i j tot};
close;
x=tot||i||j;
want=full(x);
print want;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Apr 2018 14:27:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453926#M284075</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-04-13T14:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a table into a matrix for use with PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453929#M284076</link>
      <description>is there a way to change the matrix index into&lt;BR /&gt;1 2 3&lt;BR /&gt;1&lt;BR /&gt;2&lt;BR /&gt;3&lt;BR /&gt;&lt;BR /&gt;instead of&lt;BR /&gt;&lt;BR /&gt;col1 col2 col 3&lt;BR /&gt;row1&lt;BR /&gt;row2&lt;BR /&gt;row 3&lt;BR /&gt;&lt;BR /&gt;thanks for your help</description>
      <pubDate>Fri, 13 Apr 2018 14:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453929#M284076</guid>
      <dc:creator>SC_1991</dc:creator>
      <dc:date>2018-04-13T14:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a table into a matrix for use with PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453930#M284077</link>
      <description>that works! thanks.</description>
      <pubDate>Fri, 13 Apr 2018 14:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453930#M284077</guid>
      <dc:creator>SC_1991</dc:creator>
      <dc:date>2018-04-13T14:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a table into a matrix for use with PROC IML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453932#M284078</link>
      <description>&lt;P&gt;Sure.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input I      J       tot;
cards;
1     1       250
1     2      545
1     3      654
2     1         54
2     2       458
2     3         878
3     1         87
3     2         447
3     3        562
;

proc iml;
use have;
read all var {i j tot};
close;
x=tot||i||j;
want=full(x);
idx=char(1:nrow(want));
print want[r=idx c=idx l=''];
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Apr 2018 14:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-a-table-into-a-matrix-for-use-with-PROC-IML/m-p/453932#M284078</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-04-13T14:38:21Z</dc:date>
    </item>
  </channel>
</rss>

