Hello,
I'm trying to make a stacked bar graph with the following variables:
1) deciles (below it's the first column and the first decile, "1" is copied)
2) children who are stunted - 0 indicates not stunted, 1 indicates stunting
3) children with wasting - 0 indicates not wasted (no - I do not mean drunk...) 1 indicates wasted
4 children who are underweight (1) or not (0)
5) households with children (1) or without (0)
I want to make a bar graph where deciles would be on the horizontal x axis (1-10) and y axis would indicate shares of stunted, or wasted or underweight children in reference to a number of households that have children within a given decile. I can produce a figure that would take the total number of households in the decile - but this is not what I want.
My code is following, but it did not give right shares
To give an example, if in decile 1 we have 500 households and there are 250 households with children within this first decile, and 50 of them are stunting, then I want stata to show 50/250=20%. But with this code I have above it would show 50/500=10%. How do I fix it?
The end result (produced in excel) should look like this:

I'm trying to make a stacked bar graph with the following variables:
1) deciles (below it's the first column and the first decile, "1" is copied)
2) children who are stunted - 0 indicates not stunted, 1 indicates stunting
3) children with wasting - 0 indicates not wasted (no - I do not mean drunk...) 1 indicates wasted
4 children who are underweight (1) or not (0)
5) households with children (1) or without (0)
I want to make a bar graph where deciles would be on the horizontal x axis (1-10) and y axis would indicate shares of stunted, or wasted or underweight children in reference to a number of households that have children within a given decile. I can produce a figure that would take the total number of households in the decile - but this is not what I want.
My code is following, but it did not give right shares
Code:
graph bar (percent) only_stunted only_wasted underweight_and_rest if has_child_under_5==1, over(decile) stack
The end result (produced in excel) should look like this:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float decile byte(only_stunted only_wasted underweight_and_rest has_child_under_5) 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0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