<?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: Proc IML missing values question in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70866#M438</link>
    <description>Rick-&lt;BR /&gt;
&lt;BR /&gt;
Suppose now that I had a matrix instead of a vector, let say A={1 2; 3 4} and B={1 . 3; . 1 2}. Can I still use the loc function to find the indices of the missing values for the B matrix?&lt;BR /&gt;
&lt;BR /&gt;
So I would need to get B1={1 3;1 2}, then do A*B1 and then augment the B1 matrix with corresponding missing values.

Here is what I thought of. I assume there is a faster way?&lt;BR /&gt;
&lt;BR /&gt;
proc iml;&lt;BR /&gt;
a={1 2,3 4};&lt;BR /&gt;
b={1 . 3,. 1 2};&lt;BR /&gt;
nm=loc(b^=.);&lt;BR /&gt;
b1=shape(b[loc(b^=.)],nrow(a),ncol(a));&lt;BR /&gt;
y=shape(a*b1,ncol(nm));&lt;BR /&gt;
y1=repeat(.,nrow(b)*ncol(b));&lt;BR /&gt;
y1[nm]=y;&lt;BR /&gt;
y1=shape(y1,nrow(b),ncol(b));&lt;BR /&gt;
print a,b,nm,b1,y,y1;&lt;BR /&gt;
quit;&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: trekvana</description>
    <pubDate>Thu, 09 Sep 2010 16:53:58 GMT</pubDate>
    <dc:creator>trekvana</dc:creator>
    <dc:date>2010-09-09T16:53:58Z</dc:date>
    <item>
      <title>Proc IML missing values question</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70864#M436</link>
      <description>Hello all,&lt;BR /&gt;
&lt;BR /&gt;
Here is my basic scenario.&lt;BR /&gt;
&lt;BR /&gt;
Lets say I read in a 2x2 matrix from a SAS data set say, A=[1,2 ; 3,4] and I have to multiply it into a 3 dimensional column vector with a missing value say, x=(4, . ,6)'.&lt;BR /&gt;
&lt;BR /&gt;
Now I know that proc IML doesnt like missing values so I have to first remove the missing value from x then I can do A*x and now I get a 2x1 column vector. &lt;BR /&gt;
&lt;BR /&gt;
What I want to do now is reinsert the missing value into its original position as with the x vector. So in our case y=A*x=[16,36] and I want y to become y=[16, . , 36].&lt;BR /&gt;
&lt;BR /&gt;
This was just a basic example. My x vectors may have multiple missing values at different indices. My A matrix will always be the dimension of the truncated x vector so I dont need to worry about my A matrix. All I need to do is truncate the missing values from my x vector, do the matrix multiplication, and then add the missing value character (.) in y where it initially was on x.&lt;BR /&gt;
&lt;BR /&gt;
I am not that proficient in coding yet so any complete or semi-complete code would help.&lt;BR /&gt;
&lt;BR /&gt;
George</description>
      <pubDate>Wed, 08 Sep 2010 22:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70864#M436</guid>
      <dc:creator>trekvana</dc:creator>
      <dc:date>2010-09-08T22:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML missing values question</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70865#M437</link>
      <description>I can tell that you have a MATLAB background. Welcome to IML!&lt;BR /&gt;
&lt;BR /&gt;
In IML, use a space to separate columns and use a comma to indicate a new row. So your data might look like this:&lt;BR /&gt;
&lt;BR /&gt;
A = {1 2 3, 4 5 6, 7 8 9};&lt;BR /&gt;
x = {1, ., ., 4, ., 6, .};&lt;BR /&gt;
&lt;BR /&gt;
The function you want is the LOC function, which can find the indices of x that are missing (or nonmissing):&lt;BR /&gt;
&lt;BR /&gt;
NMidx = loc(x ^= .); /** non-missing index **/&lt;BR /&gt;
v = x[NMidx];        /** subset to form nonmissing values of x **/&lt;BR /&gt;
&lt;BR /&gt;
y = repeat(., nrow(x)); /** fill answer vector with missing values **/&lt;BR /&gt;
y[NMidx] = A*v;         /** put answer in correct locations **/&lt;BR /&gt;
print y;</description>
      <pubDate>Thu, 09 Sep 2010 10:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70865#M437</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2010-09-09T10:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML missing values question</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70866#M438</link>
      <description>Rick-&lt;BR /&gt;
&lt;BR /&gt;
Suppose now that I had a matrix instead of a vector, let say A={1 2; 3 4} and B={1 . 3; . 1 2}. Can I still use the loc function to find the indices of the missing values for the B matrix?&lt;BR /&gt;
&lt;BR /&gt;
So I would need to get B1={1 3;1 2}, then do A*B1 and then augment the B1 matrix with corresponding missing values.

Here is what I thought of. I assume there is a faster way?&lt;BR /&gt;
&lt;BR /&gt;
proc iml;&lt;BR /&gt;
a={1 2,3 4};&lt;BR /&gt;
b={1 . 3,. 1 2};&lt;BR /&gt;
nm=loc(b^=.);&lt;BR /&gt;
b1=shape(b[loc(b^=.)],nrow(a),ncol(a));&lt;BR /&gt;
y=shape(a*b1,ncol(nm));&lt;BR /&gt;
y1=repeat(.,nrow(b)*ncol(b));&lt;BR /&gt;
y1[nm]=y;&lt;BR /&gt;
y1=shape(y1,nrow(b),ncol(b));&lt;BR /&gt;
print a,b,nm,b1,y,y1;&lt;BR /&gt;
quit;&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: trekvana</description>
      <pubDate>Thu, 09 Sep 2010 16:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70866#M438</guid>
      <dc:creator>trekvana</dc:creator>
      <dc:date>2010-09-09T16:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML missing values question</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70867#M439</link>
      <description>That's not bad. I think I'd shape y1 to be a matrix and get rid of y:&lt;BR /&gt;
&lt;BR /&gt;
nm=loc(b^=.);&lt;BR /&gt;
b1=shape(b[loc(b^=.)],nrow(a),ncol(a));&lt;BR /&gt;
y1=repeat(.,nrow(b),ncol(b));&lt;BR /&gt;
y1[nm]=a*b1;&lt;BR /&gt;
print nm,b1,y1;&lt;BR /&gt;
&lt;BR /&gt;
Can anyone else come up with a better technique?&lt;BR /&gt;
&lt;BR /&gt;
Incidentally, I discuss handling missing values in Ch. 3 and Ch. 11 of my forthcoming book on IML. This problem you've posed is a variation of the problems and solutions in those chapters.</description>
      <pubDate>Thu, 09 Sep 2010 18:14:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70867#M439</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2010-09-09T18:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML missing values question</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70868#M440</link>
      <description>Rick-&lt;BR /&gt;
&lt;BR /&gt;
when is your book slated to be released? Do you have a title for it already (or at least something on how to find it when it comes out). I look forward to it.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the help&lt;BR /&gt;
&lt;BR /&gt;
George</description>
      <pubDate>Fri, 10 Sep 2010 00:57:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70868#M440</guid>
      <dc:creator>trekvana</dc:creator>
      <dc:date>2010-09-10T00:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML missing values question</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70869#M441</link>
      <description>Rick-&lt;BR /&gt;
&lt;BR /&gt;
when is your book slated to be released? Do you have a title for it already (or at least something on how to find it when it comes out). I look forward to it.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the help.&lt;BR /&gt;
&lt;BR /&gt;
George&lt;BR /&gt;
&lt;BR /&gt;
EDIT: A quick search and I believe I found it&lt;BR /&gt;
&lt;A href="http://support.sas.com/publishing/authors/wicklin.html" target="_blank"&gt;http://support.sas.com/publishing/authors/wicklin.html&lt;/A&gt;</description>
      <pubDate>Fri, 10 Sep 2010 00:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70869#M441</guid>
      <dc:creator>trekvana</dc:creator>
      <dc:date>2010-09-10T00:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc IML missing values question</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70870#M442</link>
      <description>That's it. I was told the book would be available "late October to early November, 2010."</description>
      <pubDate>Fri, 10 Sep 2010 12:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Proc-IML-missing-values-question/m-p/70870#M442</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2010-09-10T12:33:51Z</dc:date>
    </item>
  </channel>
</rss>

