<?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: SAS IML error in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/770849#M5668</link>
    <description>&lt;P&gt;Thanks both for the explanation.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Sep 2021 11:07:22 GMT</pubDate>
    <dc:creator>Arick</dc:creator>
    <dc:date>2021-09-28T11:07:22Z</dc:date>
    <item>
      <title>SAS IML error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/769807#M5653</link>
      <description>&lt;P&gt;I am using SAS for Windows 9.4.&amp;nbsp;Below is the log for what I thought was simple SAS/IML code. But I cannot understand why I am receiving an error. Can anyone explain why and how to fix?&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; a1={1 2 3 4 0 0};&lt;BR /&gt;&amp;nbsp; &amp;nbsp; a2={1 1 1 1 1 1};&lt;BR /&gt;&amp;nbsp; &amp;nbsp; a3=j(1,6,0);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; a4=j(1,6,0);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; n_cols=ncol(a1);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; PRINT a1 a2 a3 a4 n_cols;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; do i=1 to n_cols;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if a1[i] ^= 0 then do;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; * Condition [1] *;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a3[i]=1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a4[i]=a2/a1; *Why is this line processed when Condition [1] not met *;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; else do;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a3[i]=9;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a4[i]=9;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; end;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;PRINT a3 a4;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The log file is attached.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 08:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/769807#M5653</guid>
      <dc:creator>Arick</dc:creator>
      <dc:date>2021-09-23T08:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/769870#M5654</link>
      <description>&lt;P&gt;Many of us cannot (or will not) download attachments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please include the log in your reply AND FORMAT IT PROPERLY by following these instructions: in the editor here at SAS Communities, click on the &amp;lt;/&amp;gt; icon and paste the log into the window that appears.&amp;nbsp;&lt;STRONG&gt;DO NOT SKIP THIS STEP&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 12:07:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/769870#M5654</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-09-23T12:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/769878#M5655</link>
      <description>&lt;P&gt;Why not post it at IML forum and calling out&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc iml;

    a1={1 2 3 4 0 0};
    a2={1 1 1 1 1 1};
    a3=j(1,6,0);
    a4=j(1,6,0);
    n_cols=ncol(a1);
    PRINT a1 a2 a3 a4 n_cols;
    do i=1 to n_cols;
    if a1[i] ^= 0 then do;        * Condition [1] *;
        a3[i]=1;
        a4[i]=&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;a2[i]/a1[i]&lt;/FONT&gt;&lt;/STRONG&gt;; *Why is this line processed when Condition [1] not met *;
    end;
    else do;
        a3[i]=9;
        a4[i]=9;
    end;
end;

PRINT a3 a4;

quit;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Sep 2021 12:19:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/769878#M5655</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-09-23T12:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/769888#M5656</link>
      <description>&lt;P&gt;As KSharp points out, the expression&amp;nbsp;&lt;BR /&gt;a4[i] = a2/a1;&lt;/P&gt;
&lt;P&gt;is incorrect for two reasons:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The expression on the right is a vector whose j_th component is a2[j]/a1[j].&amp;nbsp; You cannot assign the vector on the right to the scalar on the left. PROC IML reports "Matrices do not conform to the operation" to indicate that you are attempting an impossible operation because the sizes of the various objects do not make sense.&lt;/LI&gt;
&lt;LI&gt;Because the expression on the right is a vector, it attempts to divide EVERY element of a2 by the corresponding element of a1. When an element of a1 is 0, PROC IML reports the warning "Division by zero, result set to missing value."&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 23 Sep 2021 12:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/769888#M5656</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-09-23T12:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/769901#M5657</link>
      <description>&lt;P&gt;By the way, you don't need any loops for this computation. The following is a vectorized way to write this program:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
a1={1 2 3 4 0 0};
a2={1 1 1 1 1 1};
a3= choose(a1^=0, 1, 9);
a4=j(1,6,9);
idx = loc(a1^=0);
if ncol(idx)&amp;gt;0 then
   a4[idx] = a2[idx] / a1[idx];

PRINT a3 a4;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are not familiar with the CHOOSE function, you can &lt;A href="https://blogs.sas.com/content/iml/2011/08/15/complex-assignment-statements-choose-wisely.html" target="_self"&gt;read about the CHOOSE function here.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If you are not familiar with the LOC function, you can &lt;A href="https://blogs.sas.com/content/iml/2011/05/16/finding-data-that-satisfy-a-criterion.html" target="_self"&gt;read about the LOC function here.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 13:20:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/769901#M5657</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-09-23T13:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/770400#M5658</link>
      <description>&lt;P&gt;Is there anything else we can help with? If we have answered your questions, you can mark an answer and close the thread.&lt;/P&gt;</description>
      <pubDate>Sat, 25 Sep 2021 11:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/770400#M5658</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-09-25T11:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML error</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/770849#M5668</link>
      <description>&lt;P&gt;Thanks both for the explanation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Sep 2021 11:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-error/m-p/770849#M5668</guid>
      <dc:creator>Arick</dc:creator>
      <dc:date>2021-09-28T11:07:22Z</dc:date>
    </item>
  </channel>
</rss>

