Sample 25300: CORR Procedure, Chapter 15
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: BPG15R01 */
/* TITLE: CORR Procedure, Chapter 15 */
/* PRODUCT: SAS */
/* SYSTEM: ALL */
/* KEYS: EXAMPLES FROM DOCUMENTATION, */
/* PROCS: CORR */
/* DATA: */
/* */
/* SUPPORT: UPDATE: */
/* REF: SAS Procedures Guide, CHAPTER 15 */
/* MISC: */
/* */
/****************************************************************/
/* Example 1: Skin Data */
options ls=132;
*---Data Courtesy A.C. Linnerud, N.C.State Univ.;
data skinfold;
input chest abdomen arm @@;
cards;
09.0 12.0 3.0 20.0 20.0 7.5 10.0 23.0 6.0 12.0 6.0 5.0
08.5 15.0 3.0 12.0 17.0 4.0 11.0 13.0 6.0 05.0 14.0 3.0
13.0 19.0 3.0 22.0 20.0 6.0 10.5 12.0 3.5 17.0 15.0 4.5
10.0 7.0 4.0 17.0 28.0 5.5 15.0 15.5 3.0 16.0 11.0 3.0
07.0 13.0 2.5 16.0 18.0 3.0 09.0 12.5 5.0 17.5 18.0 3.0
15.5 28.5 5.0 21.0 27.5 6.0 23.0 24.0 6.5 11.5 15.0 3.0
22.5 20.0 4.5 13.0 14.0 4.0 14.0 21.0 2.5 04.0 3.0 2.0
05.5 8.5 3.0 21.0 13.0 9.0 16.0 11.0 3.0 17.5 15.0 4.5
25.0 35.0 6.5 21.0 6.0 3.5 16.5 17.0 4.0 09.5 11.5 2.5
15.0 19.0 4.0 13.5 6.5 3.5 16.0 15.0 3.0 26.0 38.0 4.0
12.5 20.0 3.0 05.0 7.5 3.5 12.0 15.0 3.5 15.0 13.0 4.5
17.0 19.5 5.0 16.0 20.0 5.5 09.0 4.0 2.0 19.0 12.0 3.0
16.0 17.5 6.0 14.5 14.5 4.0
;
proc corr pearson spearman kendall hoeffding;
var chest abdomen arm;
title 'Spearman''s rho, Kendall''s tau-b, Pearson''s & Hoeffding';
run;
proc corr data=skinfold csscp cov;
var chest abdomen;
partial arm;
title 'Partial Correlation Matrix';
run;
proc corr data=skinfold cov nomiss alpha outp=corrout;
var chest abdomen arm;
title 'Covariances and Correlations';
run;
proc print data=corrout;
title2 'Output Dataset from PROC CORR';
run;
/* Example 2: Iris Setosa Data */
data setosa;
title 'Fisher (1936) Iris Setosa Data';
input sepallen sepalwid petallen petalwid @@;
label sepallen='Sepal Length in mm.'
sepalwid='Sepal Width in mm.'
petallen='Petal Length in mm.'
petalwid='Petal Width in mm.';
cards;
50 33 14 02 46 34 14 03 46 36 . 02
51 33 17 05 55 35 13 02 48 31 16 02
52 34 14 02 49 36 14 01 44 32 13 02
50 35 16 06 44 30 13 02 47 32 16 02
48 30 14 03 51 38 16 02 48 34 19 02
50 30 16 02 50 32 12 02 43 30 11 .
58 40 12 02 51 38 19 04 49 30 14 02
51 35 14 02 50 34 16 04 46 32 14 02
57 44 15 04 50 36 14 02 54 34 15 04
52 41 15 . 55 42 14 02 49 31 15 02
54 39 17 04 50 34 15 02 44 29 14 02
47 32 13 02 46 31 15 02 51 34 15 02
50 35 13 03 49 31 15 01 54 37 15 02
54 39 13 04 51 35 14 03 48 34 16 02
48 30 14 01 45 23 13 03 57 38 17 03
51 38 15 03 54 34 17 02 51 37 15 04
52 35 15 02 53 37 15 02
;
proc corr data=setosa nomiss nosimple cov;
var sepallen sepalwid;
with petallen petalwid;
title2 'Rectangular COV and CORR Matrices';
run;
proc corr data=setosa csscp nosimple cov;
title2 'CSSCP and COV Matrices from Data Set with Missing Values';
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Example 1: Skin Data
Spearman's rho, Kendall's tau-b, Pearson's & Hoeffding
Correlation Analysis
3 'VAR' Variables: CHEST ABDOMEN ARM
Simple Statistics
Variable N Mean Std Dev Median Minimum Maximum
CHEST 50 14.410000 5.256376 15.000000 4.000000 26.000000
ABDOMEN 50 16.010000 7.190903 15.000000 3.000000 38.000000
ARM 50 4.150000 1.485474 4.000000 2.000000 9.000000
Pearson Correlation Coefficients / Prob > |R| under Ho: Rho=0 / N = 50
CHEST ABDOMEN ARM
CHEST 1.00000 0.61986 0.52973
0.0 0.0001 0.0001
ABDOMEN 0.61986 1.00000 0.42925
0.0001 0.0 0.0019
ARM 0.52973 0.42925 1.00000
0.0001 0.0019 0.0
Spearman Correlation Coefficients / Prob > |R| under Ho: Rho=0 / N = 50
CHEST ABDOMEN ARM
CHEST 1.00000 0.54825 0.51761
0.0 0.0001 0.0001
ABDOMEN 0.54825 1.00000 0.45687
0.0001 0.0 0.0009
ARM 0.51761 0.45687 1.00000
0.0001 0.0009 0.0
Kendall Tau b Correlation Coefficients / Prob > |R| under Ho: Rho=0 / N = 50
CHEST ABDOMEN ARM
CHEST 1.00000 0.41246 0.38974
0.0 0.0001 0.0002
ABDOMEN 0.41246 1.00000 0.33048
0.0001 0.0 0.0015
ARM 0.38974 0.33048 1.00000
0.0002 0.0015 0.0
Hoeffding Dependence Coefficients / Prob > D under Ho: D=0 / N = 50
CHEST ABDOMEN ARM
CHEST 0.91768 0.09636 0.06797
0.0001 0.0001 0.0006
ABDOMEN 0.09636 0.89934 0.04966
0.0001 0.0001 0.0030
ARM 0.06797 0.04966 0.69550
0.0006 0.0030 0.0001
Partial Correlation Matrix
Correlation Analysis
1 'PARTIAL' Variables: ARM
2 'VAR' Variables: CHEST ABDOMEN
Corrected Sum-of-Squares and Crossproducts
ARM CHEST ABDOMEN
ARM 108.125000 202.675000 224.675000
CHEST 202.675000 1353.845000 1148.045000
ABDOMEN 224.675000 1148.045000 2533.745000
Partial Corrected Sum-of-Squares and Crossproducts
CHEST ABDOMEN
CHEST 973.940671 726.902751
ABDOMEN 726.902751 2066.888532
Partial Covariance Matrix DF = 48
CHEST ABDOMEN
CHEST 20.29043064 15.14380732
ABDOMEN 15.14380732 43.06017775
Simple Statistics
Partial Partial
Variable N Mean Std Dev Sum Minimum Maximum Variance Std Dev
ARM 50 4.150000 1.485474 207.500000 2.000000 9.000000 . .
CHEST 50 14.410000 5.256376 720.500000 4.000000 26.000000 20.290431 4.504490
ABDOMEN 50 16.010000 7.190903 800.500000 3.000000 38.000000 43.060178 6.562025
Pearson Partial Correlation Coefficients / Prob > |R| under Ho: Partial Rho=0 / N = 50
CHEST ABDOMEN
CHEST 1.00000 0.51233
0.0 0.0002
ABDOMEN 0.51233 1.00000
0.0002 0.0
Covariances and Correlations
Correlation Analysis
3 'VAR' Variables: CHEST ABDOMEN ARM
Covariance Matrix DF = 49
CHEST ABDOMEN ARM
CHEST 27.62948980 23.42948980 4.13622449
ABDOMEN 23.42948980 51.70908163 4.58520408
ARM 4.13622449 4.58520408 2.20663265
Simple Statistics
Variable N Mean Std Dev Sum Minimum Maximum
CHEST 50 14.410000 5.256376 720.500000 4.000000 26.000000
ABDOMEN 50 16.010000 7.190903 800.500000 3.000000 38.000000
ARM 50 4.150000 1.485474 207.500000 2.000000 9.000000
Covariances and Correlations
Correlation Analysis
Cronbach Coefficient Alpha
for RAW variables : 0.661328
for STANDARDIZED variables: 0.769205
Raw Variables Std. Variables
Deleted Correlation Correlation
Variable with Total Alpha with Total Alpha
----------------------------------------------------------------------------
CHEST 0.660261 0.290727 0.679943 0.600665
ABDOMEN 0.631090 0.434152 0.599789 0.692578
ARM 0.522633 0.742629 0.532788 0.765325
Pearson Correlation Coefficients / Prob > |R| under Ho: Rho=0 / N = 50
CHEST ABDOMEN ARM
CHEST 1.00000 0.61986 0.52973
0.0 0.0001 0.0001
ABDOMEN 0.61986 1.00000 0.42925
0.0001 0.0 0.0019
ARM 0.52973 0.42925 1.00000
0.0001 0.0019 0.0
Covariances and Correlations
Output Dataset from PROC CORR
OBS _TYPE_ _NAME_ CHEST ABDOMEN ARM
1 COV CHEST 27.6295 23.4295 4.1362
2 COV ABDOMEN 23.4295 51.7091 4.5852
3 COV ARM 4.1362 4.5852 2.2066
4 MEAN 14.4100 16.0100 4.1500
5 STD 5.2564 7.1909 1.4855
6 N 50.0000 50.0000 50.0000
7 RAWALPHA 0.6613 0.6613 0.6613
8 STDALPHA 0.7692 0.7692 0.7692
9 RAWALDEL 0.2907 0.4342 0.7426
10 STDALDEL 0.6007 0.6926 0.7653
11 RAWCTDEL 0.6603 0.6311 0.5226
12 STDCTDEL 0.6799 0.5998 0.5328
13 CORR CHEST 1.0000 0.6199 0.5297
14 CORR ABDOMEN 0.6199 1.0000 0.4292
15 CORR ARM 0.5297 0.4292 1.0000
Example 2: Iris Setosa Data
Fisher (1936) Iris Setosa Data
Rectangular COV and CORR Matrices
Correlation Analysis
2 'WITH' Variables: PETALLEN PETALWID
2 'VAR' Variables: SEPALLEN SEPALWID
Covariance Matrix DF = 46
SEPALLEN SEPALWID
PETALLEN 0.729417206 1.041628122 Petal Length in mm.
PETALWID 0.882978723 1.091581869 Petal Width in mm.
Pearson Correlation Coefficients / Prob > |R| under Ho: Rho=0 / N = 47
SEPALLEN SEPALWID
PETALLEN 0.13690 0.17945
Petal Length in mm. 0.3588 0.2275
PETALWID 0.24863 0.28214
Petal Width in mm. 0.0919 0.0547
Fisher (1936) Iris Setosa Data
CSSCP and COV Matrices from Data Set with Missing Values
Correlation Analysis
4 'VAR' Variables: SEPALLEN SEPALWID PETALLEN PETALWID
Corrected Sum-of-Squares and Crossproducts
CSSCP('W','V') / CSS('W') / CSS('V')
'W'\'V' SEPALLEN SEPALWID PETALLEN PETALWID
SEPALLEN 608.8200000 486.1600000 61.0000000 42.8333333
Sepal Length in mm. 608.8200000 608.8200000 592.0000000 554.6666667
608.8200000 704.0800000 126.0000000 49.9791667
SEPALWID 486.1600000 704.0800000 65.4285714 49.2708333
Sepal Width in mm. 704.0800000 704.0800000 701.0612245 640.4791667
608.8200000 704.0800000 126.0000000 49.9791667
PETALLEN 61.0000000 65.4285714 126.0000000 22.3191489
Petal Length in mm. 126.0000000 126.0000000 126.0000000 111.8723404
592.0000000 701.0612245 126.0000000 49.7021277
PETALWID 42.8333333 49.2708333 22.3191489 49.9791667
Petal Width in mm. 49.9791667 49.9791667 49.7021277 49.9791667
554.6666667 640.4791667 111.8723404 49.9791667
Variances and Covariances
COV('W','V') / VAR('W') / VAR('V') / DF('W','V')
'W'\'V' SEPALLEN SEPALWID PETALLEN PETALWID
SEPALLEN 12.42489796 9.92163265 1.27083333 0.91134752
Sepal Length in mm. 12.42489796 12.42489796 12.33333333 11.80141844
12.42489796 14.36897959 2.62500000 1.06338652
49 49 48 47
SEPALWID 9.92163265 14.36897959 1.36309524 1.04831560
Sepal Width in mm. 14.36897959 14.36897959 14.60544218 13.62721631
12.42489796 14.36897959 2.62500000 1.06338652
49 49 48 47
PETALLEN 1.27083333 1.36309524 2.62500000 0.48519889
Petal Length in mm. 2.62500000 2.62500000 2.62500000 2.43200740
12.33333333 14.60544218 2.62500000 1.08048104
48 48 48 46
PETALWID 0.91134752 1.04831560 0.48519889 1.06338652
Petal Width in mm. 1.06338652 1.06338652 1.08048104 1.06338652
11.80141844 13.62721631 2.43200740 1.06338652
47 47 46 47
Fisher (1936) Iris Setosa Data
CSSCP and COV Matrices from Data Set with Missing Values
Correlation Analysis
Pearson Correlation Coefficients / Prob > |R| under Ho: Rho=0 / Number of Observations
SEPALLEN SEPALWID PETALLEN PETALWID
SEPALLEN 1.00000 0.74255 0.22335 0.25726
Sepal Length in mm. 0.0 0.0001 0.1229 0.0775
50 50 49 48
SEPALWID 0.74255 1.00000 0.22014 0.27539
Sepal Width in mm. 0.0001 0.0 0.1285 0.0582
50 50 49 48
PETALLEN 0.22335 0.22014 1.00000 0.29932
Petal Length in mm. 0.1229 0.1285 0.0 0.0410
49 49 49 47
PETALWID 0.25726 0.27539 0.29932 1.00000
Petal Width in mm. 0.0775 0.0582 0.0410 0.0
48 48 47 48
These samples are from the "SAS Procedures Guide, Version 6", Chapter 15.
For additional information on the samples refer to this book.
| Type: | Sample |
| Topic: | Analytics ==> Nonparametric Analysis Analytics ==> Descriptive Statistics SAS Reference ==> Procedures ==> CORR
|
| Date Modified: | 2005-06-18 03:00:00 |
| Date Created: | 2005-05-23 13:44:28 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |