BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
plzsiga
Obsidian | Level 7

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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. 

View solution in original post

5 REPLIES 5
Reeza
Super User

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. 

plzsiga
Obsidian | Level 7

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;
Ksharp
Super User
Do you like to use SAS/IML code ?

Post your sample data and the output .


plzsiga
Obsidian | Level 7

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.

Reeza
Super User

SAMPLE data, it needs to show the structure of your data but doesn't have to be real. 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 5 replies
  • 1376 views
  • 2 likes
  • 3 in conversation