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
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.)
You could use the BEST= option to get a data set with the top correlations, and then delete any correlations that are <0.7
I have tried using the rank function but how do I delete the correlations?
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.)
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.