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

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Re: different types of correlations using proc cor...

Topic Options

- 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
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-29-2018 12:07 PM

Using this:

```
ods exclude all;
proc corr data=SomeInputData;
ods output PearsonCorr=SomeOutputData;
var SomeMeasure;
by SomeCategory;
run;
ods exclude none;
```

Gives me the Pearson correlation including p values. Can I also obtain the Kendall rank, Spearman and Point-Biserial correlation using proc corr (or other procs)?

Accepted Solutions

Solution

01-30-2018
10:44 AM

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

Posted in reply to csetzkorn

01-30-2018 05:43 AM

The answer is the same as last time you asked, but replace the word 'Pearson' by 'Spearman.'.

See https://communities.sas.com/t5/SAS-Procedures/add-p-values-to-output-dataset-of-proc-corr/m-p/430081

If I may suggest, it will be easier to ask and answer questions if you post code that uses one of the built-in SAS data sets in the SASHELP libref. See also the SAS/STAT data sets.

My favorites in Sashelp are Class,Cars, Heart, and Iris. You can use PROC CONTENTS to see the variables and PROC PRINT (OBS=5) to see a few records.For example, here is your solution using Cars:

```
proc sort data=sashelp.cars out=cars;
by origin;
run;
ods exclude all;
proc corr data=cars Spearman;
ods output SpearmanCorr=P;
var mpg_city weight;
by Origin;
run;
ods exclude none;
proc print data=P; run;
```

All Replies

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

Posted in reply to csetzkorn

01-29-2018 12:09 PM

Somewhat, see the options on the PROC CORR statement in the documentation.

I don't know if Point-Biserial correlation is available.

Highlighted
## Re: different types of correlations using proc corr

Options

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

Posted in reply to csetzkorn

01-29-2018 12:11 PM

Did you SAS install not come with ANY online help or documentation?

You can request Fisher Hoeffding Kendal Pearson Polychoric Polyserial and Spearman correlations with proc corr.

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

Posted in reply to ballardw

01-29-2018 01:34 PM

To follow-up on Ballardw's comment, all documentation is posted online. Here are some URLs that I have bookmarked for easy reference:

Most Base SAS Procedures: CONTENTS, COMPARE, MEANS, RANK,...

Base SAS Statistical Procedures: CORR, FREQ, and UNIVARIATE <== relevant for current question

DATA Step Functions and Call Routines

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

Posted in reply to Rick_SAS

01-30-2018 04:28 AM

Hi all,

Thanks and apologies for not doing enough research. I wrote this on the mobile last night and did not have reliable Internet access.

I am currently using this code to obtain the Spearman correlation:

```
ods exclude all;
PROC CORR DATA=SomeInputData SPEARMAN out=SomeOutputData;
var SomeMeasure;
by SomeCategory;
RUN;
ods exclude none;
```

Is there a way to get p values similarly to the Pearson correlation code in my original question?

Solution

01-30-2018
10:44 AM

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

Posted in reply to csetzkorn

01-30-2018 05:43 AM

The answer is the same as last time you asked, but replace the word 'Pearson' by 'Spearman.'.

See https://communities.sas.com/t5/SAS-Procedures/add-p-values-to-output-dataset-of-proc-corr/m-p/430081

If I may suggest, it will be easier to ask and answer questions if you post code that uses one of the built-in SAS data sets in the SASHELP libref. See also the SAS/STAT data sets.

My favorites in Sashelp are Class,Cars, Heart, and Iris. You can use PROC CONTENTS to see the variables and PROC PRINT (OBS=5) to see a few records.For example, here is your solution using Cars:

```
proc sort data=sashelp.cars out=cars;
by origin;
run;
ods exclude all;
proc corr data=cars Spearman;
ods output SpearmanCorr=P;
var mpg_city weight;
by Origin;
run;
ods exclude none;
proc print data=P; run;
```