Contributor
Posts: 27

# Scatter Plot- Tetrachoric Corr

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!

Super User
Posts: 20,725

## Re: Scatter Plot- Tetrachoric Corr

Proc CORR - check default plots first?

Contributor
Posts: 27

## Re: Scatter Plot- Tetrachoric Corr

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!!
SAS Super FREQ
Posts: 3,835

## Re: Scatter Plot- Tetrachoric Corr

[ Edited ]

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;

``````

Contributor
Posts: 27

## Re: Scatter Plot- Tetrachoric Corr

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!
SAS Super FREQ
Posts: 3,835

## Re: Scatter Plot- Tetrachoric Corr

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

http://support.sas.com/documentation/cdl/en/procstat/68142/HTML/default/viewer.htm#procstat_corr_syn...

Contributor
Posts: 27

## Re: Scatter Plot- Tetrachoric Corr

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

SAS Super FREQ
Posts: 3,835

## Re: Scatter Plot- Tetrachoric Corr

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.

Discussion stats
• 7 replies
• 190 views
• 0 likes
• 3 in conversation