<?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: Correlation in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723320#M27957</link>
    <description>hmm I dont know why but this code does not work.&lt;BR /&gt;%let vars=earn cfo c_sales c_cogs c_oe c_int c_tax&lt;BR /&gt;c_othert del_ar del_inv del_ap depr amort&lt;BR /&gt;other_acc_s_t acc_s_t div_s_t BV_s_t at_s_t negEE_s_t NEGE DivD;&lt;BR /&gt;&lt;BR /&gt;/* Compute correlation coefficients by year */&lt;BR /&gt;&lt;BR /&gt;proc corr data=mylibf1.endversion out=pearson_corr noprint;&lt;BR /&gt;var &amp;amp;vars;&lt;BR /&gt;by houyear;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/* Retrieve sort order of analysis variables */&lt;BR /&gt;&lt;BR /&gt;data _vars(keep=_seqno _name_);&lt;BR /&gt;set pearson_corr(firstobs=21);&lt;BR /&gt;_seqno=_n_;&lt;BR /&gt;if _type_~=:'C' then stop;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/* Compute mean values of correlation coefficients */&lt;BR /&gt;&lt;BR /&gt;proc summary data=pearson_corr nway;&lt;BR /&gt;class _name_;&lt;BR /&gt;var &amp;amp;vars;&lt;BR /&gt;output out=_tmp(drop=_type_ _freq_) mean=;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/* Sort the resulting dataset */&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select a.* from _tmp a, _vars b&lt;BR /&gt;where a._name_=b._name_&lt;BR /&gt;order by _seqno;&lt;BR /&gt;drop table _vars, _tmp;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;Now I have four variables in the rows and all variables in the columns.&lt;BR /&gt;Sry Iam a very new user of sas.</description>
    <pubDate>Wed, 03 Mar 2021 23:08:40 GMT</pubDate>
    <dc:creator>DomUk</dc:creator>
    <dc:date>2021-03-03T23:08:40Z</dc:date>
    <item>
      <title>Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723112#M27937</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 20 years of data and for every year, I estimated the correlations for all the variables using the following code.&lt;/P&gt;&lt;P&gt;proc corr data=... out=pearson_corr;&lt;BR /&gt;var x1 x2 x3 x4;&lt;BR /&gt;with x1 x2 x3 x4;&lt;/P&gt;&lt;P&gt;by year&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the next step I would like to get a correlation matrix which shows the mean of this 20 correlation matrixes.&lt;/P&gt;&lt;P&gt;Does anyone have an idea how this is possible? Using proc means I dont get the right result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 10:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723112#M27937</guid>
      <dc:creator>DomUk</dc:creator>
      <dc:date>2021-03-03T10:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723116#M27938</link>
      <description>&lt;P&gt;If you have SAS/IML, you can do this in a few lines of code:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Read the data WHERE _TYPE_="CORR";&lt;/LI&gt;
&lt;LI&gt;Flatten the data so that each 4x4 matrix becomes a 1x16 row vector&lt;/LI&gt;
&lt;LI&gt;FInd the average of the 16 columns. This average is a 1x16 row vector.&lt;/LI&gt;
&lt;LI&gt;Reshape the answer into a 4x4 matrix.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
call streaminit(12345);
do year = 1 to 20;
   do i = 1 to 100;
      x1 = rand("Normal");
      x2 = x1 + rand("Normal");
      x3 = x2 + rand("Normal");
      x4 = x3 + rand("Normal");
      output;
   end;
end;
run;

proc corr data=Have out=pearson_corr noprint;
by year;
var x1 x2 x3 x4;
with x1 x2 x3 x4;
run;

proc iml;
use pearson_corr(where=(_TYPE_='CORR'));
read all var {x1 x2 x3 x4} into X;
close;

/* "flatten" the 4x4 matrices into a 1 x 16 row vector */
Y = shape(X, 0, 16);
/* compute the mean of each column */
mean = mean(Y);
/* reshape into 4x4 matrix */
meanCorr = shape(mean, 0, 4);
print meanCorr;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you don't have SAS/IML, you can do the same operations, but you'll need to use the DATA step and arrays to reshape the data, then use PROC MEANS to find the means of the 16-variable data.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 11:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723116#M27938</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-03-03T11:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723117#M27939</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/368433"&gt;@DomUk&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=pearson_corr nway;
class _name_;
var x:;
output out=want(keep=_name_ x:) mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;[Edit: Removed redundant statement&amp;nbsp;&lt;FONT face="courier new,courier"&gt;where _type_=:'C';&lt;/FONT&gt;]&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 11:29:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723117#M27939</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-03-03T11:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723159#M27944</link>
      <description>Thank you very much,&lt;BR /&gt;how can I keep automatically the variable names ( actually I have 30 varaibles, so to rename them step by step would be taff) and bring them in an folder, after your code they are renamed in col 1... and row1... and only shown in the result viewer.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Mar 2021 14:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723159#M27944</guid>
      <dc:creator>DomUk</dc:creator>
      <dc:date>2021-03-03T14:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723178#M27945</link>
      <description>Thanks a lot. I get already the right numbers, however on the x-axis the varaibles are not sorted (so the diagonal "1-line" is not there, instead the 1-values are distributed thorughout the whole table.</description>
      <pubDate>Wed, 03 Mar 2021 15:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723178#M27945</guid>
      <dc:creator>DomUk</dc:creator>
      <dc:date>2021-03-03T15:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723198#M27947</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/368433"&gt;@DomUk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks a lot. I get already the right numbers, however on the x-axis the varaibles are not sorted (so the diagonal "1-line" is not there, instead the 1-values are distributed thorughout the whole table.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I see. Your variable names are not alphabetically sorted (unlike x1, x2, x3, x4), are they? In this case you may want to retrieve their sort order from dataset &lt;FONT face="courier new,courier"&gt;pearson_corr&lt;/FONT&gt; and finally use this information to sort the output dataset from PROC SUMMARY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As an example, let's assume the variable names are &lt;FONT face="courier new,courier"&gt;h&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;d&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;s&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;q&lt;/FONT&gt;.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let vars=h d s q;

/* Compute correlation coefficients by year */

proc corr data=have out=pearson_corr noprint;
var &amp;amp;vars;
by year;
run;

/* Retrieve sort order of analysis variables */

data _vars(keep=_seqno _name_);
set pearson_corr(firstobs=4);
_seqno=_n_;
if _type_~=:'C' then stop;
run;

/* Compute mean values of correlation coefficients */

proc summary data=pearson_corr nway;
class _name_;
var &amp;amp;vars;
output out=_tmp(drop=_type_ _freq_) mean=;
run;

/* Sort the resulting dataset */

proc sql;
create table want as
select a.* from _tmp a, _vars b
where a._name_=b._name_
order by _seqno;
drop table _vars, _tmp;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;EDIT: If you store the variable names in macro variable VARS (as shown above), you can also use this macro variable to obtain the desired sort order. That is, you can omit the DATA step (&lt;FONT face="courier new,courier"&gt;data _vars&lt;/FONT&gt;&amp;nbsp;...) and replace the PROC SQL step by this modified version:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select * from _tmp
order by whichc(upcase(_name_),"%sysfunc(tranwrd(%upcase(&amp;amp;vars),%str( ),%str(",")))");
drop table _tmp;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 18:16:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723198#M27947</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-03-03T18:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723320#M27957</link>
      <description>hmm I dont know why but this code does not work.&lt;BR /&gt;%let vars=earn cfo c_sales c_cogs c_oe c_int c_tax&lt;BR /&gt;c_othert del_ar del_inv del_ap depr amort&lt;BR /&gt;other_acc_s_t acc_s_t div_s_t BV_s_t at_s_t negEE_s_t NEGE DivD;&lt;BR /&gt;&lt;BR /&gt;/* Compute correlation coefficients by year */&lt;BR /&gt;&lt;BR /&gt;proc corr data=mylibf1.endversion out=pearson_corr noprint;&lt;BR /&gt;var &amp;amp;vars;&lt;BR /&gt;by houyear;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/* Retrieve sort order of analysis variables */&lt;BR /&gt;&lt;BR /&gt;data _vars(keep=_seqno _name_);&lt;BR /&gt;set pearson_corr(firstobs=21);&lt;BR /&gt;_seqno=_n_;&lt;BR /&gt;if _type_~=:'C' then stop;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/* Compute mean values of correlation coefficients */&lt;BR /&gt;&lt;BR /&gt;proc summary data=pearson_corr nway;&lt;BR /&gt;class _name_;&lt;BR /&gt;var &amp;amp;vars;&lt;BR /&gt;output out=_tmp(drop=_type_ _freq_) mean=;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/* Sort the resulting dataset */&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select a.* from _tmp a, _vars b&lt;BR /&gt;where a._name_=b._name_&lt;BR /&gt;order by _seqno;&lt;BR /&gt;drop table _vars, _tmp;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;Now I have four variables in the rows and all variables in the columns.&lt;BR /&gt;Sry Iam a very new user of sas.</description>
      <pubDate>Wed, 03 Mar 2021 23:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723320#M27957</guid>
      <dc:creator>DomUk</dc:creator>
      <dc:date>2021-03-03T23:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723327#M27959</link>
      <description>&lt;P&gt;You changed&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set pearson_corr(firstobs=4);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set pearson_corr(firstobs=&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;21&lt;/FONT&gt;&lt;/STRONG&gt;);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;probably assuming that the "4" meant the number of variables -- but that was pure coincidence. The SET statement must start at the &lt;EM&gt;fourth&lt;/EM&gt; observation irrespective of the number of variables.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 03 Mar 2021 23:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723327#M27959</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-03-03T23:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723847#M27990</link>
      <description>thank you! Now it works.&lt;BR /&gt;If I run the correlation by year, then I get a pvalue for every variable-combination.&lt;BR /&gt;Is it possible to become the average pvalues as well?</description>
      <pubDate>Fri, 05 Mar 2021 11:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723847#M27990</guid>
      <dc:creator>DomUk</dc:creator>
      <dc:date>2021-03-05T11:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723851#M27991</link>
      <description>&lt;P&gt;Yes, it's possible to obtain average p-values as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a complete example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
call streaminit(27182818);
do year=1 to 20;
  do _n_=1 to 100;
    d=rand('uniform');
    h=rand('uniform');
    s=rand('uniform');
    q=rand('uniform');
    output;
  end;
end;
run;

%let vars=h d s q; /* Variable order may be defined differently than in the dataset. */

/* Compute correlation coefficients by year */

ods output pearsoncorr=pearson_corr;
proc corr data=have;
var &amp;amp;vars;
by year;
run;

/* Compute mean values of correlation coefficients and p-values */

proc summary data=pearson_corr nway;
class Variable;
var _numeric_;
output out=_tmp(drop=year _:) mean=;
run;

/* Sort the resulting dataset */

proc sql;
create table want as
select * from _tmp
order by whichc(upcase(Variable),"%sysfunc(tranwrd(%upcase(&amp;amp;vars),%str( ),%str(",")))");
drop table _tmp;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Variable           h           d           s           q          Ph          Pd          Ps          Pq

   h         1.00000     0.00485     0.01906     0.01108       .          0.5860      0.4575      0.5198
   d         0.00485     1.00000     0.00465    -0.00434      0.5860       .          0.4407      0.4343
   s         0.01906     0.00465     1.00000    -0.01984      0.4575      0.4407       .          0.5118
   q         0.01108    -0.00434    -0.01984     1.00000      0.5198      0.4343      0.5118       .&lt;/PRE&gt;
&lt;P&gt;The variable list &lt;FONT face="courier new,courier"&gt;_numeric_&lt;/FONT&gt; in the PROC SUMMARY step includes &lt;FONT face="courier new,courier"&gt;year&lt;/FONT&gt; (which is then dropped from dataset &lt;FONT face="courier new,courier"&gt;_tmp&lt;/FONT&gt;). Alternatively, you could use a different variable list:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=pearson_corr nway;
class Variable;
var &amp;amp;vars p:;
output out=_tmp(drop=_:) mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works in the current example (where none of the variable names in &lt;FONT face="courier new,courier"&gt;&amp;amp;vars&lt;/FONT&gt; starts with "P"). In other cases you might need to construct the variable list for the VAR statement differently (e.g. similarly to the TRANWRD technique used in the PROC SQL step).&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 12:42:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723851#M27991</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-03-05T12:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723878#M27992</link>
      <description>&lt;P&gt;With respect, the arithmetic average p-value is a meaningless quantity. It has no useful interpretation that I am aware of.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To give an example, suppose for 19 models, the p-value is 0.01. For the 20th model, the p-value is 0.99. The average of those values is ~0.059, but that value does not mean anything because it is not the result of a statistical test.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 14:36:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723878#M27992</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2021-03-05T14:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723884#M27994</link>
      <description>yes that is right, however in my data, the pvalues are almost the same. So it might be okay in this case.</description>
      <pubDate>Fri, 05 Mar 2021 14:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723884#M27994</guid>
      <dc:creator>DomUk</dc:creator>
      <dc:date>2021-03-05T14:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723903#M27997</link>
      <description>&lt;P&gt;I have one small more question.&lt;/P&gt;&lt;P&gt;For the same 20 years I calculated descriptive statistics using the following code:&lt;/P&gt;&lt;P&gt;proc means data=... N&amp;nbsp; Mean min p1 p25 Median p75 p99 max std;&lt;BR /&gt;var x1 ..... x21;&lt;BR /&gt;by year;&lt;BR /&gt;output out=desk_stat mean()= p1()= p25()= median()= p75()= p99()= std()= /autoname;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;In the second step I calculated again the mean of the 20 years:&lt;/P&gt;&lt;P&gt;proc means data=desk_stat mean;&lt;BR /&gt;output out = mylib.desk_stat_EV;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;After the first step I get a very nice picture in the result window. I would like to get such a table (columns show the statistics and row the variables) for my output.&lt;/P&gt;&lt;P&gt;I think I have to use a transform step, but Iam not exactly sure how I can handle it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 16:34:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723903#M27997</guid>
      <dc:creator>DomUk</dc:creator>
      <dc:date>2021-03-05T16:34:53Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723921#M28000</link>
      <description>&lt;P&gt;The statistic-keywords in the PROC MEANS statement control the output in the Output window (listing output) or Results Viewer (HTML), independently of the statistics for the output dataset requested in the OUTPUT statement. In your second PROC MEANS step you don't specify statistics in the OUTPUT statement (and use no VAR statement either) so that the output dataset will contain a &lt;EM&gt;default&lt;/EM&gt; set of statistics (N, min, max, mean, std) for all numeric variables: five rows with one statistic per row. You can obtain an output dataset with columns &lt;FONT face="courier new,courier"&gt;Variable&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;Mean&lt;/FONT&gt;, ... (other statistics as specified in the PROC MEANS statement) ... by using an &lt;EM&gt;ODS&lt;/EM&gt; OUTPUT statement in conjunction with the STACKODSOUTPUT option of the PROC MEANS statement. For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=desk_stat(drop=_:) mean std stackodsoutput;
ods output summary=want;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Mar 2021 17:25:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723921#M28000</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-03-05T17:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723922#M28001</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/368433"&gt;@DomUk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;yes that is right, however in my data, the pvalues are almost the same. So it might be okay in this case.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Indeed, certain conclusions are valid. For example:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;mean(of p1-p20)&amp;lt;=0.0025 implies max(of p1-p20)&amp;lt;=0.05,
mean(of p1-p20)&amp;gt; 0.9525 implies min(of p1-p20)&amp;gt; 0.05.&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Mar 2021 17:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/723922#M28001</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-03-05T17:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/727538#M28201</link>
      <description>Hi again &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;If I run the code, I get the following note message: NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT clause. I dont exactly understand the meaning of this statement. Can I ignore it? The exact log statement is the following:&lt;BR /&gt;187 proc sql;&lt;BR /&gt;188 create table Avg_korr2 as&lt;BR /&gt;189 select * from _tmp&lt;BR /&gt;190 order by whichc(upcase(Variable),"%sysfunc(tranwrd(%upcase(&amp;amp;vars),%str( ),%str(",")))");&lt;BR /&gt;NOTE: The query as specified involves ordering by an item that doesn't appear in its SELECT clause.&lt;BR /&gt;NOTE: Table WORK.AVG_KORR2 created, with 21 rows and 43 columns.&lt;BR /&gt;&lt;BR /&gt;191 drop table _tmp;&lt;BR /&gt;NOTE: Table WORK._TMP has been dropped.&lt;BR /&gt;192 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.07 seconds&lt;BR /&gt;cpu time 0.09 seconds&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Mar 2021 19:30:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/727538#M28201</guid>
      <dc:creator>DomUk</dc:creator>
      <dc:date>2021-03-18T19:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/727546#M28202</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/368433"&gt;@DomUk&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes, you can ignore that note. It refers to the WHICHC expression (in the ORDER BY clause), which indeed "&lt;SPAN&gt;doesn't appear in [the] SELECT clause" -- but exactly this is intended.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 19:46:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/727546#M28202</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-03-18T19:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/738452#M28886</link>
      <description>Hi again,&lt;BR /&gt;is it possible to run the same code for spearman correlation? If I substitute pearson corr with spearmancorr it does not work. YOu can find the code below.&lt;BR /&gt;Thanks again for an answer!&lt;BR /&gt;&lt;BR /&gt;%let vars=earn_s_t cfo_s_t c_sales_s_t c_cogs_s_t c_oe_s_t c_int_s_t c_tax_s_t&lt;BR /&gt;c_other_s_t del_ar_s_t del_inv_s_t del_ap_s_t depr_s_t amort_s_t&lt;BR /&gt;oth_acc_s_t acc_s_t div_s_t BV_s_t at_s_t negEE_s_t NEGE DivD;&lt;BR /&gt;&lt;BR /&gt;ods output SpearmanCorr=spearman_Korr;&lt;BR /&gt;proc corr data=mylib.endversion;&lt;BR /&gt;var &amp;amp;vars;&lt;BR /&gt;by houyear;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc summary data=Spearman_Korr nway;&lt;BR /&gt;class Variable;&lt;BR /&gt;var _numeric_;&lt;BR /&gt;output out=_tmp(drop=houyear _:) mean=;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table mylib.Avg_korr_Spearman as&lt;BR /&gt;select * from _tmp&lt;BR /&gt;order by whichc(upcase(Variable),"%sysfunc(tranwrd(%upcase(&amp;amp;vars),%str( ),%str(",")))");&lt;BR /&gt;drop table _tmp;&lt;BR /&gt;quit;&lt;BR /&gt;</description>
      <pubDate>Sun, 02 May 2021 22:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/738452#M28886</guid>
      <dc:creator>DomUk</dc:creator>
      <dc:date>2021-05-02T22:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/738453#M28887</link>
      <description>&lt;P&gt;What doesn't work? Explain. Show us.&lt;/P&gt;</description>
      <pubDate>Sun, 02 May 2021 22:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/738453#M28887</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-05-02T22:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Correlation</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/738522#M28890</link>
      <description>&lt;P&gt;Of course, you can apply the same techniques to Spearman correlation coefficients that we used for Pearson correlation coefficients. Just specify the appropriate option &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_corr_syntax01.htm#procstat.corr.spearmanopt" target="_blank" rel="noopener"&gt;SPEARMAN&lt;/A&gt; in the PROC CORR statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4"&gt;proc corr data=mylib.endversion &lt;FONT color="#3366FF"&gt;&lt;STRONG&gt;spearman&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise you will get this warning in the log:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#008000"&gt;WARNING: Output 'SpearmanCorr' was not created.  Make sure that the output object name, label, or path is spelled correctly.  Also, verify that the
         appropriate procedure options are used to produce the requested output object.  For example, verify that the NOPRINT option is not used.&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;The request to "&lt;FONT face="courier new,courier" color="#008000"&gt;verify that the appropriate procedure options are used to produce the requested output object&lt;/FONT&gt;" means: Check column "Option" in the table of ODS table names, which is found under "Details" in the procedure documentation. For PROC CORR:&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_corr_details24.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/procstat/procstat_corr_details24.htm&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 09:45:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Correlation/m-p/738522#M28890</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-05-03T09:45:10Z</dc:date>
    </item>
  </channel>
</rss>

