turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- How do I get simple pearson correlations for 5 pai...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-12-2017 07:46 PM

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;
```

Accepted Solutions

Solution

04-18-2017
08:00 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-12-2017 08:34 PM

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.

All Replies

Solution

04-18-2017
08:00 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-12-2017 08:34 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-12-2017 09:02 PM

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;
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-13-2017 08:37 AM

Do you like to use SAS/IML code ? Post your sample data and the output .

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-18-2017 08:03 PM

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.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-18-2017 08:46 PM

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