hello,
I am trying to create a bar graph that shows the distribution in terms of frequency of different genders across age groups (age_cat). So, I would like to have within the bar graph the "total", "males" and females".

I initially attempted the following:

separate age_cat, by(gender)
graph bar (count) age_cat age_cat1 age_cat2 , over(age_cat)
but I got:

age_cat may not be both target and by()
so then I did that
gen age_total= age_cat
graph bar (count) age_total age_cat1 age_cat2 , over(age_cat)
in all honestly, in the second attempt I think it worked but I am not sure that it makes sense that the syntaxes work using age_total and age_cat (which literally mean the exact same thing) but in the first instance described above did not work. Am I in the right track?