Programming the statistical procedures from SAS

Help on Proc Corr

Reply
N/A
Posts: 0

Help on Proc Corr

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??
SAS Super FREQ
Posts: 8,781

Re: Help on Proc Corr

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]
Frequent Contributor
Posts: 139

Re: Help on Proc Corr

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
Ask a Question
Discussion stats
  • 2 replies
  • 127 views
  • 0 likes
  • 3 in conversation