/*------------------------------------------------------------*/ /* */ /*SAS Example VII Stat345 Categorical Data Analysis*/ /* */ /*Socioeconomic Status / Smoking Study */ /* */ /*------------------------------------------------------------*/ Options LS=78; Data Smoke; INPUT Soc_Econ Smoker $ Age $ Freq; Cards; 1 S <55 84 1 S 55+ 22 1 NS <55 87 1 Ns 55+ 135 2 S <55 44 2 S 55+ 12 2 NS <55 41 2 NS 55+ 44 3 S <55 26 3 S 55+ 17 3 NS <55 22 3 NS 55+ 57 4 S <55 17 4 S 55+ 14 4 NS <55 19 4 NS 55+ 21 ; /*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 'By' statement produces a separate analysis for each */ /* level of the designated variable. The data set must be */ /* previously sorted by this variable using Proc SORT. */ /* The 'ChiSq' option produces results for chi-squared tests */ /* of independence (e.g., Pearson chi-squared, likelihood */ /* ratio). */ /* The 'Trend' option produces the Cochran-Armitage linear */ /* trend test. */ /* The 'Title' statement assigns a heading to each page of */ /* output. */ Proc SORT; By Age; Proc FREQ Order = Data; Weight Freq; By Age; Tables Soc_Econ*Smoker / ChiSq Trend; Title 'Socioeconomic Status / Smoking Study (1977)'; Title '(Status Indides from 1 [Low] to 5 [High])'; Title '(Separate Analyses by Age)'; Run;