<?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: referencing matrices in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149821#M1353</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rick,&lt;/P&gt;&lt;P&gt;Thanks so much for responding.&amp;nbsp; Actually I already learned the unique_by statement trick from one of your earlier posts and it is amazing!&amp;nbsp; Believe it or not, it's the actual indexing statement that is tripping me up.&amp;nbsp; I already have the ESTS matrix split into submatrices by sample no.&amp;nbsp; I just can't get the correct observations pulled from it.&amp;nbsp; I'll show you some of the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read all var{sample lo hi} into worklim;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;use thirdsorted;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;read all var{sample mc3estimates} into workests;&lt;/P&gt;&lt;P&gt;unique_rows400=uniqueby(workests,1,1:nrow(workests));&lt;/P&gt;&lt;P&gt;do k=1 to nrow(unique_rows400);&amp;nbsp; &lt;/P&gt;&lt;P&gt;if k=nrow(unique_rows400) then index=unique_rows400&lt;K&gt;:nrow(workests);&amp;nbsp; &lt;/K&gt;&lt;/P&gt;&lt;P&gt;else index=unique_rows400&lt;K&gt;:unique_rows400[k+1]-1;&amp;nbsp;&amp;nbsp; &lt;/K&gt;&lt;/P&gt;&lt;P&gt;submat400=workests[index,];&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;print submat400;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;I am struggling with something like------&lt;/P&gt;&lt;P&gt;confint=j(nrow(worklim),2,0);&lt;/P&gt;&lt;P&gt;confint[i,1:2]=workests[worklim&lt;I&gt;,worklim[i,2]];&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help Rick!&lt;/P&gt;&lt;P&gt;Rachel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 18 Sep 2014 12:05:53 GMT</pubDate>
    <dc:creator>rachgoo</dc:creator>
    <dc:date>2014-09-18T12:05:53Z</dc:date>
    <item>
      <title>referencing matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149819#M1351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am in great need of help with this:&amp;nbsp; &lt;/P&gt;&lt;P&gt;this is the matrix that I wish to fill &lt;/P&gt;&lt;P&gt;CI=&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="71.39999997615814" style="border: 1px solid #000000; width: 141.399999976158px; height: 22.3999999761581px;" width="139.39999997615814"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;sample&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;lower&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;upper&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the contents I need to fill it with are in a matrix like this:&lt;/P&gt;&lt;P&gt;ESTS=&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="167.39999997615814" style="border: 1px solid #000000; width: 129.399999976158px; height: 108.399999976158px;" width="127.39999997615814"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;sample&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;estimate&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;&lt;P&gt;1&lt;/P&gt;&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.01&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.75&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;the next matrix tells me which rows I need to pull from ESTS into the matrix at the very top (CI):&lt;/P&gt;&lt;P&gt;LIMS=&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="71.39999997615814" jive-data-cell="{&amp;quot;color&amp;quot;:&amp;quot;#000000&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;left&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;}" jive-data-header="{&amp;quot;color&amp;quot;:&amp;quot;#FFFFFF&amp;quot;,&amp;quot;backgroundColor&amp;quot;:&amp;quot;#6690BC&amp;quot;,&amp;quot;textAlign&amp;quot;:&amp;quot;center&amp;quot;,&amp;quot;padding&amp;quot;:&amp;quot;2&amp;quot;,&amp;quot;fontFamily&amp;quot;:&amp;quot;arial,helvetica,sans-serif&amp;quot;}" style="border: 1px solid rgb(0, 0, 0); width: 553.399999976158px; height: 8.39999997615814px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;sample&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;lim1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;lim2&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;what I wish to end up with is this:&lt;/P&gt;&lt;P&gt;CI=&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="71.39999997615814" style="border: 1px solid rgb(0, 0, 0); width: 490.399999976158px; height: 1.39999997615814px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;sample&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;lower&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;upper&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;1&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.3&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;2&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.01&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;.9&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I can not for the life of me figure this out.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I'll appreciate any help I get on this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Sep 2014 23:55:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149819#M1351</guid>
      <dc:creator>rachgoo</dc:creator>
      <dc:date>2014-09-17T23:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: referencing matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149820#M1352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the &lt;A href="http://blogs.sas.com/content/iml/2011/11/01/the-unique-loc-trick-a-real-treat/"&gt;UNIQU-LOC trick&lt;/A&gt; to extract the i_th sample. Within each sample, use the LIMS matrix to determine the rows and use indexing to pull out the correct numbers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 09:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149820#M1352</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-09-18T09:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: referencing matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149821#M1353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rick,&lt;/P&gt;&lt;P&gt;Thanks so much for responding.&amp;nbsp; Actually I already learned the unique_by statement trick from one of your earlier posts and it is amazing!&amp;nbsp; Believe it or not, it's the actual indexing statement that is tripping me up.&amp;nbsp; I already have the ESTS matrix split into submatrices by sample no.&amp;nbsp; I just can't get the correct observations pulled from it.&amp;nbsp; I'll show you some of the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read all var{sample lo hi} into worklim;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;use thirdsorted;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;read all var{sample mc3estimates} into workests;&lt;/P&gt;&lt;P&gt;unique_rows400=uniqueby(workests,1,1:nrow(workests));&lt;/P&gt;&lt;P&gt;do k=1 to nrow(unique_rows400);&amp;nbsp; &lt;/P&gt;&lt;P&gt;if k=nrow(unique_rows400) then index=unique_rows400&lt;K&gt;:nrow(workests);&amp;nbsp; &lt;/K&gt;&lt;/P&gt;&lt;P&gt;else index=unique_rows400&lt;K&gt;:unique_rows400[k+1]-1;&amp;nbsp;&amp;nbsp; &lt;/K&gt;&lt;/P&gt;&lt;P&gt;submat400=workests[index,];&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;print submat400;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;I am struggling with something like------&lt;/P&gt;&lt;P&gt;confint=j(nrow(worklim),2,0);&lt;/P&gt;&lt;P&gt;confint[i,1:2]=workests[worklim&lt;I&gt;,worklim[i,2]];&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help Rick!&lt;/P&gt;&lt;P&gt;Rachel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 12:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149821#M1353</guid>
      <dc:creator>rachgoo</dc:creator>
      <dc:date>2014-09-18T12:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: referencing matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149822#M1354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You almost got it. See if the following helps.&amp;nbsp; I wrote out each step on a separate line in case you want to insert PRINT statements inside the DO loop to see how it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;worklim = {&lt;BR /&gt;1 1 3 ,&lt;BR /&gt;2 1 2 &lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;workests = {&lt;BR /&gt;1 .3 ,&lt;BR /&gt;1 .2 ,&lt;BR /&gt;1 .4 ,&lt;BR /&gt;2 .01 ,&lt;BR /&gt;2 .9 ,&lt;BR /&gt;2 .75 &lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;confint=j(nrow(worklim),2,0);&lt;BR /&gt;unique_rows=uniqueby(workests,1);&lt;BR /&gt;unique_rows = unique_rows // (nrow(workests)+1); /* append final row */&lt;BR /&gt;do k=1 to nrow(unique_rows);&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; index=unique_rows&lt;K&gt;:unique_rows[k+1]-1;&amp;nbsp;&amp;nbsp; /* rows of workests */&lt;BR /&gt;&amp;nbsp;&amp;nbsp; submat=workests[index,2];&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* extract the values */&lt;BR /&gt;&amp;nbsp;&amp;nbsp; rows = worklim[k,2:3];&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* rows of submat */&lt;BR /&gt;&amp;nbsp;&amp;nbsp; confint[k,]=rowvec( submat[rows] );&lt;BR /&gt;end;&lt;BR /&gt;print confint;&lt;/K&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 14:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149822#M1354</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-09-18T14:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: referencing matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149823#M1355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rick, &lt;/P&gt;&lt;P&gt;Thank you from the ends of the earth and back!!!&amp;nbsp; That worked like a charm.&amp;nbsp; I put in print statements like you said so I could see the "magic" happen.&amp;nbsp; I did not realize that you have to append the last row in the unique_by matrix......I tried taking it off just for fun and it doesn't fill the last row.&amp;nbsp; So, I'm guessing it is there to make the do loop complete?&amp;nbsp; Thanks again.&lt;/P&gt;&lt;P&gt;Rachel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 15:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149823#M1355</guid>
      <dc:creator>rachgoo</dc:creator>
      <dc:date>2014-09-18T15:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: referencing matrices</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149824#M1356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You don't have to append the last row. It is a trick that I use to avoid having an IF-THEN/ELSE statement inside the DO loop (as in your original code).&amp;nbsp; It makes the code a little easier to read, and slightly more efficient, as explained in this blog post: &lt;A href="http://blogs.sas.com/content/iml/2012/02/13/avoid-unnecessary-if-then-statements-in-loops/" title="http://blogs.sas.com/content/iml/2012/02/13/avoid-unnecessary-if-then-statements-in-loops/"&gt; Avoid unnecessary IF-THEN statements in loops - The DO Loop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 18 Sep 2014 15:45:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/referencing-matrices/m-p/149824#M1356</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2014-09-18T15:45:10Z</dc:date>
    </item>
  </channel>
</rss>

