Successfully reported this slideshow.
Upcoming SlideShare
×

# Sas tutorial 0308

612 views

Published on

Published in: Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

### Sas tutorial 0308

1. 1. SAS tutorial 0308: Correlation
2. 2. PROC CORRBY, VAR, WEIGHT FREQ – 指定各觀察值的出現次數。 – 指定變項用以描述資料。 ID – 指定要以那個變項為基準計算淨 PARTIAL 相關。 WITH – 指定變項，和用VAR指定的變項作 相關。
3. 3. 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 ......;ods graphics on;proc corr data=Fitness plots=matrix(histogram);run;ods graphics off;
4. 4. proc corr;var x1 x2;with y1 y2 y3;run;
5. 5. data Setosa;input SepalLength SepalWidth PetalLength PetalWidth @@;label sepallength=Sepal Length in mm. sepalwidth=Sepal Width in mm. petallength=Petal Length in mm. petalwidth=Petal Width in mm.;datalines; 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 48 30 14 01 45 23 13 03 57 38 17 03 51 38 15 03 54 34 17 02 51 37 15 04 ......;ods graphics on;title Fisher (1936) Iris Setosa Data;proc corr data=Setosa sscp cov plots=scatter;var sepallength sepalwidth;with petallength petalwidth;run;ods graphics off;
6. 6. PROC CORR statements-1
7. 7. PROC CORR statements-2
8. 8. CheckDisplay scatter plots.Compute Pearson’s correlation coefficient. Fisher’s z transformation. Kendall’s tau. Spearman rank-order correlation. Partial correlation. Cronbach’s alpha.Handle missing values.Variance/covariance matrix.
9. 9. Review• PROC FREQ• PROC STANDARD
10. 10. Chi-square distribution
11. 11. Example• Q: 男性跟女性同意婚前性行為的傾向有差 別嗎？
12. 12. Agree No opinion Disagree TotalMale 279 73 225 577Female 175 47 201 423Total 454 120 426 1000 Why?Expected Agree No opinion DisagreeMale 261.96 69.24 245.80Female 192.04 50.76 180.20 Why? Why?
13. 13. SAS CodeDATA ex1;DO i=1 to 2; PROC PRINT DATA=ex1; DO j=1 to 3; INPUT x @@; PROC FREQ DATA=ex1; OUTPUT; TABLES i*j/CHISQ; END; WEIGHT x;END; RUN;DATALINES;279 73 225175 47 201;
14. 14. Results這些指標各代表什麼意義？
15. 15. 想一下• Q1: 為什麼 Fisher’s exact test 是 “Exact”？• Q2: Binomial counts 可以跑Chi-square test嗎？• Q3: 找一組2*2的資料，比較以下兩者 output的差別。 PROC FREQ PROC FREQ DATA=AAA; DATA=AAA; EXACT FISHER; EXACT CHISQ; ...; ...; 怎麼算出來的?
16. 16. PROC STANDARD • 把分數調成平均80， 標準差10的常態分配。
17. 17. SAS codePROC IMPORT OUT=EX2DATAFILE="C:UsersuserDesktopQUIZ.txt"DBMS=dlm REPLACE;GETNAMES=YES; 從文字檔讀資料DELIMITER=09x;PROC STANDARD DATA=ex2 MEAN=80 STD=10 OUT=ex3 PRINT; 標準化VAR Score;PROC PRINT DATA= ex2;PROC PRINT DATA= ex3;RUN;
18. 18. Results