<?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: Replace missing values with 0 in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230758#M2413</link>
    <description>&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2015/01/20/elements-satisfy-logical-expression.html" target="_self"&gt;use the LOC function to find the entries that are missing&lt;/A&gt;. Then use assignment to replace those values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;idx = loc( G = . );
G[ idx ] = 0;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Oct 2015 14:46:31 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2015-10-20T14:46:31Z</dc:date>
    <item>
      <title>Replace missing values with 0</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230751#M2412</link>
      <description>&lt;P&gt;I have a matrix &lt;EM&gt;G&amp;nbsp;&lt;/EM&gt;that contains 2 missing values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;G&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0.0909091&lt;/TD&gt;&lt;TD&gt;0.2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0.6666667&lt;/TD&gt;&lt;TD&gt;0.2857143&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0.1428571&lt;/TD&gt;&lt;TD&gt;0.2857143&l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explanations for the REPLACE function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the logic in SAS/IML to replace those two missing values with 0?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Oct 2015 14:25:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230751#M2412</guid>
      <dc:creator>xtc283x</dc:creator>
      <dc:date>2015-10-20T14:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing values with 0</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230758#M2413</link>
      <description>&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2015/01/20/elements-satisfy-logical-expression.html" target="_self"&gt;use the LOC function to find the entries that are missing&lt;/A&gt;. Then use assignment to replace those values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;idx = loc( G = . );
G[ idx ] = 0;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Oct 2015 14:46:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230758#M2413</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-10-20T14:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing values with 0</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230901#M2418</link>
      <description>&lt;P&gt;Thank you. Using &lt;EM&gt;LOC()&lt;/EM&gt; and &lt;EM&gt;idx()&lt;/EM&gt; worked. Using the same matrix &lt;EM&gt;G&lt;/EM&gt;, I'm getting a new error in applying it to the norm() module. Here's the line of code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; GFrob = norm(G, "Frobenius");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the error is "ERROR: Invocation of unresolved module NORM."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on a post in The Do Loop, this code should work! &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2014/04/07/vector-and-matrix-norms-in-sas.html" target="_blank"&gt;http://blogs.sas.com/content/iml/2014/04/07/vector-and-matrix-norms-in-sas.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 12:23:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230901#M2418</guid>
      <dc:creator>xtc283x</dc:creator>
      <dc:date>2015-10-21T12:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing values with 0</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230905#M2420</link>
      <description>&lt;P&gt;The first sentence of the blog says that you need SAS/IML 12.1, which was shipped in August 2012 as part of SAS 9.3m2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you get when you run the following statement?&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: rgb(0, 0, 255);"&gt;%put&lt;/SPAN&gt; SYSVLONG = &lt;SPAN style="color: rgb(0, 0, 255); font-weight: bold;"&gt;&amp;amp;SYSVLONG&lt;/SPAN&gt;;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 12:29:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230905#M2420</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-10-21T12:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing values with 0</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230909#M2421</link>
      <description>&lt;P&gt;SYSVLONG = 9.03.01M1P&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 12:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230909#M2421</guid>
      <dc:creator>xtc283x</dc:creator>
      <dc:date>2015-10-21T12:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing values with 0</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230921#M2424</link>
      <description>&lt;P&gt;That answers the question: You are running SAS 9.3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now what to do about it? There have been &lt;A href="http://blogs.sas.com/content/iml/2013/08/02/how-old-is-your-version-of-sas-release-dates-for-sas-software.html" target="_self"&gt;five releases of SAS since SAS 9.3&lt;/A&gt;, so you might consider upgrading.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the meantime, most norms are trivial to program. Here's a SAS/IML function that computes the Frobenius, L1, L2, and "L infinity" norms for matrices:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start matnorm(x, method);
   s = substr(upcase(method), 1, 4);
   isValid = (s="FROB" | s="L1" | s="LINF" | s="L2");
   if ^isValid then return(.);
   
   if (s="FROB") then do;
      return( sqrt(x[##]) );
   end;
   else if (s="L1") then do;
      return( max(x[+,]) );
   end;
   else if (s="LINF") then do;
      return( max(x[,+]) );
   end;
   else if (s="L2") then do;
      v = eigval(x`*x);
      return( sqrt(v[1]) );
   end;
finish;


/* Test the module on the doc example */

x={1 2, 3 4};
mn1 = matnorm(x, "L1");
mnF = matnorm(x, "Frobenius");
mnInf = matnorm(x, "LInf");
print mn1 mnF mnInf;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Oct 2015 12:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230921#M2424</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2015-10-21T12:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Replace missing values with 0</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230939#M2427</link>
      <description>&lt;P&gt;That worked. Thank you again.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Oct 2015 13:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Replace-missing-values-with-0/m-p/230939#M2427</guid>
      <dc:creator>xtc283x</dc:creator>
      <dc:date>2015-10-21T13:36:35Z</dc:date>
    </item>
  </channel>
</rss>

