FOCUS AREAS

Categorical Data Analysis: Chapter 2

  

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

   data respire;
      input treat $ outcome $ count;
      datalines;
   placebo f 16
   placebo u 48 
   test    f 40 
   test    u 20
   ; 
   proc freq;
      weight count;
      tables treat*outcome / chisq;
   run;

   data severe;
      input treat $ outcome $ count;
      datalines;
   Test    f 10 
   Test    u 2
   Control f 2 
   Control u 4 
   ; 
   proc freq order=data;
      weight count;
      tables treat*outcome / chisq nocol;
   run; 

   proc freq order=data;
      weight count;
      tables treat*outcome / chisq nocol;
      exact chisq;
   run; 

   ods select RiskDiffCol1 Measures; 
   data respire2; 
      input treat $ outcome $ count @@; 
      datalines;  
   test    f 40 test    u 20 
   placebo f 16 placebo u 48 
   ; 
   proc freq order=data; 
      weight count; 
      tables treat*outcome / riskdiff measures; 
   run; 
   

   data stress;
      input stress $ outcome $ count;
      datalines;
   low  f 48 
   low  u 12 
   high f 96 
   high u 94
   ; 
   proc freq order=data;
      weight count;
      tables stress*outcome / chisq measures nocol nopct;    
   run; 

   data respire;
      input treat $ outcome $ count;
      datalines;
   test    yes  29 
   test    no   16 
   placebo yes  14 
   placebo no   31
   ; 
   proc freq order=data;
      weight count;
      tables treat*outcome / all nocol nopct;      
   run; 

   data severe;
      input treat $ outcome $ count;
      datalines;
   Test    f 10 
   Test    u 2
   Control f 2 
   Control u 4 
   ; 
   proc freq order=data;
      weight count;
      tables treat*outcome / nocol;
      exact or;
   run;

   data approval;
      input hus_resp $ wif_resp $ count;
      datalines;
   yes yes 20 
   yes no   5
   no yes  10
   no no   10 
   ; 

   ods select McNemarsTest;
   proc freq order=data;
      weight count;
      tables hus_resp*wif_resp / agree;
   run;


Statistics and Operations Research