<?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: Nesting and the IML equivalent of FOR and WHILE loops in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Nesting-and-the-IML-equivalent-of-FOR-and-WHILE-loops/m-p/242727#M2535</link>
    <description>&lt;P&gt;If this&amp;nbsp;issue has been resolved, please mark the question as 'answered.'&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jan 2016 15:44:06 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2016-01-11T15:44:06Z</dc:date>
    <item>
      <title>Nesting and the IML equivalent of FOR and WHILE loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Nesting-and-the-IML-equivalent-of-FOR-and-WHILE-loops/m-p/236219#M2491</link>
      <description>&lt;P&gt;I need to create a square matrix (let's call it SQUARE_M) where the rows represent a certain variable (let's call it Var_A), the columns, another variable (Var_B), and their intersection, a certain value resulting from a combination of the two variables. Each variable can have &lt;EM&gt;m&lt;/EM&gt; values, so my matrix needs to have &lt;EM&gt;m&lt;/EM&gt; rows and &lt;EM&gt;m&lt;/EM&gt; columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;Currently, I have a matrix (let's call it CURRENT) with &lt;/SPAN&gt;&lt;EM&gt;m**2&lt;/EM&gt;&lt;SPAN style="line-height: 20px;"&gt; rows and 3 columns (Var_A, Var_B, and, for each combination of the two, the resulting value in Var_C). I intend to get the matrix into a square shape (as described above) as follows: &amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&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;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;1. Sort current matrix by Var_A, then by Var_B; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt; 2. Create a square matrix, populated only with 1's so far: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;SQUARE_M=j (m, m+1, 1); *The extra column is for holding the value of VAR_A from the CURRENT matrix;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I'm not sure of, though, is the exact IML syntax&amp;nbsp;for the two steps below:&lt;/P&gt;
&lt;P&gt;3. &amp;nbsp;Loop through VAR_A in CURRENT&amp;nbsp;and write each &lt;EM&gt;unique&lt;/EM&gt;&amp;nbsp;value into column 1 in SQUARE_M, in the order in which they are found.&lt;/P&gt;
&lt;OL start="4"&gt;
&lt;LI&gt;For each unique value in VAR_A, write the corresponding values in VAR_C into the relevant row in SQUARE_M, roughly like this:&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;m = [number of rows and columns in my data];&lt;/P&gt;
&lt;P&gt;r_new_row = 1; * row in new matrix;&lt;/P&gt;
&lt;P&gt;c_new_column = 1; * column in new&amp;nbsp;matrix;&lt;/P&gt;
&lt;P&gt;while c_new_column &amp;lt;= m:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (&lt;EM&gt;write the figure from CURRENT to [m_square_row, m_square_column]&lt;/EM&gt;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c_square_column +=1;&lt;/P&gt;
&lt;P&gt;r_square_row +=1;&lt;/P&gt;
&lt;P&gt;quit; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, am I right that, when counting rows or columns, IML begins with 1 rather than 0?&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2015 16:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Nesting-and-the-IML-equivalent-of-FOR-and-WHILE-loops/m-p/236219#M2491</guid>
      <dc:creator>dvtarasov</dc:creator>
      <dc:date>2015-11-24T16:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Nesting and the IML equivalent of FOR and WHILE loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Nesting-and-the-IML-equivalent-of-FOR-and-WHILE-loops/m-p/236389#M2492</link>
      <description>&lt;P&gt;Have a look at the FULL() function, as this might do everything that you want.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  x={
4.1 1 2,
5.3 1 5,
3.7 3 3};

  y=full(x);

  print x, y;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regarding the last question, you are correct that&amp;nbsp;IML matrices have no row or column zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2015 13:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Nesting-and-the-IML-equivalent-of-FOR-and-WHILE-loops/m-p/236389#M2492</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2015-11-25T13:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Nesting and the IML equivalent of FOR and WHILE loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Nesting-and-the-IML-equivalent-of-FOR-and-WHILE-loops/m-p/236450#M2493</link>
      <description>&lt;P&gt;Ian's suggestion will work as long as the values of VAR_A and VAR_B are 1 through m.&amp;nbsp; From your pseudo-code, this appears to be the case.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2015 16:50:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Nesting-and-the-IML-equivalent-of-FOR-and-WHILE-loops/m-p/236450#M2493</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-11-25T16:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Nesting and the IML equivalent of FOR and WHILE loops</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Nesting-and-the-IML-equivalent-of-FOR-and-WHILE-loops/m-p/242727#M2535</link>
      <description>&lt;P&gt;If this&amp;nbsp;issue has been resolved, please mark the question as 'answered.'&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2016 15:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Nesting-and-the-IML-equivalent-of-FOR-and-WHILE-loops/m-p/242727#M2535</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-01-11T15:44:06Z</dc:date>
    </item>
  </channel>
</rss>

