<?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: bring back Lower triangular matrix in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60718#M384</link>
    <description>&amp;gt; I want the covariance values. &lt;BR /&gt;
&lt;BR /&gt;
They are in v.&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; I would like the low matrix but with missing values on the diagonal.&lt;BR /&gt;
&lt;BR /&gt;
low = j(n, p, .);&lt;BR /&gt;
do i = 2 to n;&lt;BR /&gt;
cols = 1:i-1;&lt;BR /&gt;
low[i, cols] = a[i, cols];&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; show me how to produce the mean, min, max, ... of the covariance part &lt;BR /&gt;
&amp;gt; of the matrix for A, B and C in IML ?&lt;BR /&gt;
&lt;BR /&gt;
For the matrix a, you can compute the mean (or max or min...)  of three different quantities: the total mean, the rows means, or the column means.&lt;BR /&gt;
For the totals:&lt;BR /&gt;
mean = a[:];            /* ":" is mean operator */&lt;BR /&gt;
min = min(a);&lt;BR /&gt;
max = max(a);&lt;BR /&gt;
print mean min max;&lt;BR /&gt;
&lt;BR /&gt;
For the column means:&lt;BR /&gt;
ColMean = a[:,];  /* mean of each column (apply operation on rows)*/&lt;BR /&gt;
ColMin  = a[&amp;gt;&amp;lt;,]; /* min of each column */&lt;BR /&gt;
ColMax  = a[&amp;lt;&amp;gt;,]; /* max of each column */&lt;BR /&gt;
print ColMean, ColMin, ColMax;&lt;BR /&gt;
&lt;BR /&gt;
These subscript reduction operators take some getting used to, but are great for computing summary statistics without writing any loops. They are documented in the "Working with Matrices" chapter of the SAS/IML User's Guide:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/imlug/59656/HTML/default/workmatrix_sect14.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/imlug/59656/HTML/default/workmatrix_sect14.htm&lt;/A&gt;</description>
    <pubDate>Wed, 24 Feb 2010 13:31:57 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2010-02-24T13:31:57Z</dc:date>
    <item>
      <title>bring back Lower triangular matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60714#M380</link>
      <description>Hi&lt;BR /&gt;
&lt;BR /&gt;
I'd like to bring back the lower or upper triangular matrix with IML.&lt;BR /&gt;
&lt;BR /&gt;
Is it possible ?</description>
      <pubDate>Sat, 20 Feb 2010 17:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60714#M380</guid>
      <dc:creator>Stephane</dc:creator>
      <dc:date>2010-02-20T17:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: bring back Lower triangular matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60715#M381</link>
      <description>"bring back"?? I don't understand what you are asking for.</description>
      <pubDate>Mon, 22 Feb 2010 20:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60715#M381</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-02-22T20:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: bring back Lower triangular matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60716#M382</link>
      <description>It's always a good idea to supply an example.&lt;BR /&gt;
&lt;BR /&gt;
Are you saying that you have a matrix&lt;BR /&gt;
a = {1 2 3, 4 5 6, 7 8 9};&lt;BR /&gt;
and you want the lower triangular values?&lt;BR /&gt;
If so, do you want them in a vector or in a matrix?&lt;BR /&gt;
&lt;BR /&gt;
To get the values in a vector, you can use&lt;BR /&gt;
lower = symsqr(a);&lt;BR /&gt;
upper = symsqr(a`);&lt;BR /&gt;
&lt;BR /&gt;
If you need the lower triangular matrix with zeros above the diagonal, you can use:&lt;BR /&gt;
n = nrow(a);&lt;BR /&gt;
p = ncol(a);&lt;BR /&gt;
low = j(n, p, 0);&lt;BR /&gt;
do i = 1 to n;&lt;BR /&gt;
   cols = 1:i;  /* or   cols=i:p; */&lt;BR /&gt;
   low[i, cols] = a[i, cols];&lt;BR /&gt;
end;</description>
      <pubDate>Mon, 22 Feb 2010 20:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60716#M382</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2010-02-22T20:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: bring back Lower triangular matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60717#M383</link>
      <description>oops sorry it's true that my explanation is light and I'm newbie in IML.&lt;BR /&gt;
&lt;BR /&gt;
using your (excellent) proposition :&lt;BR /&gt;
proc iml;&lt;BR /&gt;
 a={&lt;BR /&gt;
-3   2  4, &lt;BR /&gt;
2  -2  3, &lt;BR /&gt;
4   3 -4};&lt;BR /&gt;
r={"A" "B" "C"}; &lt;BR /&gt;
c={"A" "B" "C"};&lt;BR /&gt;
v=vecdiag(a);&lt;BR /&gt;
lower = symsqr(a);&lt;BR /&gt;
upper = symsqr(a`);&lt;BR /&gt;
&lt;BR /&gt;
n = nrow(a);&lt;BR /&gt;
p = ncol(a);&lt;BR /&gt;
low = j(n, p, .);&lt;BR /&gt;
do i = 1 to n;&lt;BR /&gt;
cols = 1:i; /* or cols=i:p; */&lt;BR /&gt;
low[i, cols] = a[i, cols];&lt;BR /&gt;
end; &lt;BR /&gt;
&lt;BR /&gt;
print a[rowname=r colname=c];&lt;BR /&gt;
print low[rowname=r colname=c];&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
You see that the "a" matrix is a variance/covariance matrix and I want the covariance values. So your low matrix is fine except that I would like the low matrix but with missing values on the diagonal.&lt;BR /&gt;
&lt;BR /&gt;
Otherwise Rick, could you show me how to produce the mean, min, max, ... of the covariance part of the matrix for A, B and C in IML ?

Message was edited by: Stephane</description>
      <pubDate>Wed, 24 Feb 2010 10:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60717#M383</guid>
      <dc:creator>Stephane</dc:creator>
      <dc:date>2010-02-24T10:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: bring back Lower triangular matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60718#M384</link>
      <description>&amp;gt; I want the covariance values. &lt;BR /&gt;
&lt;BR /&gt;
They are in v.&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; I would like the low matrix but with missing values on the diagonal.&lt;BR /&gt;
&lt;BR /&gt;
low = j(n, p, .);&lt;BR /&gt;
do i = 2 to n;&lt;BR /&gt;
cols = 1:i-1;&lt;BR /&gt;
low[i, cols] = a[i, cols];&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; show me how to produce the mean, min, max, ... of the covariance part &lt;BR /&gt;
&amp;gt; of the matrix for A, B and C in IML ?&lt;BR /&gt;
&lt;BR /&gt;
For the matrix a, you can compute the mean (or max or min...)  of three different quantities: the total mean, the rows means, or the column means.&lt;BR /&gt;
For the totals:&lt;BR /&gt;
mean = a[:];            /* ":" is mean operator */&lt;BR /&gt;
min = min(a);&lt;BR /&gt;
max = max(a);&lt;BR /&gt;
print mean min max;&lt;BR /&gt;
&lt;BR /&gt;
For the column means:&lt;BR /&gt;
ColMean = a[:,];  /* mean of each column (apply operation on rows)*/&lt;BR /&gt;
ColMin  = a[&amp;gt;&amp;lt;,]; /* min of each column */&lt;BR /&gt;
ColMax  = a[&amp;lt;&amp;gt;,]; /* max of each column */&lt;BR /&gt;
print ColMean, ColMin, ColMax;&lt;BR /&gt;
&lt;BR /&gt;
These subscript reduction operators take some getting used to, but are great for computing summary statistics without writing any loops. They are documented in the "Working with Matrices" chapter of the SAS/IML User's Guide:&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/imlug/59656/HTML/default/workmatrix_sect14.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/imlug/59656/HTML/default/workmatrix_sect14.htm&lt;/A&gt;</description>
      <pubDate>Wed, 24 Feb 2010 13:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60718#M384</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2010-02-24T13:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: bring back Lower triangular matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60719#M385</link>
      <description>&amp;gt; I want the covariance values.&lt;BR /&gt;
&lt;BR /&gt;
They are in v.&lt;BR /&gt;
&lt;BR /&gt;
=&amp;gt; No it's the variance and this is why I want to the rest.&lt;BR /&gt;
&lt;BR /&gt;
for your explanations for the statistics, it's fine.

Message was edited by: Stephane</description>
      <pubDate>Wed, 24 Feb 2010 15:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60719#M385</guid>
      <dc:creator>Stephane</dc:creator>
      <dc:date>2010-02-24T15:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: bring back Lower triangular matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60720#M386</link>
      <description>Of course. Sorry. The variances are in v; the covariances are in low.</description>
      <pubDate>Wed, 24 Feb 2010 15:45:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60720#M386</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2010-02-24T15:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: bring back Lower triangular matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60721#M387</link>
      <description>Thank you very much Rick.</description>
      <pubDate>Thu, 25 Feb 2010 12:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/60721#M387</guid>
      <dc:creator>Stephane</dc:creator>
      <dc:date>2010-02-25T12:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: bring back Lower triangular matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/280363#M2881</link>
      <description>&lt;P&gt;Hi rick,&lt;/P&gt;&lt;P&gt;did you have any suggests to do the same thing but without PROC IML?&lt;/P&gt;&lt;P&gt;thank you bery much&lt;/P&gt;&lt;P&gt;MC&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 09:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/280363#M2881</guid>
      <dc:creator>MC1985</dc:creator>
      <dc:date>2016-06-27T09:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: bring back Lower triangular matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/280371#M2882</link>
      <description>&lt;P&gt;Please start a new thread in the Base SAS Programming community rather than re-opening a SAS/IML thread from 2010.&amp;nbsp; You can solve this problem in the DATA step by using arrays and the _N_ automatic variable.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 10:18:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/280371#M2882</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-06-27T10:18:37Z</dc:date>
    </item>
    <item>
      <title>Re: bring back Lower triangular matrix</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/280373#M2883</link>
      <description>&lt;P&gt;OK, thanks. Here we are: &lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/SAS-BASE-from-TRIANGLE-UPPER-MATRIX-to-Squared-Matrix-NO-IML/m-p/280368#M56646" target="_self"&gt;New Topic on SAS BASE&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 10:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/bring-back-Lower-triangular-matrix/m-p/280373#M2883</guid>
      <dc:creator>MC1985</dc:creator>
      <dc:date>2016-06-27T10:21:23Z</dc:date>
    </item>
  </channel>
</rss>

