The CORR Procedure

Example 2.7 Saving Correlations in an Output Data Set

The following statements compute Pearson correlations:

title 'Correlations for a Fitness and Exercise Study';
proc corr data=Fitness nomiss outp=CorrOutp;
   var weight oxygen runtime;
run;

The NOMISS option excludes observations with missing values of the VAR statement variables from the analysis—that is, the same set of 28 observations is used to compute the correlation for each pair of variables. The OUTP= option creates an output data set named CorrOutp that contains the Pearson correlation statistics.

"Pearson Correlation Coefficients" table in Output 2.7.1 displays the correlation and the p-value under the null hypothesis of zero correlation.

Output 2.7.1: Pearson Correlation Coefficients

Correlations for a Fitness and Exercise Study

The CORR Procedure

Pearson Correlation Coefficients, N = 28
Prob > |r| under H0: Rho=0
  Weight Oxygen RunTime
Weight
1.00000
 
-0.18419
0.3481
0.19505
0.3199
Oxygen
-0.18419
0.3481
1.00000
 
-0.86843
<.0001
RunTime
0.19505
0.3199
-0.86843
<.0001
1.00000
 



The following statements display (in Output 2.7.2) the output data set:

title 'Output Data Set from PROC CORR';
proc print data=CorrOutp noobs;
run;

Output 2.7.2: OUTP= Data Set with Pearson Correlations

Output Data Set from PROC CORR

_TYPE_ _NAME_ Weight Oxygen RunTime
MEAN   77.2168 47.1327 10.6954
STD   8.4495 5.5535 1.4127
N   28.0000 28.0000 28.0000
CORR Weight 1.0000 -0.1842 0.1950
CORR Oxygen -0.1842 1.0000 -0.8684
CORR RunTime 0.1950 -0.8684 1.0000



The output data set has the default type CORR and can be used as an input data set for regression or other statistical procedures. For example, the following statements request a regression analysis using CorrOutp, without reading the original data in the REG procedure:

title 'Input Type CORR Data Set from PROC REG';
proc reg data=CorrOutp;
   model runtime= weight oxygen;
run;

The following statements generate the same results as the preceding statements:

proc reg data=Fitness;
   model runtime= weight oxygen;
run;