sas實習111229

22
統計學、資料分析 SAS實習課 12/29 Email: [email protected] Office hour: Mon. 13:00~14:00

Upload: visual-cognition-and-modeling-lab

Post on 03-Jul-2015

1.281 views

Category:

Health & Medicine


3 download

TRANSCRIPT

Page 1: SAS實習111229

統計學、資料分析

SAS實習課 12/29

胡 元

Email: [email protected]

Office hour: Mon. 13:00~14:00

Page 2: SAS實習111229

PROC FREQ Statement

PROC FREQ <options> ;

BY Statement

EXACT Statement

OUTPUT Statement

TABLES Statement

TEST Statement

WEIGHT Statement

Page 3: SAS實習111229

PROC FREQ <options> ;

TABLES requests </ options> ;

Page 4: SAS實習111229

Requests 對應的output

tables A*(B C); A*B、A*C

tables (A B)*(C D); A*C、B*C、A*D、B*D

tables (A B C)*D; A*D、B*D、C*D

tables A – – C; A、B、C

tables (A – – C)*D; A*D、B*D、C*D

Page 5: SAS實習111229

1. data a;

2. input childabuse $ adultabuse $ count;

3. datalines;

4. 0 N 512

5. 0 Y 54

6. 1 N 227

7. 1 Y 37

8. 2 N 59

9. 2 Y 15

10. 3-4 N 18

11. 3-4 Y 12

12. ;

13. proc freq data=a;

14. weight count;

15. tables childabuse*adultabuse;

16. run;

CODE

Number of

child abuse

categories

Abused as adultTotal

No Yes

0 512 54 566

1 227 37 264

2 59 15 74

3~4 18 12 30

Total 816 118 934

Page 6: SAS實習111229

1. data a;

2. input childabuse $ adultabuse $ count;

3. datalines;

4. 0 N 512

5. 0 Y 54

6. 1 N 227

7. 1 Y 37

8. 2 N 59

9. 2 Y 15

10. 3-4 N 18

11. 3-4 Y 12

12. ;

13. proc freq data=a;

14. weight count;

15. tables childabuse*adultabuse;

16. run;

CODE

Page 7: SAS實習111229

OUTPUT

Number of

child

abuse

categories

Abused as

adultTotal

No Yes

0 512 54 566

1 227 37 264

2 59 15 74

3~4 18 12 30

Total 816 118 934

Page 8: SAS實習111229

OUTPUT

Without

options:

頻率

百分比

列百分比

欄百分比

Page 9: SAS實習111229

1. data a;

2. input childabuse $ adultabuse $ count;

3. datalines;

4. 0 N 512

5. 0 Y 54

6. 1 N 227

7. 1 Y 37

8. 2 N 59

9. 2 Y 15

10. 3-4 N 18

11. 3-4 Y 12

12. ;

13. proc freq data=a;

14. weight count;

15. tables childabuse*adultabuse/expected;

16. run;

CODE

Page 10: SAS實習111229

OUTPUT

Page 11: SAS實習111229

1. data a;

2. input childabuse $ adultabuse $ count;

3. datalines;

4. 0 N 512

5. …

6. 3-4 Y 12

7. ;

8. proc freq data=a;

9. weight count;

10. tables childabuse*adultabuse/chisq;

11. run;

CODE卡方檢定

Page 12: SAS實習111229

OUTPUT

Page 13: SAS實習111229

OUTPUT

G2

Page 14: SAS實習111229

1. data a;

2. input childabuse $ adultabuse $ count;

3. datalines;

4. 0 N 3

5. 0 Y 3

6. 1 N 1

7. 1 Y 1

8. 2 N 1

9. 2 Y 0

10. 3-4 N 0

11. 3-4 Y 1

12. ;

13. proc freq data=a;

14. weight count;

15. tables childabuse*adultabuse/fisher;

16. run;

CODE

Page 15: SAS實習111229

OUTPUT

N<20即有此警告

Page 16: SAS實習111229

Goodness of fit

適合度檢定

1. data a;

2. input childabuse $ adultabuse $ count;

3. datalines;

4. 0 N512

5. …

6. 3-4 Y 12

7. ;

8. proc freq data=a;

9. weight count;

10. tables childabuse/chisq testp=(20 30 30 20);

11. run;

CODENumber of

child

abuse

categories

Abused as

adultTotal

No Yes

0 512 54 566

1 227 37 264

2 59 15 74

3~4 18 12 30

Total 816 118 934

Page 17: SAS實習111229

OUTPUT

Page 18: SAS實習111229

TESTFSpecifies expected frequencies for one-

way chi-square test

TESTPSpecifies expected proportions for one-

way chi-square test

Page 19: SAS實習111229

1. data a;

2. input J1 $ J2 $ count;

3. datalines;

4. N N 512

5. N Y 54

6. Y Y 227

7. Y N 37

8. ;

9. proc freq data=a;

10. weight count;

11. tables J1*J2/agree;

12. run;

CODE

Kappa (κ): A measure of

agreement

Page 20: SAS實習111229

OUTPUT

Page 21: SAS實習111229

BINOMIAL <(binomial-options)>

1. data a;

2. input childabuse $ adultabuse $ count;

3. datalines;

4. 0 N 512

5. …

6. 3-4 Y 20

7. ;

8. proc freq data=a;

9. weight count;

10. tables adultabuse/binomial;

11. run;

CODE

Page 22: SAS實習111229

OUTPUT