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
SAS Super FREQ
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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1334 views
  • 0 likes
  • 3 in conversation