/*-----------------------------------------------------------------*/
/*                                                                 */
/*SAS Example III         Stat345         Categorical Data Analysis*/
/*                                                                 */
/*Titanic Example                                                  */
/*                                                                 */
/*-----------------------------------------------------------------*/

Options LS=78;

Data Titanic;
  INPUT Class $ Survival $ Freq @@;
  Cards;
  First  Survival 202  First  Perished 135
  Second Survival 125  Second Perished 160
  Third  Sruvived 180  Third  Perished 541
  ;

/*Analyze the data using Proc FREQ.                                */
/*  The 'Order=Data' specification maintains the ordering of       */
/*     the variable levels in which the data was input.            */
/*  The 'Weight' statement identifies the cell frequency           */
/*     variable.                                                   */
/*  The 'ChiSq' option produces results for chi-squared tests of   */
/*     independence (e.g., Pearson chi-squared, likelihood ratio). */
/*  The 'CellChi2' option outputs each cell's contibution to the   */
/*     Pearson chi-squared statistic (as used for testing          */
/*     Independence).                                              */
/*  The 'Measures' option produces estimates of various measures   */
/*     of association.                                             */
/*  The 'Title' statement assigns a heading to each page of output.*/

Proc FREQ Order = Data;
  Weight Freq;
  Tables Class*Survival / ChiSq CellChi2 Measures;
  Title 'Titanic Example';
  Run;

Submit to see output