<?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: Using Proc IML to analyze data rowwise in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Proc-IML-to-analyze-data-rowwise/m-p/109823#M828</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot, will look into your considerations carefully!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Apr 2013 15:02:16 GMT</pubDate>
    <dc:creator>mamzolo</dc:creator>
    <dc:date>2013-04-16T15:02:16Z</dc:date>
    <item>
      <title>Using Proc IML to analyze data rowwise</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Proc-IML-to-analyze-data-rowwise/m-p/109819#M824</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a macro which orders means (ascending/descending) using PROC IML. But I want to do this for each simulation number. Is it possible to do this, given that in the usual data step I can use the 'BY statement'?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is it this SAS macro and a small dataset is attached (with variables sim, meanX1--meanX5). This macro is support to arrange the means in a descending order per 'sim'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro mean_will(numbersim=, J1=, J2=, J3=, J4=, J5=, df=);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;start MLE(x,n);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; k=ncol(x);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m=j(1,k,.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a=j(1,k,.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c=j(1,k,.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to k;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do u=1 to i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do v=i to k;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a&lt;V&gt;=sum(x[u:v]#n[u:v])/sum(n[u:v]);&lt;/V&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c&lt;U&gt;=max(a);&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a=j(1,k,.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m&lt;I&gt;=min(c);&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c=j(1,k,.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return(m);&lt;/P&gt;&lt;P&gt;finish;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use meanXit;&lt;/P&gt;&lt;P&gt;read all into Xmat;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; x=Xmat[,2]||Xmat[,3]||Xmat[,4]||Xmat[,5]||Xmat[,6];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; n={&amp;amp;J1 &amp;amp;J2 &amp;amp;J3 &amp;amp;J4 &amp;amp;J5};&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; m=MLE(x,n);&lt;/P&gt;&lt;P&gt; create meanX from m;&lt;/P&gt;&lt;P&gt; append from m;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mean_will(numbersim=2, J1=7, J2=2, J3=2, J4=2, J5=2, df=20);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 12:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Proc-IML-to-analyze-data-rowwise/m-p/109819#M824</guid>
      <dc:creator>mamzolo</dc:creator>
      <dc:date>2013-04-16T12:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using Proc IML to analyze data rowwise</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Proc-IML-to-analyze-data-rowwise/m-p/109820#M825</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You say that you want to "order means for each simulation number," but I don't understand the connection to the %mean_will macro, which is not sorting anything. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The example data are&lt;/P&gt;&lt;P&gt;sim meanX1 meanX2 meanX3 meanX4 meanX5 &lt;/P&gt;&lt;P&gt;1 1.85570 1.82321 1.85598 1.80608 1.81799 &lt;/P&gt;&lt;P&gt;2 1.84527 1.82912 1.85502 1.85474 1.82042&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you want the results to be, and why? Do you want each row to appear in sorted order?&amp;nbsp; Do you want to run the %mean_will macro and then sort the resulting vector?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW, in the macro I notice that you are computing with x[u:v] when x is a matrix. Are you trying to work with the columns x[ ,u:v]?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 12:41:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Proc-IML-to-analyze-data-rowwise/m-p/109820#M825</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-04-16T12:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using Proc IML to analyze data rowwise</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Proc-IML-to-analyze-data-rowwise/m-p/109821#M826</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes the proc iml inside %mean_will macro looks at the mean values meanX1-meanX5 to see if they are all in a non-increasing order, if that's not the case it will take the average of those means that violate this restriction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to be able to do this for each sim=1, 2, etc. The reason is that I'm doing some analysis where the alternative hypothesis is ordered this way. For this macro I want to be able to get the means computed/arranged as indicated in the proc iml but this done for each 'sim'. The whole macro works perfect when only 1 row is considered, problems start when I include several rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, I'm working with the columns. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All in all it's more like this: For each sim (row) : The value in column 1 &amp;gt;= the value in column 2 &amp;gt;= etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 13:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Proc-IML-to-analyze-data-rowwise/m-p/109821#M826</guid>
      <dc:creator>mamzolo</dc:creator>
      <dc:date>2013-04-16T13:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using Proc IML to analyze data rowwise</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Proc-IML-to-analyze-data-rowwise/m-p/109822#M827</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't make sense of what your algorithm is doing, but here are some tips:&lt;/P&gt;&lt;P&gt;In the innermost loop, you have a computation that is equivalent to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; w = x[u:v]#n[u:v];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a&lt;V&gt;=w[+] / sum(n[u:v]);&lt;/V&gt;&lt;/P&gt;&lt;P&gt;This expression is incorrect when x is a matrix.&amp;nbsp; Instead, you might consider a vector expression like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; w = x[ ,u:v]#n[ ,u:v];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a[ ,v]=w[ ,+] / sum(n[u:v]);&lt;/P&gt;&lt;P&gt;where now a is now a matrix: a = j(nrow(x), ncol(x), .);&lt;/P&gt;&lt;P&gt;Then you have to do something with the MIN and MAX functions, so that you get the min and max for each row(?).&amp;nbsp; Perhaps you can use&amp;nbsp; something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; maxOfRows = a[ , &amp;lt;&amp;gt;];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; minOfRows = a[ , &amp;gt;&amp;lt;];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In short, express everything as vectors and use subscript reduction operators. Subscript reduction operators are described here: &lt;A href="http://blogs.sas.com/content/iml/2012/05/23/compute-statistics-for-each-row-by-using-subscript-operators/" title="http://blogs.sas.com/content/iml/2012/05/23/compute-statistics-for-each-row-by-using-subscript-operators/"&gt; Compute statistics for each row by using subscript operators - The DO Loop&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 14:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Proc-IML-to-analyze-data-rowwise/m-p/109822#M827</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-04-16T14:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using Proc IML to analyze data rowwise</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Proc-IML-to-analyze-data-rowwise/m-p/109823#M828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot, will look into your considerations carefully!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 15:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-Proc-IML-to-analyze-data-rowwise/m-p/109823#M828</guid>
      <dc:creator>mamzolo</dc:creator>
      <dc:date>2013-04-16T15:02:16Z</dc:date>
    </item>
  </channel>
</rss>

