/********************************************* homework4.sas *********************************************/ libname b510 v9 "e:\510\homework"; proc format; value actfmt 1="1: <=1" 2="2: 2-4 hours" 3="3: >4 hours"; value hifmt 1="1:High" 2="2:Not High"; value rranfmt 1="1:Yes" 2="2:No"; value $genfmt "M" = "Male" "F" = "Female"; run; /*Question 1: Crosstab of HI1 vs HI2 Get McNemar's test of symmetry*/ proc freq data=b510.combine2; tables hi1*hi2 / agree; format hi1 hi2 hifmt.; run; /*Question 2: Crosstab of RAN * HI1 * Hi2 Get McNemar's test of symmetry separately for those who ran and did not run*/ proc freq data=b510.combine2; tables rran*hi1*hi2 / agree; format hi1 hi2 hifmt.; run; /*Question 3: Oneway frequency with a goodness of fit chi-square test*/ proc freq data=b510.combine2; tables hi1 / chisq testp=(.20,.80); format hi1 hifmt.; run; /*Question 4: Relationship between high fat diet and heart disease*/ data hrtdisease; input diet $ hrtdis $ count; cards; HIGHFAT YES 15 HIGHFAT NO 15 LOWFAT YES 6 LOWFAT NO 14 ; proc freq data=hrtdisease order=data; tables diet * hrtdis / chisq relrisk ; weight count; run; /*Question 5: Same Question, but with 500 patient*/ data hrtdisease2; input diet $ hrtdis $ count; cards; HIGHFAT YES 150 HIGHFAT NO 150 LOWFAT YES 60 LOWFAT NO 140 ; proc freq data=hrtdisease2 order=data; tables diet * hrtdis / chisq relrisk ; weight count; run; /*Question 6: Interrater reliability in assessing tonsil size*/ data tonsil; input Rater1 $ Rater2 $ count; cards; + + 25 + ++ 2 + +++ 0 ++ + 4 ++ ++ 15 ++ +++ 3 +++ + 1 +++ ++ 2 +++ +++ 10 ; proc freq order=data; weight count; tables rater1*rater2 / agree ; test kappa wtkap; exact kappa wtkap; run; /*Question 7: Assessing Grip Before and After Training*/ data grip; input Before $ After $ count; cards; YES YES 17 YES NO 10 NO YES 3 NO NO 41 ; proc freq order=data; weight count; tables before*after / agree ; run;