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.)

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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