To answer the questions above, we need to use the summarize command with both qualifiers and by() option. In STATA we enter the following:
sort gender_c
by gender_c: summarize educ_new if age >= 21 & age~=.
by gender_c: summarize educ_new if age<21
by gender_c: summarize educ_new if age age > 5 & age < 11
. by gender_c: summarize educ_new if age >= 21 & age~=.
-> gender_c = F
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
educ_new | 1342 4.934426 3.79943 0 16
_______________________________________________________________________________
-> gender_c = M
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
educ_new | 1126 5.452043 3.953835 0 16
. by gender_c: summarize educ_new if age<21
-> gender_c = F
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
educ_new | 1279 2.801407 3.115858 0 12
_______________________________________________________________________________
-> gender_c = M
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
educ_new | 1317 2.514047 2.934828 0 12
. by gender_c: summarize educ_new if age > 5 & age < 11
-> gender_c = F
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
educ_new | 336 1.142857 .9062682 0 6
_______________________________________________________________________________
-> gender_c = M
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
educ_new | 333 1.027027 .8336969 0 7
After entering the syntax above, we see that for adults, the average education of males is 5.45 while that of females is 4.93. For non-adults, the average education of males is 2.51 while that of females is 2.80. One interpretation is that the gender differences in education levels might diminish in the future. When we just look at children between the ages of 6 and 10, we find that the average education levels of boys and girls are almost identical (1.14 for girls and 1.03 for boys). This makes for a very positive outlook in the future.