<?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: Can proc iml be converted into an sql format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-proc-iml-be-converted-into-an-sql-format/m-p/578119#M163918</link>
    <description>&lt;P&gt;What did you try?&lt;/P&gt;
&lt;P&gt;First thing is to convert your "matrix" into a proper dataset. If you have a 2 dimensional matrix with R rows and C cols you should store that as a dataset with R times C observations.&amp;nbsp; One variable has the row index, one has the column index and the third has the value.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
price = 
{10 20 30
,40 50 60
};
print price;
quit;
 
data price_table;
  row+1;
  do col=1 to 3 ;
    input price @;
    output;
  end;
cards;
10 20 30
40 50 60
;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;            price

       10        20        30
       40        50        60
&amp;#12;

Obs    row    col    price

 1      1      1       10
 2      1      2       20
 3      1      3       30
 4      2      1       40
 5      2      2       50
 6      2      3       60
&lt;/PRE&gt;
&lt;P&gt;Similarly a 3 dimensional array becomes a dataset with 4 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Jul 2019 15:35:12 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-07-31T15:35:12Z</dc:date>
    <item>
      <title>Can proc iml be converted into an sql format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-proc-iml-be-converted-into-an-sql-format/m-p/578042#M163888</link>
      <description>&lt;P&gt;Hi. I have some code in the proc iml format and was wondering if it could possibly be converted into a sql format?&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: navy; font-family: &amp;quot;Courier New&amp;quot;;"&gt;proc&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;SPAN style="background: white; color: navy; font-family: &amp;quot;Courier New&amp;quot;;"&gt;iml&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;/****************************************&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Reading the data into a iml matrix&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;*****************************************/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;Use&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; price3_1;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;/*price = j(2000000,482,0);*/&lt;/SPAN&gt; &lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;/*(number of transactions, number of date points,fill with zeros) = creating the size of the matrix price3&amp;nbsp; */&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;read&lt;/SPAN&gt; &lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;all&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; into price;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;/************************************************************&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Creating the X and Y matrix &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;Y is a matrix containing all the data for the&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;first month of the entire time period (bases time step)&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;and its size one by (number of transactions) &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;X is a matrix containing the data point from the second&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;time period to the last time period of all the transactions,&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;and its size is&amp;nbsp; (time steps -1) by (amount of transactions) &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;*************************************************************/&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;X&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; = price[,&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;2&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;:ncol(price)];&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;Y = Price[,&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;];&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;/*************************************************************&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In order to compute beta according to the Case Shiller&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; method You have to change the first price in each row &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; of the X matrix to a negative value and keep the second&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; price the same, except if the transactions first price&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; falls within the bases time period thus in the Y matrix&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then the first and only price in the X matrix row stays&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; positive. &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;**************************************************************/&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; i = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; nrow(x);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;one = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; y[i,&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;] &amp;gt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;then&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; j = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; to ncol(x);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x[i,j] = x[i,j];&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;else&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; j = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; to ncol(x);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; one = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; x[i,j] = x[i,j]*-&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; ;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; x[i,j] = x[i,j]; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; one = x[i,j]+one;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;/*************************************************************&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Z is basically the X matrix except that the price is&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; changed to one thus where there is a negative price in&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; X&amp;nbsp;&amp;nbsp; there is -1 in Z and where there is a positive price&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; in X there is a 1 in Z else the rest stays zero.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: green; font-family: &amp;quot;Courier New&amp;quot;;"&gt;**************************************************************/&lt;/SPAN&gt; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;Z = j(nrow(x),ncol(x),&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; i = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; nrow(x);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; j = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; ncol(x);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; x[i,j] = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; z[i,j] = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; x[i,j] &amp;gt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; z[i,j] = &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; x[i,j] &amp;lt; &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;0&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt; z[i,j] = -&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN style="background: white; color: teal; font-family: &amp;quot;Courier New&amp;quot;;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;;&amp;nbsp; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;SPAN style="background: white; color: blue; font-family: &amp;quot;Courier New&amp;quot;;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: black; font-family: &amp;quot;Courier New&amp;quot;;"&gt;&lt;FONT size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 12:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-proc-iml-be-converted-into-an-sql-format/m-p/578042#M163888</guid>
      <dc:creator>Tzar</dc:creator>
      <dc:date>2019-07-31T12:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can proc iml be converted into an sql format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-proc-iml-be-converted-into-an-sql-format/m-p/578048#M163891</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283527"&gt;@Tzar&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi. I have some code in the proc iml format and was wondering if it could possibly be converted into a sql format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Having examined this IML code, where you are performing operations across the rows according to some value of another variable in the row, I am going to answer your question with NO. (or it would be extremely difficult to do in SQL) (it might be also easily do-able in a DATA step using ARRAYs)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's a &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;maxim&lt;/A&gt; about this. Use the right tool for the job, which appears to be IML (or maybe a DATA step)&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 13:02:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-proc-iml-be-converted-into-an-sql-format/m-p/578048#M163891</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-31T13:02:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can proc iml be converted into an sql format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-proc-iml-be-converted-into-an-sql-format/m-p/578116#M163916</link>
      <description>It's doable but painful and long. SQL doesn't have the concept of arrays/columns so anything that loops across multiple columns will have to instead explicitly list out all the columns or you'd have to change your data structure to accomplish this. It's possible but not easy.</description>
      <pubDate>Wed, 31 Jul 2019 15:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-proc-iml-be-converted-into-an-sql-format/m-p/578116#M163916</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-31T15:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Can proc iml be converted into an sql format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-proc-iml-be-converted-into-an-sql-format/m-p/578119#M163918</link>
      <description>&lt;P&gt;What did you try?&lt;/P&gt;
&lt;P&gt;First thing is to convert your "matrix" into a proper dataset. If you have a 2 dimensional matrix with R rows and C cols you should store that as a dataset with R times C observations.&amp;nbsp; One variable has the row index, one has the column index and the third has the value.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
price = 
{10 20 30
,40 50 60
};
print price;
quit;
 
data price_table;
  row+1;
  do col=1 to 3 ;
    input price @;
    output;
  end;
cards;
10 20 30
40 50 60
;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;            price

       10        20        30
       40        50        60
&amp;#12;

Obs    row    col    price

 1      1      1       10
 2      1      2       20
 3      1      3       30
 4      2      1       40
 5      2      2       50
 6      2      3       60
&lt;/PRE&gt;
&lt;P&gt;Similarly a 3 dimensional array becomes a dataset with 4 variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jul 2019 15:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-proc-iml-be-converted-into-an-sql-format/m-p/578119#M163918</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-31T15:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Can proc iml be converted into an sql format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-proc-iml-be-converted-into-an-sql-format/m-p/578360#M164021</link>
      <description>&lt;P&gt;IML is not right tool for your purpose .&lt;/P&gt;
&lt;P&gt;Try Data Step .&lt;/P&gt;
&lt;P&gt;And post an example include INPUT and OUTPUT .&lt;/P&gt;
&lt;P&gt;Somebody would give you right data step code .&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 12:23:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-proc-iml-be-converted-into-an-sql-format/m-p/578360#M164021</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-08-01T12:23:04Z</dc:date>
    </item>
  </channel>
</rss>

