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
- /
- Scatter Plot- Tetrachoric Corr

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

12-14-2016 11:31 AM

Hi

I want to create a scatter plot (or any graphs that are visiually appealing!) of the correlation matrix between two dichotomous variables in my dataset. I used the plrr option in PROC FREQ to get the basic statistics including tetrachoric correlation and OR. I've never created any graphs in SAS so any help would be greatly appreciated!

Thank you!

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

12-14-2016 01:04 PM

Proc CORR - check default plots first?

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

12-14-2016 01:15 PM

Hello.Thank you for your reply! My question is how do I specify the tetrachoric option in the PROC CORR (i.e. GPLOT)? I've used the tetrachoric in PROC FREQ in lieu of PROC CORR so I wasn't sure how to generate a plot/graph in this case. Hope this makes sense!!

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

12-14-2016 02:28 PM - edited 12-14-2016 02:31 PM

Geting PROC CORR to generate polychoric correlations in a data set and then plotting them is no different than for ordinary Pearson correlations. See @ChrisHemedinger's blog post for a discussion in SAS 9.3.

Since you didn't provide data, here is some sample data to play with. The data is from the SAS Sample on how to create a polychoric matrix.

```
data norm;
length id $ 8;
array x{5} x1-x5;
do n=1 to 20;
do i=1 to 5;
x{i}=rannor(238423)*3+10;
end;
id=cats(n,'');
keep id x1-x5;
output;
end;
run;
proc rank data=norm out=ordinal groups=5;
var x1-x5;
run;
```

There are three main steps to the analysis. The graph is created by using the HEATMAP statement in PROC SGPLOT, which was introduced in SAS 9.4m3.:

```
/* 1. Create OUT data set that contains correlations in matrix form */
proc corr data=ordinal polychoric outplc=OUT;
var x1-x5;
run;
/* 2. transpose from wide to long */
proc transpose data=Out(where=(_TYPE_="CORR"))
name=ID out=Have(rename=(COL1=Value) drop=_LABEL_);
var x1-x5;
by _NAME_;
run;
/* 3. Plot with scatter plot or heat map */
title "Polychoric Correlations";
proc sgplot data=Have;
heatmap x=_NAME_ y=ID / colorresponse=Value discretex discretey;
yaxis reverse display=(nolabel);
xaxis display=(nolabel);
run;
```

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

12-14-2016 03:18 PM

Hi Rick,

Thank you for your reply- Quick question in the Step 1 process:

proc corr data=ordinal polychoric outplc=OUT;

var x1-x5;

run;

I am not sure what 'outplc" does, did you mean outp? Also having 'polychoric' in PROC CORR gave me an error message- any suggestion?

Thank you!

Thank you for your reply- Quick question in the Step 1 process:

proc corr data=ordinal polychoric outplc=OUT;

var x1-x5;

run;

I am not sure what 'outplc" does, did you mean outp? Also having 'polychoric' in PROC CORR gave me an error message- any suggestion?

Thank you!

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

12-14-2016 05:32 PM

Here is a link to the documentation for the PROC CORR statement:

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

12-14-2016 09:58 PM

Thanks for the link! I guess the polychoric option didn't work because I am using SAS 9.3? Not sure. Anyway, thank you!

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

12-15-2016 05:50 AM

The documentation says

"In the Second Maintenance Release of SAS 9.3, the POLYCHORIC option has been added to the PROC CORR statement."

Therefore you need 9.3m2to use the opiton. SAS 9.3m2 was released in Aug 2012. I strongly encourage you to upgrade to SAS 9.4. You are also missing a HUGE number of new features, especially related to ODS graphics and the SGPLOT procedure. I mentioned the HEATMAP statement, but that is just one instance.