Saving correlations in a list format


To display or save the Pearson and/or Spearman correlations in a list format rather than the matrix format generated by default by PROC CORR, specify the FISHER option together with the PEARSON and/or SPEARMAN options. You can save the correlations in list format using the corresponding ODS tables FisherPearsonCorr and FisherSpearmanCorr. This is illustrated in the following example.

Example

These statements generate the fitness data set to analyze correlations between variables related to fitness.

data Fitness;
   input Age Weight Oxygen RunTime @@;
   datalines;
44 89.47 44.609 11.37    40 75.07 45.313 10.07
44 85.84 54.297  8.65    42 68.15 59.571  8.17
38 89.02 49.874   .      47 77.45 44.811 11.63
40 75.98 45.681 11.95    43 81.19 49.091 10.85
44 81.42 39.442 13.08    38 81.87 60.055  8.63
44 73.03 50.541 10.13    45 87.66 37.388 14.03
45 66.45 44.754 11.12    47 79.15 47.273 10.60
54 83.12 51.855 10.33    49 81.42 49.156  8.95
51 69.63 40.836 10.95    51 77.91 46.672 10.00
48 91.63 46.774 10.25    49 73.37   .    10.08
57 73.37 39.407 12.63    54 79.38 46.080 11.17
52 76.32 45.441  9.63    50 70.87 54.625  8.92
51 67.25 45.118 11.08    54 91.63 39.203 12.88
51 73.71 45.790 10.47    57 59.08 50.545  9.93
49 76.32   .      .      48 61.24 47.920 11.50
52 82.78 47.467 10.50
;

In the following PROC CORR step, the FISHER option is specified along with the PEARSON and SPEARMAN options to estimate the Pearson and Spearman correlations among the variables in the Fitness data set. The FisherPearsonCorr and FisherSpearmanCorr tables are saved as data sets PearsonCorrs and SpearmanCorrs using an ODS OUTPUT statement.

proc corr data=Fitness fisher pearson spearman;
   ods output
       fisherpearsoncorr  = PearsonCorrs
       fisherspearmancorr = SpearmanCorrs;
   run;

The displayed results from PROC CORR include the default matrix format display of the correlations. The FISHER option adds the second pair of tables which use a list format showing pairwise correlations among the variables. This second set of tables is saved as data sets by the ODS OUTPUT statement.

Pearson Correlation Coefficients
Prob > |r| under H0: Rho=0
Number of Observations
 AgeWeightOxygenRunTime
Age
1.00000
 
31
-0.23354
0.2061
31
-0.31474
0.0963
29
0.14478
0.4536
29
Weight
-0.23354
0.2061
31
1.00000
 
31
-0.15358
0.4264
29
0.20072
0.2965
29
Oxygen
-0.31474
0.0963
29
-0.15358
0.4264
29
1.00000
 
29
-0.86843
<.0001
28
RunTime
0.14478
0.4536
29
0.20072
0.2965
29
-0.86843
<.0001
28
1.00000
 
29

 

Spearman Correlation Coefficients
Prob > |r| under H0: Rho=0
Number of Observations
 AgeWeightOxygenRunTime
Age
1.00000
 
31
-0.16152
0.3853
31
-0.20621
0.2832
29
0.09989
0.6062
29
Weight
-0.16152
0.3853
31
1.00000
 
31
-0.06824
0.7250
29
0.13749
0.4769
29
Oxygen
-0.20621
0.2832
29
-0.06824
0.7250
29
1.00000
 
29
-0.80131
<.0001
28
RunTime
0.09989
0.6062
29
0.13749
0.4769
29
-0.80131
<.0001
28
1.00000
 
29

 

Pearson Correlation Statistics (Fisher's z Transformation)
VariableWith VariableNSample CorrelationFisher's zBias AdjustmentCorrelation Estimate95% Confidence Limitsp Value for
H0:Rho=0
AgeWeight31-0.23354-0.23793-0.00389-0.22986-0.5401980.1355220.2080
AgeOxygen29-0.31474-0.32580-0.00562-0.30967-0.6072530.0641160.0967
AgeRunTime290.144780.145810.002590.14225-0.2365880.4835470.4572
WeightOxygen29-0.15358-0.15480-0.00274-0.15090-0.4902890.2282290.4299
WeightRunTime290.200720.203480.003580.19727-0.1824220.5257650.2995
OxygenRunTime28-0.86843-1.32665-0.01608-0.86442-0.935728-0.725221<.0001

 

Spearman Correlation Statistics (Fisher's z Transformation)
VariableWith VariableNSample CorrelationFisher's zBias AdjustmentCorrelation Estimate95% Confidence Limitsp Value for
H0:Rho=0
AgeWeight31-0.16152-0.16295-0.00269-0.15890-0.4858830.2071010.3885
AgeOxygen29-0.20621-0.20921-0.00368-0.20268-0.5298280.1769730.2861
AgeRunTime290.099890.100220.001780.09812-0.2783940.4485000.6093
WeightOxygen29-0.06824-0.06835-0.00122-0.06703-0.4231410.3070180.7275
WeightRunTime290.137490.138370.002460.13508-0.2434800.4779250.4805
OxygenRunTime28-0.80131-1.10227-0.01484-0.79594-0.901360-0.601465<.0001


These statements display the PearsonCorrs and SpearmanCorrs data sets and show the correlations in list format as displayed above. Variable labels, as shown above for the columns, are saved with the data and can be displayed instead of variable names by specifying the LABEL option in PROC PRINT as done in the second PROC PRINT step below.

proc print data=PearsonCorrs;
   id Var WithVar;
   run;
proc print data=SpearmanCorrs label;
   id Var WithVar;
   run;

VarWithVarNObsCorrZValBiasAdjCorrEstLclUclpValue
AgeWeight31-0.23354-0.23793-0.00389-0.22986-0.5401980.1355220.2080
AgeOxygen29-0.31474-0.32580-0.00562-0.30967-0.6072530.0641160.0967
AgeRunTime290.144780.145810.002590.14225-0.2365880.4835470.4572
WeightOxygen29-0.15358-0.15480-0.00274-0.15090-0.4902890.2282290.4299
WeightRunTime290.200720.203480.003580.19727-0.1824220.5257650.2995
OxygenRunTime28-0.86843-1.32665-0.01608-0.86442-0.935728-0.725221<.0001

 

VariableWith VariableNSample CorrelationFisher's zBias AdjustmentCorrelation EstimateLower 95% Confidence
Limit
Upper 95% Confidence
Limit
p Value for
H0:Rho=0
AgeWeight31-0.16152-0.16295-0.00269-0.15890-0.4858830.2071010.3885
AgeOxygen29-0.20621-0.20921-0.00368-0.20268-0.5298280.1769730.2861
AgeRunTime290.099890.100220.001780.09812-0.2783940.4485000.6093
WeightOxygen29-0.06824-0.06835-0.00122-0.06703-0.4231410.3070180.7275
WeightRunTime290.137490.138370.002460.13508-0.2434800.4779250.4805
OxygenRunTime28-0.80131-1.10227-0.01484-0.79594-0.901360-0.601465<.0001