<?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: mean correlations across 80 variables in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52219#M2379</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the inaccuracy in my question.. Yes I meant across all countries..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Apr 2012 21:36:22 GMT</pubDate>
    <dc:creator>carbs</dc:creator>
    <dc:date>2012-04-02T21:36:22Z</dc:date>
    <item>
      <title>mean correlations across 80 variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52217#M2377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a data including 20 countries' observations for four variables, x1,x2,x3 and x4. I would like to get mean values for the correlations between countries for pairs x1&amp;amp;x2, x1&amp;amp;x3,1&amp;amp;4,2&amp;amp;3,2&amp;amp;4,3&amp;amp;4. I have all the data in one file, and I know proc corr can be used in calculating the correlations, but didn't figure out how to be able to modify the code so that I'd get it to calculate the mean correlations like suggested?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Apr 2012 09:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52217#M2377</guid>
      <dc:creator>carbs</dc:creator>
      <dc:date>2012-04-01T09:37:56Z</dc:date>
    </item>
    <item>
      <title>mean correlations across 80 variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52218#M2378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually, I am not sure that your question is well specified.&amp;nbsp; You have twenty data points with 4 values for each (20 rows and 4 columns).&amp;nbsp; If you do the initial correlations that you specify, then that is ACROSS&amp;nbsp; all countries, not BETWEEN any pair of them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2012 19:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52218#M2378</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2012-04-02T19:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: mean correlations across 80 variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52219#M2379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the inaccuracy in my question.. Yes I meant across all countries..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2012 21:36:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52219#M2379</guid>
      <dc:creator>carbs</dc:creator>
      <dc:date>2012-04-02T21:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: mean correlations across 80 variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52220#M2380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any ideas still?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 18:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52220#M2380</guid>
      <dc:creator>carbs</dc:creator>
      <dc:date>2012-04-17T18:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: mean correlations across 80 variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52221#M2381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Post some actual example data so that someone can try to understand the question.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 19:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52221#M2381</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-17T19:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: mean correlations across 80 variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52222#M2382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I attached a data sample.. There's four variables, and each country has their own values for those variables.. Now I'd like to calculate mean correlations for those variables.. By mean correlations I mean what is the average correlation between two of the variables across 20 countries.. Hope this helps&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 19:54:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52222#M2382</guid>
      <dc:creator>carbs</dc:creator>
      <dc:date>2012-04-17T19:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: mean correlations across 80 variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52223#M2383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you post what you'd expect the output to look like? I'm still a bit confused on the 'across 20 countries' part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You'll definitely need to change your data structure as well, do you already have that done?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 20:13:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52223#M2383</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-04-17T20:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: mean correlations across 80 variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52224#M2384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I didn't open your Excel file for security reasons and the usefulness of mean correlation is foreign to me but the following example might still show you how to calculate just that : the mean of all possible correlations in a set of variables :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;array x{4};&lt;BR /&gt;do country = 1 to 20;&lt;BR /&gt;do i = 1 to 4;&lt;BR /&gt; X{i} = rannor(-1); /* Random numbers for the test */&lt;BR /&gt;end;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc corr data=test outp=testc;&lt;BR /&gt;var X:;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=testc(where=(_TYPE_="CORR")) &lt;BR /&gt; name=VAR &lt;BR /&gt; out=testt(where=(VAR&amp;gt;_NAME_))&lt;BR /&gt; prefix=CORR;&lt;BR /&gt;var X:;&lt;BR /&gt;by _NAME_ notsorted;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title "Mean correlation";&lt;BR /&gt;proc sql;&lt;BR /&gt;select mean(CORR1) as meanCorr from testt;&lt;BR /&gt;drop table testc, testt;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 20:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52224#M2384</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-04-17T20:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: mean correlations across 80 variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52225#M2385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Attached a table that represents the results I want to have as well (the average part).. Haven't yet modified my data, so it's just in the form than in the excel file attached..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Apr 2012 20:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52225#M2385</guid>
      <dc:creator>carbs</dc:creator>
      <dc:date>2012-04-17T20:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: mean correlations across 80 variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52226#M2386</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;proc import datafile='c:\sasforums.xls' out=have dbms=excel replace ;getnames=yes ;run;
data _null_;
dsid=open("have","i");
num=attrn(dsid,"nvars");
do i=2 to num by 5;
 n+1;
 name=catx(',',varname(dsid,1),varname(dsid,i),varname(dsid,i+1),varname(dsid,i+2),varname(dsid,i+3),varname(dsid,i+4) );
 call symputx(cats('name',n),name);
end;
&amp;nbsp; call symputx('n',n);
rc=close(dsid);
run;
%macro stack;
proc sql;
create table want as 
%do i=1 %to &amp;amp;n;
 select &amp;amp;&amp;amp;name&amp;amp;i from have
 %if &amp;amp;i ne &amp;amp;n %then %do; union all&amp;nbsp; %end;
%end;
 ;
quit;
%mend stack;

 %stack
proc sort data=want;by country;run;
proc corr data=want outp=want1(where=(_TYPE_="CORR"))&amp;nbsp; noprint;
&amp;nbsp; by country;
&amp;nbsp; var _numeric_;
run;
data want2(keep=country _name_ name corr);
 set want1;
 array _a{*} _numeric_;
 do i=1 to dim(_a);
&amp;nbsp; if _a{i}=1 then leave;
&amp;nbsp; name=vname(_a{i});corr=_a{i};output;
 end;
run;
proc sql noprint;
 select distinct catt('want2(where=(country="',country,'") rename=(corr=corr_',scan(country,-1),'))') into : list separated by ' '
&amp;nbsp; from want2;
quit;

proc sort data=want2;by country _name_ name;run;
data want3(drop=country);
 merge &amp;amp;list ;
 by _name_ name;
 mean_corr=mean(of corr_:);
run;



&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Apr 2012 08:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52226#M2386</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-04-18T08:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: mean correlations across 80 variables</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52227#M2387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;PGstats and Ksharp, thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Apr 2012 07:29:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/mean-correlations-across-80-variables/m-p/52227#M2387</guid>
      <dc:creator>carbs</dc:creator>
      <dc:date>2012-04-22T07:29:53Z</dc:date>
    </item>
  </channel>
</rss>

