I am looking for a simple way to produce correlations for 5 pairs of variable across 8 groups. I am using SAS 9.4 with SAS/STAT 14.1 and can work on Enterprise Guide or Base SAS.
The code below is what I am using, thanks to others who have posted and appear in Lex Jansen's pages.
But my code produces 135 separate tabs when ods puts it in an excel file.
I tried doing all 10 in one proc corr statement, and that produced a 10 x 10 chart for each of the 8 groups.
I also don't need the 'Simple Statistics' table and am most interested in the correlation only.
Is there a way to get everything (all 5 pairs by 8 groups) into 1 table, or even 1 table for all 5 pairs for each of the 8 groups? I have to perform this with 9 databases, and am a lazy man, which is why I love SAS.
proc corr data = alltoclus;
var var1 var2;
by Grade;
run;
proc corr data = alltoclus;
var var3 var4;
by Grade;
run;
proc corr data = alltoclus;
var var5 var6;
by Grade;
run;
proc corr data = alltoclus;
var var7 var8;
by Grade;
run;
proc corr data = alltoclus;
var var9 var10 ;
by Grade;
run;
http://blogs.sas.com/content/iml/2015/05/26/suppress-ods.html
http://blogs.sas.com/content/iml/2017/01/09/ods-output-any-statistic.html
The above SAS blogs cover capturing and controlling output from a SAS Procedure.
Include all variables at once, store results in a dataset rather than use output and filter the dataset as desired.
http://blogs.sas.com/content/iml/2015/05/26/suppress-ods.html
http://blogs.sas.com/content/iml/2017/01/09/ods-output-any-statistic.html
The above SAS blogs cover capturing and controlling output from a SAS Procedure.
Include all variables at once, store results in a dataset rather than use output and filter the dataset as desired.
Thank you! That makes it easier. I was able to run each pair once, and sort the outputby type and group in excel to get a simple chart of each pair by group. The revised code is below.
proc corr data = alltoclus outp=OutCorr1 NOPRINT;
var var1 var2;
by Grade;
run;
proc corr data = alltoclus outp=OutCorr2 NOPRINT;
var var3 var4;
by Grade;
run;
proc corr data = alltoclus outp=OutCorr3 NOPRINT;
var var5 var6;
by Grade;
run;
proc corr data = alltoclus outp=OutCorr4 NOPRINT;
var var7 var8;
by Grade;
run;
proc corr data = alltoclus outp=OutCorr5 NOPRINT;
var var9 var10 ;
by Grade;
run;
Do you like to use SAS/IML code ? Post your sample data and the output .
Thanks for asking, but the data is protected and would be difficult to mask so it could be posted. I was able to use the links to the articles to find statements I could use to get the results I needed.
SAMPLE data, it needs to show the structure of your data but doesn't have to be real.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.