Dear Statalist members:
I work with two variables: age_c5 which clusters respondents into five age groups; and aoss which is the dependent variable and takes values from -4 to 4. What I want to do is to show the distribution of the age groups (age_c5) across the values of the dependent variable (aoss) in a bar chart.
When I use histogram with the by() option, I get five histograms, one for each age group, in one graph. However, what I actually want is to compare the distribution of the age groups across the values directly, similar to this graph:

When I use the following code, I get the distribution of the age groups across the dependent variables including percentages.

Now, the question is: how do I get the row percentage values of each age group into a variable to present the distribution of all age groups across the dependent variable in a bar chart?
I have already read the instruction of Nicholas J. Cox and Scott Merryman on creating percent summary variables:
http://www.stata.com/support/faqs/da...ary-variables/
But as my dependent variable is not an indicator variable, I think this doesn’t solve my problem.
Thank you for any help!
I work with two variables: age_c5 which clusters respondents into five age groups; and aoss which is the dependent variable and takes values from -4 to 4. What I want to do is to show the distribution of the age groups (age_c5) across the values of the dependent variable (aoss) in a bar chart.
When I use histogram with the by() option, I get five histograms, one for each age group, in one graph. However, what I actually want is to compare the distribution of the age groups across the values directly, similar to this graph:
When I use the following code, I get the distribution of the age groups across the dependent variables including percentages.
Code:
tab age_c5 aoss, row
Now, the question is: how do I get the row percentage values of each age group into a variable to present the distribution of all age groups across the dependent variable in a bar chart?
I have already read the instruction of Nicholas J. Cox and Scott Merryman on creating percent summary variables:
http://www.stata.com/support/faqs/da...ary-variables/
But as my dependent variable is not an indicator variable, I think this doesn’t solve my problem.
Thank you for any help!
Comment