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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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