SlideShare a Scribd company logo
CORR procedure
     2013/3/6
The CORR procedure gives you
• Pearson product-moment correlation
• Rank correlation:
   • Spearman rank-order correlation
   • Kendall’s tau-b coefficient
• Hoeffding’s measure of dependence, D
• Partial correlations for Pearson, Spearman, and Kendall’s
  measurement
Syntax
         PROC CORR <options> ;
               BY variables ;
               FREQ variable ;
指定計算淨相
關時的control     ID variables ;
variable
               PARTIAL variables ;
               VAR variables ;
               WEIGHT variable ;
               WITH variables ;
         RUN; proc corr;
                 var x1 x2;
                 with y1 y2 y3;
               run;
Example 1
data example1;
do i=1 to 200;
        x=10*rannor(100);
        y=x+10*rannor(3);
        output;
end;
drop i;
;

proc corr plots=scatter spearman;
run;
Example 2 (SAS 9.2 guide)
                                              不指定var
                                                  Without control
data Fitness;
input Age Weight Oxygen RunTime @@;
datalines;
        44 89.47 44.609 11.37
        …
;
proc corr data=Fitness plots=matrix(histogram);   With control
var RunTime Weight;
partial Oxygen Age;
run;
Questions ?
Why correlation?
Pearson’s r (for linear correlation)




                                  Var X
Correlation does not “imply” causation
• Tufte:
   • "Empirically observed covariation is a necessary but not sufficient condition for
     causality."
   • "Correlation is not causation but it sure is a hint."
• If Y and X correlate significantly, then one of the following may be true:
   •   X causes Y
   •   Y causes X
   •   X and Y are consequences of a common cause other than X or Y
   •   Just coincidence
• What does “cause” mean actually?
   • It is a philosophical question

More Related Content

More from WenSheng Chang

1129 sas實習課
1129 sas實習課1129 sas實習課
1129 sas實習課
WenSheng Chang
 
Sas tutorial 1018
Sas tutorial 1018Sas tutorial 1018
Sas tutorial 1018
WenSheng Chang
 
Sas tutorial 0524
Sas tutorial 0524Sas tutorial 0524
Sas tutorial 0524
WenSheng Chang
 
Sas tutorial glm2
Sas tutorial glm2Sas tutorial glm2
Sas tutorial glm2
WenSheng Chang
 
Sas tutorial glm1
Sas tutorial glm1Sas tutorial glm1
Sas tutorial glm1
WenSheng Chang
 
SAS 0412
SAS 0412SAS 0412
SAS 0412
WenSheng Chang
 
Sas tutorial 0308
Sas tutorial 0308Sas tutorial 0308
Sas tutorial 0308
WenSheng Chang
 
Sas tutorial 0308
Sas tutorial 0308Sas tutorial 0308
Sas tutorial 0308
WenSheng Chang
 
Science p79 -- polished
Science p79 -- polishedScience p79 -- polished
Science p79 -- polished
WenSheng Chang
 

More from WenSheng Chang (11)

1129 sas實習課
1129 sas實習課1129 sas實習課
1129 sas實習課
 
Sas tutorial 1018
Sas tutorial 1018Sas tutorial 1018
Sas tutorial 1018
 
Sas tutorial 0524
Sas tutorial 0524Sas tutorial 0524
Sas tutorial 0524
 
Sas tutorial glm2
Sas tutorial glm2Sas tutorial glm2
Sas tutorial glm2
 
Sas tutorial glm1
Sas tutorial glm1Sas tutorial glm1
Sas tutorial glm1
 
Regression ci
Regression ciRegression ci
Regression ci
 
SAS 0412
SAS 0412SAS 0412
SAS 0412
 
Sas tutorial 0308
Sas tutorial 0308Sas tutorial 0308
Sas tutorial 0308
 
Sas tutorial 0308
Sas tutorial 0308Sas tutorial 0308
Sas tutorial 0308
 
0925 sas實習課
0925 sas實習課0925 sas實習課
0925 sas實習課
 
Science p79 -- polished
Science p79 -- polishedScience p79 -- polished
Science p79 -- polished
 

Sas corr

  • 1. CORR procedure 2013/3/6
  • 2. The CORR procedure gives you • Pearson product-moment correlation • Rank correlation: • Spearman rank-order correlation • Kendall’s tau-b coefficient • Hoeffding’s measure of dependence, D • Partial correlations for Pearson, Spearman, and Kendall’s measurement
  • 3. Syntax PROC CORR <options> ; BY variables ; FREQ variable ; 指定計算淨相 關時的control ID variables ; variable PARTIAL variables ; VAR variables ; WEIGHT variable ; WITH variables ; RUN; proc corr; var x1 x2; with y1 y2 y3; run;
  • 4. Example 1 data example1; do i=1 to 200; x=10*rannor(100); y=x+10*rannor(3); output; end; drop i; ; proc corr plots=scatter spearman; run;
  • 5. Example 2 (SAS 9.2 guide) 不指定var Without control data Fitness; input Age Weight Oxygen RunTime @@; datalines; 44 89.47 44.609 11.37 … ; proc corr data=Fitness plots=matrix(histogram); With control var RunTime Weight; partial Oxygen Age; run;
  • 8. Pearson’s r (for linear correlation) Var X
  • 9. Correlation does not “imply” causation • Tufte: • "Empirically observed covariation is a necessary but not sufficient condition for causality." • "Correlation is not causation but it sure is a hint." • If Y and X correlate significantly, then one of the following may be true: • X causes Y • Y causes X • X and Y are consequences of a common cause other than X or Y • Just coincidence • What does “cause” mean actually? • It is a philosophical question