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 |
|---|
| | Age | Weight | Oxygen | RunTime |
|---|
| Age |
|
|
|
|
|---|
| Weight |
|
|
|
|
|---|
| Oxygen |
|
|
|
|
|---|
| RunTime |
|
|
|
|
|---|
Spearman Correlation Coefficients Prob > |r| under H0: Rho=0 Number of Observations |
|---|
| | Age | Weight | Oxygen | RunTime |
|---|
| Age |
|
|
|
|
|---|
| Weight |
|
|
|
|
|---|
| Oxygen |
|
|
|
|
|---|
| RunTime |
|
|
|
|
|---|
| Pearson Correlation Statistics (Fisher's z Transformation) |
|---|
| Variable | With Variable | N | Sample Correlation | Fisher's z | Bias Adjustment | Correlation Estimate | 95% Confidence Limits | p Value for H0:Rho=0 |
|---|
| Age | Weight | 31 | -0.23354 | -0.23793 | -0.00389 | -0.22986 | -0.540198 | 0.135522 | 0.2080 |
|---|
| Age | Oxygen | 29 | -0.31474 | -0.32580 | -0.00562 | -0.30967 | -0.607253 | 0.064116 | 0.0967 |
|---|
| Age | RunTime | 29 | 0.14478 | 0.14581 | 0.00259 | 0.14225 | -0.236588 | 0.483547 | 0.4572 |
|---|
| Weight | Oxygen | 29 | -0.15358 | -0.15480 | -0.00274 | -0.15090 | -0.490289 | 0.228229 | 0.4299 |
|---|
| Weight | RunTime | 29 | 0.20072 | 0.20348 | 0.00358 | 0.19727 | -0.182422 | 0.525765 | 0.2995 |
|---|
| Oxygen | RunTime | 28 | -0.86843 | -1.32665 | -0.01608 | -0.86442 | -0.935728 | -0.725221 | <.0001 |
|---|
| Spearman Correlation Statistics (Fisher's z Transformation) |
|---|
| Variable | With Variable | N | Sample Correlation | Fisher's z | Bias Adjustment | Correlation Estimate | 95% Confidence Limits | p Value for H0:Rho=0 |
|---|
| Age | Weight | 31 | -0.16152 | -0.16295 | -0.00269 | -0.15890 | -0.485883 | 0.207101 | 0.3885 |
|---|
| Age | Oxygen | 29 | -0.20621 | -0.20921 | -0.00368 | -0.20268 | -0.529828 | 0.176973 | 0.2861 |
|---|
| Age | RunTime | 29 | 0.09989 | 0.10022 | 0.00178 | 0.09812 | -0.278394 | 0.448500 | 0.6093 |
|---|
| Weight | Oxygen | 29 | -0.06824 | -0.06835 | -0.00122 | -0.06703 | -0.423141 | 0.307018 | 0.7275 |
|---|
| Weight | RunTime | 29 | 0.13749 | 0.13837 | 0.00246 | 0.13508 | -0.243480 | 0.477925 | 0.4805 |
|---|
| Oxygen | RunTime | 28 | -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;
| Var | WithVar | NObs | Corr | ZVal | BiasAdj | CorrEst | Lcl | Ucl | pValue |
|---|
| Age | Weight | 31 | -0.23354 | -0.23793 | -0.00389 | -0.22986 | -0.540198 | 0.135522 | 0.2080 |
|---|
| Age | Oxygen | 29 | -0.31474 | -0.32580 | -0.00562 | -0.30967 | -0.607253 | 0.064116 | 0.0967 |
|---|
| Age | RunTime | 29 | 0.14478 | 0.14581 | 0.00259 | 0.14225 | -0.236588 | 0.483547 | 0.4572 |
|---|
| Weight | Oxygen | 29 | -0.15358 | -0.15480 | -0.00274 | -0.15090 | -0.490289 | 0.228229 | 0.4299 |
|---|
| Weight | RunTime | 29 | 0.20072 | 0.20348 | 0.00358 | 0.19727 | -0.182422 | 0.525765 | 0.2995 |
|---|
| Oxygen | RunTime | 28 | -0.86843 | -1.32665 | -0.01608 | -0.86442 | -0.935728 | -0.725221 | <.0001 |
|---|
| Variable | With Variable | N | Sample Correlation | Fisher's z | Bias Adjustment | Correlation Estimate | Lower 95% Confidence Limit | Upper 95% Confidence Limit | p Value for H0:Rho=0 |
|---|
| Age | Weight | 31 | -0.16152 | -0.16295 | -0.00269 | -0.15890 | -0.485883 | 0.207101 | 0.3885 |
|---|
| Age | Oxygen | 29 | -0.20621 | -0.20921 | -0.00368 | -0.20268 | -0.529828 | 0.176973 | 0.2861 |
|---|
| Age | RunTime | 29 | 0.09989 | 0.10022 | 0.00178 | 0.09812 | -0.278394 | 0.448500 | 0.6093 |
|---|
| Weight | Oxygen | 29 | -0.06824 | -0.06835 | -0.00122 | -0.06703 | -0.423141 | 0.307018 | 0.7275 |
|---|
| Weight | RunTime | 29 | 0.13749 | 0.13837 | 0.00246 | 0.13508 | -0.243480 | 0.477925 | 0.4805 |
|---|
| Oxygen | RunTime | 28 | -0.80131 | -1.10227 | -0.01484 | -0.79594 | -0.901360 | -0.601465 | <.0001 |
|---|