Hello Stata users,

I would like to perform a test of mean differences between two independent variables (q1 and q2), however, I would like to test the mean differences between 5 age categories i.e. test the mean differences in q1 and q2 between age_cat == 1 and age_cat == 2, age_cat == 1 and age_cat == 3, age_cat == 2 and age_cat == 4, etc (just to name a few). In total, this would mean 10 mean difference comparisons.

However, using the ttest function, you cannot perform: ttest q1 = q2, by (age_cat) since the error message gives: r(420): "more than 2 groups, only 2 allowed".

Is there a way to code the testing that what I would like to do?

Thank you in advance!