BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

Following is the code I would be running :
proc corr;
var &var;
by segment;
run;

I am trying to find out which of my variables are highly correlated then store them in a dataset ...

Output data set I am interested in should show me something like:

Segment_Name Variables_name Correlation_value
a x1, x2 0.85
a x5, x3 0.92
b x2, x3 0.86

Is there any way I could work around in SAS and get this kind of output??
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
ODS OUTPUT can create output datasets from SAS procedures, such as PROC CORR. However, PROC CORR has the OUTP= option, which will output just the Pearson Correlations to a dataset, as described here:
http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_corr_sec...
http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_corr_sec...

If you review the output from this program, you may find that it is close to what you want.

cynthia
[pre]
** 1) OUTP method;
** if SASHELP.CLASS is sorted by AGE, the BY variable.;
proc corr data=sashelp.class outp=work.outpmethod;
var height weight;
by age;
run;

proc print data=work.outpmethod;
run;

[/pre]
darrylovia
Quartz | Level 8
Hello Lisa,
I prefer the ODS output since you get both the correlation coefficient and the p-Values in a single output dataset.

See my example below using the SASHELP.CLASS table.

proc sort data=sashelp.class out=class;
by sex;
run;

ods output PearsonCorr=Pearson_Corr ;
proc corr data=class Pearson;
var _numeric_;
by sex;
run;

Below is a link to all the ODS tables that can be produced from PROC CORR.
http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_corr_sec...

D

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1619 views
  • 0 likes
  • 3 in conversation