<?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: output row and column headings into a vector in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/output-row-and-column-headings-into-a-vector/m-p/98668#M712</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have lots of choices:&lt;/P&gt;&lt;P&gt;1) use PROC TRANSPOSE again&lt;/P&gt;&lt;P&gt;2) use the DATA step&lt;/P&gt;&lt;P&gt;3) write a loop in SAS/IML&lt;/P&gt;&lt;P&gt;4) Use the ideas in &lt;A href="http://blogs.sas.com/content/iml/2012/02/29/defining-banded-and-triangular-matrices/" title="http://blogs.sas.com/content/iml/2012/02/29/defining-banded-and-triangular-matrices/"&gt;http://blogs.sas.com/content/iml/2012/02/29/defining-banded-and-triangular-matrices/&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Jul 2012 20:42:27 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2012-07-03T20:42:27Z</dc:date>
    <item>
      <title>output row and column headings into a vector</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/output-row-and-column-headings-into-a-vector/m-p/98665#M709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to create a dataset that lists the correlation between pairs of company's returns and the identifies the companies. Basically, I compute the correlation matrix of three companies' (A, B, and C) returns and can output the data, but I don't know how to later identify which correlation is which pair of companies. Any ideas on how to identify each pair? Here's an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data companies;&lt;/P&gt;&lt;P&gt;infile cards;&lt;/P&gt;&lt;P&gt;input permno $ date $ ret;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;A 199901 0.10&lt;/P&gt;&lt;P&gt;A 199902 0.20&lt;/P&gt;&lt;P&gt;A 199903 -0.10&lt;/P&gt;&lt;P&gt;A 199904 -0.20&lt;/P&gt;&lt;P&gt;A 199905 0.15&lt;/P&gt;&lt;P&gt;A 199906 -0.15&lt;/P&gt;&lt;P&gt;A 199907 0.12&lt;/P&gt;&lt;P&gt;A 199908 -0.12&lt;/P&gt;&lt;P&gt;A 199909 0.05&lt;/P&gt;&lt;P&gt;A 199910 -0.05&lt;/P&gt;&lt;P&gt;B 199901 -0.05&lt;/P&gt;&lt;P&gt;B 199902 -0.20&lt;/P&gt;&lt;P&gt;B 199903 0.09&lt;/P&gt;&lt;P&gt;B 199904 -0.10&lt;/P&gt;&lt;P&gt;B 199905 0.05&lt;/P&gt;&lt;P&gt;B 199906 0.05&lt;/P&gt;&lt;P&gt;B 199907 -0.07&lt;/P&gt;&lt;P&gt;B 199908 0.07&lt;/P&gt;&lt;P&gt;B 199909 0.01&lt;/P&gt;&lt;P&gt;B 199910 -0.01&lt;/P&gt;&lt;P&gt;C 199901 0.20&lt;/P&gt;&lt;P&gt;C 199902 0.10&lt;/P&gt;&lt;P&gt;C 199903 -0.05&lt;/P&gt;&lt;P&gt;C 199904 -0.05&lt;/P&gt;&lt;P&gt;C 199905 0.19&lt;/P&gt;&lt;P&gt;C 199906 -0.11&lt;/P&gt;&lt;P&gt;C 199907 0.12&lt;/P&gt;&lt;P&gt;C 199908 -0.12&lt;/P&gt;&lt;P&gt;C 199909 0.05&lt;/P&gt;&lt;P&gt;C 199910 -0.05&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;proc contents; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=companies; by date;&lt;/P&gt;&lt;P&gt;proc transpose data=companies out=want; id permno;&lt;/P&gt;&lt;P&gt;by date;&lt;/P&gt;&lt;P&gt;var ret;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc iml;&lt;/P&gt;&lt;P&gt;&amp;nbsp; use want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; read all var _NUM_ into x[colname=permno];&lt;/P&gt;&lt;P&gt;&amp;nbsp; close want;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; corr=corr(x);&lt;/P&gt;&lt;P&gt;&amp;nbsp; mattrib corr rowname=permno colname=permno;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; print corr;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create rj var {corr};&lt;/P&gt;&lt;P&gt;&amp;nbsp; append ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; close rj;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data junk; set rj; proc print; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/**********&lt;/P&gt;&lt;P&gt;data rj lists all 9 correlations but I can't identify the individual pairs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Specifically, I get&lt;/P&gt;&lt;P&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CORR&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.00000&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.43578&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.88046&lt;/P&gt;&lt;P&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.43578&lt;/P&gt;&lt;P&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.00000&lt;/P&gt;&lt;P&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.37909&lt;/P&gt;&lt;P&gt;7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.88046&lt;/P&gt;&lt;P&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.37909&lt;/P&gt;&lt;P&gt;9&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1.0000&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I'd like to get&lt;/P&gt;&lt;P&gt;A A 1&lt;/P&gt;&lt;P&gt;A B -0.43578&lt;/P&gt;&lt;P&gt;A C 0.88046&lt;/P&gt;&lt;P&gt;B A -0.43578&lt;/P&gt;&lt;P&gt;B B 1&lt;/P&gt;&lt;P&gt;B C -0.379087&lt;/P&gt;&lt;P&gt;C A 0.8804574&lt;/P&gt;&lt;P&gt;C B -0.379087&lt;/P&gt;&lt;P&gt;C C 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And really, I'd just like the bottom half of the matrix (i.e., just the 3 unique correlations)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A B -0.43578&lt;/P&gt;&lt;P&gt;A C 0.88046&lt;/P&gt;&lt;P&gt;B C -0.379087&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas? Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jul 2012 19:34:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/output-row-and-column-headings-into-a-vector/m-p/98665#M709</guid>
      <dc:creator>coug914</dc:creator>
      <dc:date>2012-07-03T19:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: output row and column headings into a vector</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/output-row-and-column-headings-into-a-vector/m-p/98666#M710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Depending upon how you intend to use the correlations, you might want to output a TYPE=CORR data set:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 14pt;"&gt;create &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 14pt;"&gt;R(type=corr) &lt;/SPAN&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 14pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 14pt;"&gt; Corr[r=permno c=permno];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 14pt;"&gt;append &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 14pt;"&gt;&lt;SPAN style="background: white; color: blue; font-family: 'Courier New'; font-size: 14pt;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; font-family: 'Courier New'; font-size: 14pt;"&gt; Corr[r=permno];&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue; line-height: 115%; font-family: 'Courier New'; font-size: 14pt;"&gt;close &lt;/SPAN&gt;&lt;SPAN style="background: white; color: black; line-height: 115%; font-family: 'Courier New'; font-size: 14pt;"&gt;R;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you really want the lower triangular data in a "flat" format, use the &lt;A href="http://support.sas.com/documentation/cdl/en/imlug/64248/HTML/default/viewer.htm#imlug_langref_sect297.htm"&gt;SYMSQR function&lt;/A&gt; .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jul 2012 20:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/output-row-and-column-headings-into-a-vector/m-p/98666#M710</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2012-07-03T20:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: output row and column headings into a vector</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/output-row-and-column-headings-into-a-vector/m-p/98667#M711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Rick -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not quite what I need, however. I want to use the correlations as dependent variables in a later regression (hence, I need it in "flat" format - each correlation is an observation). So I need to have each correlation as a single row with the identifiers of the two companies. I also tried symsqr, but again can't seem to figure out how to identify the pairs. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g., I'd like the output to look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;firm1_firm2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; corr&lt;/P&gt;&lt;P&gt;A_B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.43578&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;A_C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.88046&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;B_C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -0.379087&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Thanks,&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Rick&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jul 2012 20:15:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/output-row-and-column-headings-into-a-vector/m-p/98667#M711</guid>
      <dc:creator>coug914</dc:creator>
      <dc:date>2012-07-03T20:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: output row and column headings into a vector</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/output-row-and-column-headings-into-a-vector/m-p/98668#M712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have lots of choices:&lt;/P&gt;&lt;P&gt;1) use PROC TRANSPOSE again&lt;/P&gt;&lt;P&gt;2) use the DATA step&lt;/P&gt;&lt;P&gt;3) write a loop in SAS/IML&lt;/P&gt;&lt;P&gt;4) Use the ideas in &lt;A href="http://blogs.sas.com/content/iml/2012/02/29/defining-banded-and-triangular-matrices/" title="http://blogs.sas.com/content/iml/2012/02/29/defining-banded-and-triangular-matrices/"&gt;http://blogs.sas.com/content/iml/2012/02/29/defining-banded-and-triangular-matrices/&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jul 2012 20:42:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/output-row-and-column-headings-into-a-vector/m-p/98668#M712</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2012-07-03T20:42:27Z</dc:date>
    </item>
  </channel>
</rss>

