FOCUS AREAS

Categorical Data Analysis: Chapter 4

  

   options nodate nonumber ps=200 ls=80 formdlim=' ';

   data arth;
      input gender $ treat $ response $ count @@;
      datalines;
   female test    none 6  female test    some 5  female test    marked 16
   female placebo none 19 female placebo some 7  female placebo marked 6
   male   test    none 7  male   test    some 2  male   test    marked 5
   male   placebo none 10 male   placebo some 0  male   placebo marked 1
   ;
   proc freq data=arth order=data;
      weight count;
      tables treat*response / chisq nocol nopct;
   run;

   data arth;
      input gender $ treat $ response $ count @@;
      datalines;
   female test    none 6  female test    some 5  female test    marked 16
   female placebo none 19 female placebo some 7  female placebo marked 6
   male   test    none 7  male   test    some 2  male   test    marked 5
   male   placebo none 10 male   placebo some 0  male   placebo marked 1
   ;
   proc freq data=arth order=data;
      weight count;
      tables gender*treat*response / cmh nocol nopct;
   run;

   proc freq data=arth order=data;
      weight count;
      tables gender*treat*response/cmh scores=modridit nocol nopct;
   run;

   data colds;
      input gender $ residence $ per_cold count @@;
      datalines;
   female urban 0   45  female urban  1  64  female urban 2  71
   female rural 0   80  female rural  1 104  female rural 2 116
   male   urban 0   84  male   urban  1 124  male   urban 2  82
   male   rural 0  106  male   rural  1 117  male   rural 2  87
   ;
   proc freq data=colds order=data;
      weight count;
      tables gender*residence*per_cold / all nocol nopct;
   run;

   data tobacco;
      length risk $11. ;
      input f_usage $ risk $ usage $ count @@;
      datalines;
   no minimal      no   59 no  minimal     yes 25
   no moderate     no  169 no  moderate    yes 29
   no substantial  no  196 no  substantial yes  9
   yes minimal     no   11 yes minimal     yes  8
   yes moderate    no   33 yes moderate    yes 11
   yes substantial no   22 yes substantial yes  2
   ;
   proc freq;
      weight count;
      tables f_usage*risk*usage /cmh chisq measures trend;
      tables f_usage*risk*usage /cmh scores=modridit;
   run;

   data pain;
      input diagnosis $ treatment $ response $ count @@;
      datalines;
   I placebo  no 26 I  placebo yes  6
   I dosage1  no 26 I  dosage1 yes  7
   I dosage2  no 23 I  dosage2 yes  9
   I dosage3  no 18 I  dosage3 yes 14
   I dosage4  no  9 I  dosage4 yes 23
   II placebo no 26 II placebo yes  6
   II dosage1 no 12 II dosage1 yes 20
   II dosage2 no 13 II dosage2 yes 20
   II dosage3 no  1 II dosage3 yes 31
   II dosage4 no  1 II dosage4 yes 31
   ;
   proc freq order=data;
      weight count;
      tables treatment*response / chisq;
      tables diagnosis*treatment*response / chisq cmh;
      tables diagnosis*treatment*response / scores=modridit cmh;
   run;

   proc freq order=data;
      weight count;
      tables diagnosis*response*treatment / cmh;
      tables diagnosis*treatment*response / cmh;
   run;


Statistics and Operations Research