<?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: Matrices in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146116#M1246</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Inverting a singular matrix causes an error so the INV function needs to be moved inside the 'if'.&amp;nbsp; To avoid further errors it is necessary to always return something from the function module.&amp;nbsp; I usually use syntax like return(.) or return(0) when an error occurs.&amp;nbsp; Then the calling program can test for these return codes and know that an error has occurred.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 May 2014 08:51:51 GMT</pubDate>
    <dc:creator>IanWakeling</dc:creator>
    <dc:date>2014-05-06T08:51:51Z</dc:date>
    <item>
      <title>Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146115#M1245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am suppose only be able to put in 2x2 matrices and find the determinate if the matrices is a 2x2 if it is a 1x1 or a 3x3 I am suppose to print an error and if it is singular i am suppose to print another error.&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc IML;&lt;/P&gt;&lt;P&gt;a = {1 2, 3 4};&lt;/P&gt;&lt;P&gt;b = {1 1, 1 1}; &lt;/P&gt;&lt;P&gt;c = {1 2 3, 4 5 6, 7 8 9};&lt;/P&gt;&lt;P&gt;d = {5};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start invers(a);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; nr = nrow(a);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; nc = ncol(a) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if nr=2 &amp;amp; nc=2 then do;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = det(a);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; b = INV(a);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if i ^= 0 then return(b);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if i = 0 then print("Singular");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end; else print("error");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;finish; &lt;/P&gt;&lt;P&gt;w = invers(a);&lt;/P&gt;&lt;P&gt;x = invers(b);&lt;/P&gt;&lt;P&gt;y = invers(c);&lt;/P&gt;&lt;P&gt;z = invers(d); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print w, x, y, z;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 00:41:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146115#M1245</guid>
      <dc:creator>arbongard</dc:creator>
      <dc:date>2014-05-06T00:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146116#M1246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Inverting a singular matrix causes an error so the INV function needs to be moved inside the 'if'.&amp;nbsp; To avoid further errors it is necessary to always return something from the function module.&amp;nbsp; I usually use syntax like return(.) or return(0) when an error occurs.&amp;nbsp; Then the calling program can test for these return codes and know that an error has occurred.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 08:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146116#M1246</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2014-05-06T08:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146117#M1247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;inside what if statement?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 15:43:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146117#M1247</guid>
      <dc:creator>arbongard</dc:creator>
      <dc:date>2014-05-06T15:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146118#M1248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Don't attempt to invert the matrix unless it has passed the&amp;nbsp; i^=0&amp;nbsp; test.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 16:19:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146118#M1248</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2014-05-06T16:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146119#M1249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;so would this work?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if i ^=0 then return (a**(-1)) &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 May 2014 16:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146119#M1249</guid>
      <dc:creator>arbongard</dc:creator>
      <dc:date>2014-05-06T16:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: Matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146120#M1250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes that should work, or return(inv(a)).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 May 2014 07:43:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Matrices/m-p/146120#M1250</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2014-05-07T07:43:00Z</dc:date>
    </item>
  </channel>
</rss>

