title 'Common Cold and Vitamin C'; data cold; input Disease $8. Condition $13. n 4.; cards; Cold Placebo 31 No Cold Placebo 109 Cold Ascorbic Acid 17 No Cold Ascorbic Acid 122 ; run; proc print data = cold; run; proc freq data=cold; tables Condition*Disease / chisq fisher expected cellchi2 deviation; weight n; run; title 'Sandflies'; data sandflies; input sex $ height n; cards; m 3 173 m 35 125 f 3 150 f 35 73 ; run; proc freq data=sandflies; tables sex*height /chisq; weight n; run; title 'Acacia Ants'; data ants; input species $ invaded $ n; cards; A no 2 A yes 13 B no 10 B no 3 ; run; proc freq data=ants; tables species*invaded / chisq expected; weight n; run; title 'Piston Ring Failure'; data pistons; input machine site $ n; cards; 1 North 17 1 Centre 17 1 South 12 2 North 11 2 Centre 9 2 South 13 3 North 11 3 Centre 8 3 South 19 4 North 14 4 Centre 7 4 South 28 ; run; proc freq data=pistons order=data; tables machine*site / chisq deviation cellchi2 norow nocol nopercent; weight n; run; title 'Risk/Relative Risk/Odds Ratio'; proc freq data=cold; tables Condition*Disease / norow nocol nopercent riskdiff relrisk; weight n; run; proc freq data=sandflies; tables sex*height /riskdiff nocol nopercent; weight n; run; title 'Matched observations: Oral Contraceptive'; data the_pill; input caseuse $ contruse $ n; cards; Y Y 10 Y N 57 N Y 13 N N 95 ; run; proc freq data=the_pill order=data; tables caseuse*contruse / agree; weight n; run; title 'Bronchitis: Three way table'; data bronchitis; input agegrp level $ bronch $ n; cards; 1 H Y 20 1 H N 382 1 L Y 9 1 L N 214 2 H Y 10 2 H N 172 2 L Y 7 2 L N 120 3 H Y 12 3 H N 327 3 L Y 6 3 L N 183 ; proc freq data=bronchitis order=data; tables level*bronch / chisq nocol nopercent; Tables agegrp*level*bronch / chisq cmh nocol nopercent; weight n; run; title 'Boy Scout Example'; data boys; input SES $ scout $ delinquent $ count @@; datalines; low yes yes 11 low yes no 43 low no yes 42 low no no 169 med yes yes 14 med yes no 104 med no yes 20 med no no 132 high yes yes 8 high yes no 196 high no yes 2 high no no 59 ; proc freq data = boys; weight count; tables scout *delinquent/chisq expected nocol nopercent; tables SES*delinquent/chisq nopercent nocol norow; tables SES*scout*delinquent/chisq exact cmh nopercent nocol norow; run;