options ls=64; /***********************************************************/ /* Data from Andrews and Herzberg (1985), Data: A Collec- */ /* tion of Problems from Many Fields for the Student and */ /* Research Worker, Table 46. Observations represent sub- */ /* jects in a prostate cohort study, randomized to one of */ /* four dose levels of diethylstilbestrol. Rx records */ /* dose. Stage is disease stage. monfol is months of */ /* followup. surv is 0 if alive after 50 mo, 1 otherwise. */ /* http://lib.stat.cmu.edu/datasets/Andrews/T46.1 */ /***********************************************************/ data prostate; infile 'prostate.dat'; input stage rx monfol surv; dose="low "; if rx>1 then dose="high"; run; data stage4; set prostate; if stage<4 then delete; run; proc freq data=stage4; table rx*surv/norow nocol nopercent expected chisq; run; /***********************************************************/ /* If you wanted to test whether odds ratios for various */ /* stages are same, use Cochoran-Mantel-Haentzel test. Add*/ /* cmh before relrisk below. See 960:553 Categorical Data */ /* Analysis. */ /***********************************************************/ proc freq data=prostate; table stage*dose*surv/norow nocol nopercent relrisk; run; /* Add in crash data here*/ data pairs; set crash; by case; retain belt1 fatal1; if vh>2 then delete; if first.case and last.case then delete; if vh=1 then do; belt1= beltn; fatal1=fataln; delete; end; if fatal1+fataln=1 then; else delete; if fatal1=1 then fbu=belt1; else nfbu=belt1; if fataln=1 then fbu=beltn; else nfbu=beltn; run; title1 'McNemar test'; proc freq data=pairs; table fbu*nfbu/norow nocol nopct agree; run; title1 'Fake comparisons of McNemar and Pearson'; data fake; input a b we ex @@; cards; 0 0 100 1 0 1 50 1 1 0 50 1 1 1 25 1 0 0 100 2 0 1 50 2 1 0 50 2 1 1 0 2 0 0 200 3 0 1 50 3 1 0 100 3 1 1 25 3 ; run; proc freq data=fake; by ex; weight we; table a*b/chisq nopct nocol norow expect agree; run;