<?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 IF/THEN/ELSE in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-IF-THEN-ELSE/m-p/325776#M3233</link>
    <description>&lt;P&gt;Could you provide an example?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get a boolean (0 or 1) matrix, just use a logical expression with a matrix:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
x = {1 2,
     1 3,
     2 4};
b = (x &amp;gt; 2);
print b;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IF-THEN/ELSE statement works on a scalar quantity. &amp;nbsp;The ANY function and ALL function can be used with the&amp;nbsp;IF-THEN statement to make logical decisions. &amp;nbsp;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if any(x) &amp;gt; 3 then print "Some element &amp;gt; 3";
else print "No element &amp;gt; 3";

if all(x) &amp;gt; 0 then print "All elements &amp;gt; 0";
else print "Some element &amp;lt;= 0";
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more information, see &lt;A href="http://blogs.sas.com/content/iml/2015/01/26/if-then-matrix.html" target="_self"&gt;"IF-THEN logic with matrix expressions."&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jan 2017 19:22:23 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2017-01-18T19:22:23Z</dc:date>
    <item>
      <title>SAS IML IF/THEN/ELSE</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-IF-THEN-ELSE/m-p/325772#M3232</link>
      <description>&lt;P&gt;How can we apply IF/THEN/ELSE statement to each element in a n*m matrix so that the result is also a n*m matrix of TRUE/FALSE?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 19:07:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-IF-THEN-ELSE/m-p/325772#M3232</guid>
      <dc:creator>abbaskashif</dc:creator>
      <dc:date>2017-01-18T19:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML IF/THEN/ELSE</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-IF-THEN-ELSE/m-p/325776#M3233</link>
      <description>&lt;P&gt;Could you provide an example?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get a boolean (0 or 1) matrix, just use a logical expression with a matrix:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
x = {1 2,
     1 3,
     2 4};
b = (x &amp;gt; 2);
print b;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The IF-THEN/ELSE statement works on a scalar quantity. &amp;nbsp;The ANY function and ALL function can be used with the&amp;nbsp;IF-THEN statement to make logical decisions. &amp;nbsp;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if any(x) &amp;gt; 3 then print "Some element &amp;gt; 3";
else print "No element &amp;gt; 3";

if all(x) &amp;gt; 0 then print "All elements &amp;gt; 0";
else print "Some element &amp;lt;= 0";
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more information, see &lt;A href="http://blogs.sas.com/content/iml/2015/01/26/if-then-matrix.html" target="_self"&gt;"IF-THEN logic with matrix expressions."&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 19:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-IF-THEN-ELSE/m-p/325776#M3233</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-01-18T19:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML IF/THEN/ELSE</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-IF-THEN-ELSE/m-p/325804#M3234</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;Given a matrix x below, I would like to have a resultant matrix y having 1 for each element of x&amp;lt;0  else 0:
proc iml;&lt;BR /&gt;x = {1 2,&lt;BR /&gt; 1 -3,&lt;BR /&gt; 2 4};&lt;BR /&gt;&lt;BR /&gt;IF x&amp;lt;0 THEN y=1;&lt;BR /&gt;ELSE y=0;&lt;BR /&gt;print y;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="token punctuation"&gt;Resultant matrix should be:&lt;BR /&gt;y=  {0 0,&lt;BR /&gt;     0 1,&lt;BR /&gt;     0 0}&lt;BR /&gt;The result however is a scalar y=0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 20:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-IF-THEN-ELSE/m-p/325804#M3234</guid>
      <dc:creator>abbaskashif</dc:creator>
      <dc:date>2017-01-18T20:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS IML IF/THEN/ELSE</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-IF-THEN-ELSE/m-p/325806#M3235</link>
      <description>&lt;P&gt;&amp;nbsp;As I explained in my previous response, don't use the IF-THEN statement. Just create the binary matrix:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
x = {1  2,
     1 -3,
     2  4};

y = (x&amp;lt;0);
print y;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 20:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/SAS-IML-IF-THEN-ELSE/m-p/325806#M3235</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2017-01-18T20:53:42Z</dc:date>
    </item>
  </channel>
</rss>

