Hello, I have a chart of my variable "score" which is presented stratifying by sex and by age-group.
I would like to compare the score between men and women, for each age group separately. I will thus use 4 t-tests.
I am finding it hard to generate the code. So far I have used
ttest score, by(sex) if age_grp==1
ttest score, by(sex) if age_grp==2
ttest score, by(sex) if age_grp==3
ttest score, by(sex) if age_grp==4
but I keep getting the message that the option [if] if not allowed. I suppose I could do a Factorial ANOVA, but I am really trying to understand whether Score varies by sex, separately in each agegroup.
I would like to compare the score between men and women, for each age group separately. I will thus use 4 t-tests.
I am finding it hard to generate the code. So far I have used
ttest score, by(sex) if age_grp==1
ttest score, by(sex) if age_grp==2
ttest score, by(sex) if age_grp==3
ttest score, by(sex) if age_grp==4
but I keep getting the message that the option [if] if not allowed. I suppose I could do a Factorial ANOVA, but I am really trying to understand whether Score varies by sex, separately in each agegroup.
Age Group |
N men (2299) |
Score Men Mean(SD) |
N women (4762) |
Score Women Mean(SD) |
P value* |
<60 | 187 | 16.54(3.34) | 324 | 15.86(2.95) | |
60-69 | 1028 | 16.91(3.57) | 1426 | 16.78(3.37) | |
70-79 | 846 | 17.07(3.60) | 885 | 16.89(3.39) | |
>80 | 238 | 17.48(3.91) | 212 | 16.76(3.51) |
Comment