<?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: IF-THEN statement is SAS IML when there are zeros in matrix in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IF-THEN-statement-is-SAS-IML-when-there-are-zeros-in-matrix/m-p/495803#M4370</link>
    <description>&lt;P&gt;There is no error but the results are incorrect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what I want is if it is a non-zero value perform the calculation as per the formula and if it is zero go to the choose condition. But since&amp;nbsp; if-then statement returns false because some values in matrix are zero then it never performs the calculation and goes to choose condition directly.&lt;/P&gt;</description>
    <pubDate>Fri, 14 Sep 2018 18:41:05 GMT</pubDate>
    <dc:creator>pari2189</dc:creator>
    <dc:date>2018-09-14T18:41:05Z</dc:date>
    <item>
      <title>IF-THEN statement is SAS IML when there are zeros in matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IF-THEN-statement-is-SAS-IML-when-there-are-zeros-in-matrix/m-p/495772#M4367</link>
      <description>&lt;P&gt;I'm trying to perform logical operation through if-then statement but since my matrix has some value sas zero it fails to perform the operation correctly&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Start M_1(y);
p=13;
outarray_M=j(nrow(y),ncol(y),.);
outarray_01=j(nrow(y),ncol(y),.);
do i=14 to (nrow(y)-1);
idx= max(2,i-p+1):i;
unit= mad(y[idx,],"nmad");
outarray_M[i,]=unit;
if all(outarray_M[i,] ^= 0) then outarray_01[i+1,] = abs((y[i+1,]-median(y[idx,])))/mad(y[idx,],"nmad");
else outarray_01[i+1,]= choose(y[i+1,] =0, 0, 9999);
end;
return(outarray_01);
finish;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Sep 2018 17:15:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IF-THEN-statement-is-SAS-IML-when-there-are-zeros-in-matrix/m-p/495772#M4367</guid>
      <dc:creator>pari2189</dc:creator>
      <dc:date>2018-09-14T17:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: IF-THEN statement is SAS IML when there are zeros in matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IF-THEN-statement-is-SAS-IML-when-there-are-zeros-in-matrix/m-p/495779#M4368</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223948"&gt;@pari2189&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm trying to perform logical operation through if-then statement but since my matrix has some value sas zero it fails to perform the operation correctly&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;&lt;P&gt;Can you show us the SASLOG that contains the error?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 17:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IF-THEN-statement-is-SAS-IML-when-there-are-zeros-in-matrix/m-p/495779#M4368</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-09-14T17:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: IF-THEN statement is SAS IML when there are zeros in matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IF-THEN-statement-is-SAS-IML-when-there-are-zeros-in-matrix/m-p/495785#M4369</link>
      <description>&lt;P&gt;If&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token operator"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;mad&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;y&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;idx&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;"nmad"&lt;SPAN class="token punctuation"&gt;) returns 0&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then you have a division by 0 which is double-plus-ungood.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 17:58:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IF-THEN-statement-is-SAS-IML-when-there-are-zeros-in-matrix/m-p/495785#M4369</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-09-14T17:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: IF-THEN statement is SAS IML when there are zeros in matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IF-THEN-statement-is-SAS-IML-when-there-are-zeros-in-matrix/m-p/495803#M4370</link>
      <description>&lt;P&gt;There is no error but the results are incorrect.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what I want is if it is a non-zero value perform the calculation as per the formula and if it is zero go to the choose condition. But since&amp;nbsp; if-then statement returns false because some values in matrix are zero then it never performs the calculation and goes to choose condition directly.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 18:41:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IF-THEN-statement-is-SAS-IML-when-there-are-zeros-in-matrix/m-p/495803#M4370</guid>
      <dc:creator>pari2189</dc:creator>
      <dc:date>2018-09-14T18:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: IF-THEN statement is SAS IML when there are zeros in matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IF-THEN-statement-is-SAS-IML-when-there-are-zeros-in-matrix/m-p/495812#M4371</link>
      <description>&lt;P&gt;I think ballardw&amp;nbsp;mailed it: The MAD function will return 0 when more than half of the values are the same value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, I'd like to point out that the outarray_M matrix&amp;nbsp;is not necessary in your code. Hopefully, that code is left over from a more complicated example (thanks&amp;nbsp;for supplying a short module for us to view!). If not, you can use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if unit ^= 0 then...&lt;/P&gt;</description>
      <pubDate>Fri, 14 Sep 2018 19:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/IF-THEN-statement-is-SAS-IML-when-there-are-zeros-in-matrix/m-p/495812#M4371</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-09-14T19:38:49Z</dc:date>
    </item>
  </channel>
</rss>

