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

I am doing a Proc Corr on a data set But I only want to output the correlations of variables that have absolute correlations higher than 0.7.

I am using SAS Studio this is my code.

 

ods noproctitle;
ods graphics / imagemap=on;

 

proc corr data=_TEMP0.BODYFAT2 pearson nosimple noprob rank outp=work.Corr_stats12;


var Age Weight Height Neck Chest Abdomen Hip Thigh Knee Ankle Biceps Forearm Wrist;
with Age Weight Height Neck Chest Abdomen Hip Thigh Knee Ankle Biceps Forearm Wrist;
run;

 

I tried using the best and rank statement but they aren't really helping me.

 

Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @Avdol and welcome to the SAS Support Communities!

 

If your primary focus is on the printed output (as this is what the options BEST= and RANK only address), you can define and use a numeric format to suppress any low correlation coefficients:

proc format;
value corr07f
-0.7-0.7 = ' '
other    = [8.5];
run;

ods select none;
ods output pearsoncorr=pc;
proc corr data=_TEMP0.BODYFAT2 noprob;
var Age Weight Height Neck Chest Abdomen Hip Thigh Knee Ankle Biceps Forearm Wrist;
run;
ods select all;

proc print data=pc noobs;
format _numeric_ corr07f.;
run;

Maybe you would like to suppress the trivial "1.00000" values on the main diagonal of the correlation matrix as well (provided that you can rule out [almost] perfect correlations elsewhere!). Then just include 1 in the range specification of the format definition:

-0.7-0.7, 1 = ' '

 

(Edit: simplified format definition.)

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

You could use the BEST= option to get a data set with the top correlations, and then delete any correlations that are <0.7

--
Paige Miller
Avdol
Calcite | Level 5

I have tried using the rank function but how do I delete the correlations?

FreelanceReinh
Jade | Level 19

Hello @Avdol and welcome to the SAS Support Communities!

 

If your primary focus is on the printed output (as this is what the options BEST= and RANK only address), you can define and use a numeric format to suppress any low correlation coefficients:

proc format;
value corr07f
-0.7-0.7 = ' '
other    = [8.5];
run;

ods select none;
ods output pearsoncorr=pc;
proc corr data=_TEMP0.BODYFAT2 noprob;
var Age Weight Height Neck Chest Abdomen Hip Thigh Knee Ankle Biceps Forearm Wrist;
run;
ods select all;

proc print data=pc noobs;
format _numeric_ corr07f.;
run;

Maybe you would like to suppress the trivial "1.00000" values on the main diagonal of the correlation matrix as well (provided that you can rule out [almost] perfect correlations elsewhere!). Then just include 1 in the range specification of the format definition:

-0.7-0.7, 1 = ' '

 

(Edit: simplified format definition.)

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1541 views
  • 0 likes
  • 3 in conversation