Is smoking related to nicotine dependence for each level of this third variable,

that is, for those with major depression and those without major depression?

Similar to our anova example,

syntax to be added to the PROC FREQ code is circled here in red.

We need to first sort the data, according to the categorical third variable,

then include a bistatement, telling SAS to run a chi-square for

each level of the third variable separately.

The specific syntax for

this example is shown here,

PROC SORT; BY MAJORDEPLIFE; PROC FREQ; TABLES

TAB12MDX*USQUAN/CHISQ; BY MAJORDEPLIFE;.

When this syntax is added to the SAS program, here are the results.

You can see the cross tabs or cross tabulation table,

looking at usual quantity by tobacco dependence in the past 12 months.

First, for major depression equal to 0, which is those without major depression,

the chi-square value is large and the P-value is quite small.

In addition, the column percents reveal what seems to be a positive

linear relationship with percentages of nicotine dependency increasing

between lower levels of smoking and higher levels of smoking.

So we can say that this is a statistically significant relationship for

those without major depression.

For those with major depression, we find a large chi-square value and

small P value, which is statistically significant.