<?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: How to convert m*m correlation matrix into pair-wise dataset?! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802632#M315988</link>
    <description>&lt;P&gt;Why not just use normal SAS code?&lt;BR /&gt;Generate the correlations.&lt;/P&gt;
&lt;P&gt;Transpose.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc corr data=sashelp.heart out=corr noprint;
 var _numeric_;
run;
proc transpose
  data=corr(rename=(_name_=LEFT))
  out=pairs(rename=(_name_=RIGHT) drop=_label_ )
;
  by left notsorted;
  where _type_='CORR';
  id _type_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;Obs    LEFT          RIGHT            CORR

  1    AgeCHDdiag    AgeCHDdiag      1.00000
  2    AgeCHDdiag    AgeAtStart      0.55091
  3    AgeCHDdiag    Height         -0.21042
  4    AgeCHDdiag    Weight         -0.13741
  5    AgeCHDdiag    Diastolic      -0.03510
  6    AgeCHDdiag    Systolic        0.06924
  7    AgeCHDdiag    MRW             0.00642
  8    AgeCHDdiag    Smoking        -0.28357
  9    AgeCHDdiag    AgeAtDeath      0.74811
 10    AgeCHDdiag    Cholesterol     0.00363
 11    AgeAtStart    AgeCHDdiag      0.55091
 12    AgeAtStart    AgeAtStart      1.00000
 13    AgeAtStart    Height         -0.13173
 14    AgeAtStart    Weight          0.09352
 15    AgeAtStart    Diastolic       0.27540
 16    AgeAtStart    Systolic        0.37938
 17    AgeAtStart    MRW             0.20451
 18    AgeAtStart    Smoking        -0.16743
 19    AgeAtStart    AgeAtDeath      0.68860
 20    AgeAtStart    Cholesterol     0.27341
 21    Height        AgeCHDdiag     -0.21042
...&lt;/PRE&gt;
&lt;P&gt;You could eliminate the self correlations and the duplicate entries by just filtering to the observations where LEFT &amp;lt; RIGHT.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Mar 2022 15:12:49 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-03-17T15:12:49Z</dc:date>
    <item>
      <title>How to convert m*m correlation matrix into pair-wise dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802603#M315972</link>
      <description>&lt;P&gt;Proc CORR creates m*m correlation matrix ... how to convert it into pair-wise dataset?!&lt;/P&gt;
&lt;P&gt;Say here are ten variables, CORR creates 10*10 correlation matrix, need to convert into 10*10=100 row (var1 var2 corr12)..&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 10:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802603#M315972</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-03-17T10:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert m*m correlation matrix into pair-wise dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802604#M315973</link>
      <description>&lt;P&gt;There way to do in R. How to do in SAS?! &lt;A href="https://stackoverflow.com/questions/33781147/r-converting-correlation-matrix-to-pairwise" target="_blank"&gt;https://stackoverflow.com/questions/33781147/r-converting-correlation-matrix-to-pairwise&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 10:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802604#M315973</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-03-17T10:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert m*m correlation matrix into pair-wise dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802607#M315974</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/creating-a-table-of-highly-correlated-values/m-p/802045#M315701" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/creating-a-table-of-highly-correlated-values/m-p/802045#M315701&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 10:15:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802607#M315974</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-17T10:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert m*m correlation matrix into pair-wise dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802609#M315976</link>
      <description>&lt;P&gt;See the article, &lt;A href="https://blogs.sas.com/content/iml/2017/08/16/pairwise-correlations-bar-chart.html" target="_self"&gt;"Use a bar chart to visualize pairwise correlations."&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The focus of that article is to create a bar chart of the pairwise correlations, but you can use the same code to create a list.&lt;/P&gt;
&lt;P&gt;The SAS/IML language has similarities with R, but if you are new to SAS, here is an explicit example, modified from the article:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
ods exclude all;
proc corr data=sashelp.Heart;      /* pairwise correlation */
   var _NUMERIC_;
   ods output PearsonCorr = Corr;  /* write correlations, p-values, and sample sizes to data set */
run;
ods exclude none;

proc iml;
use Corr;
   read all var "Variable" into ColNames;  /* get names of variables */
   read all var (ColNames) into mCorr;     /* matrix of correlations */
close Corr;

numCols = ncol(mCorr);                /* number of variables */
numPairs = numCols*(numCols-1) / 2;
length = 2*nleng(ColNames) + 5;       /* max length of new ID variable */
PairNames = j(NumPairs, 1, BlankStr(length));
i = 1;
do row= 2 to numCols;                 /* construct the pairwise names */
   do col = 1 to row-1;
      PairNames[i] = strip(ColNames[col]) + " vs. " + strip(ColNames[row]);
      i = i + 1;
   end;
end;
 
lowerIdx = loc(row(mCorr) &amp;gt; col(mCorr));  /* indices of lower-triangular elements */
Corr = mCorr[ lowerIdx ];

create CorrPairs var {"PairNames" "Corr"};
append;
close;
QUIT;

proc print data=CorrPairs; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Mar 2022 10:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802609#M315976</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-03-17T10:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert m*m correlation matrix into pair-wise dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802624#M315987</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.Heart;
run;

ods exclude all;
proc corr data=have;      /* pairwise correlation */
   var _NUMERIC_;
   ods output PearsonCorr = Corr;  /* write correlations, p-values, and sample sizes to data set */
run;
ods exclude none;

proc sort data=corr(drop=Label) out=corr2;
by variable;
run;

proc sql noprint;
select variable into : vname separated by ' ' from corr2;
quit;
proc transpose data=corr2 out=want;
by variable;
var &amp;amp;vname.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Mar 2022 13:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802624#M315987</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-03-17T13:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert m*m correlation matrix into pair-wise dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802632#M315988</link>
      <description>&lt;P&gt;Why not just use normal SAS code?&lt;BR /&gt;Generate the correlations.&lt;/P&gt;
&lt;P&gt;Transpose.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc corr data=sashelp.heart out=corr noprint;
 var _numeric_;
run;
proc transpose
  data=corr(rename=(_name_=LEFT))
  out=pairs(rename=(_name_=RIGHT) drop=_label_ )
;
  by left notsorted;
  where _type_='CORR';
  id _type_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;Obs    LEFT          RIGHT            CORR

  1    AgeCHDdiag    AgeCHDdiag      1.00000
  2    AgeCHDdiag    AgeAtStart      0.55091
  3    AgeCHDdiag    Height         -0.21042
  4    AgeCHDdiag    Weight         -0.13741
  5    AgeCHDdiag    Diastolic      -0.03510
  6    AgeCHDdiag    Systolic        0.06924
  7    AgeCHDdiag    MRW             0.00642
  8    AgeCHDdiag    Smoking        -0.28357
  9    AgeCHDdiag    AgeAtDeath      0.74811
 10    AgeCHDdiag    Cholesterol     0.00363
 11    AgeAtStart    AgeCHDdiag      0.55091
 12    AgeAtStart    AgeAtStart      1.00000
 13    AgeAtStart    Height         -0.13173
 14    AgeAtStart    Weight          0.09352
 15    AgeAtStart    Diastolic       0.27540
 16    AgeAtStart    Systolic        0.37938
 17    AgeAtStart    MRW             0.20451
 18    AgeAtStart    Smoking        -0.16743
 19    AgeAtStart    AgeAtDeath      0.68860
 20    AgeAtStart    Cholesterol     0.27341
 21    Height        AgeCHDdiag     -0.21042
...&lt;/PRE&gt;
&lt;P&gt;You could eliminate the self correlations and the duplicate entries by just filtering to the observations where LEFT &amp;lt; RIGHT.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 15:12:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802632#M315988</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-17T15:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert m*m correlation matrix into pair-wise dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802716#M316035</link>
      <description>Works great. Thanks.</description>
      <pubDate>Thu, 17 Mar 2022 22:50:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802716#M316035</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-03-17T22:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert m*m correlation matrix into pair-wise dataset?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802717#M316036</link>
      <description>&lt;P&gt;Works great. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Mar 2022 22:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-m-m-correlation-matrix-into-pair-wise-dataset/m-p/802717#M316036</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-03-17T22:51:07Z</dc:date>
    </item>
  </channel>
</rss>

