First, I want to say that I don't have a good english. So,if something is not understood I can explain it again
Well, I have some problems with graphs bars in Stata. I want to add another variable as a label above stacked bar chart. I found this link https://www.stata.com/statalist/arch.../msg00911.html but that data base is not acording with mine. "Dpto" is my binary var and "g_L1" my combination of my two categories ("D" and "N"). "Total" is the percentage that I want to show in my stacked bar chart, and I would like to add the var "NV" above stacked bar chart.
g_L1 | Dpto | Total | NV |
Level1 | D | 20 | 500 |
Level1 | D | 20 | 500 |
Level1 | D | 20 | 500 |
Level1 | D | 20 | 500 |
Level1 | N | 33 | 1000 |
Level1 | N | 33 | 1000 |
Level1 | N | 33 | 1000 |
Level2 | D | 45 | 500 |
Level2 | D | 45 | 500 |
Level2 | N | 53 | 1000 |
Level2 | N | 53 | 1000 |
Level2 | N | 53 | 1000 |
Level2 | N | 53 | 1000 |
Level3 | D | 35 | 500 |
Level3 | D | 35 | 500 |
Level3 | N | 14 | 1000 |
Level3 | N | 14 | 1000 |
Level3 | N | 14 | 1000 |
When I just considered the first three vars (g_L1", "Dpto" and "Total") I run the next sintaxis and it really works, but I want to incorporate the new var "NV" above the chart
and I don't know how to do it
splitvallabels g_L1
graph bar Total, ///
over(g_L1, label(labsize(small)) relabel(`r(relabel)')) ///
over(Dpto,label(labsize(small))) ///
ytitle("Categories", size(small)) ///
title("Results" ///
,span size(medium)) ///
blabel(bar, pos(center) format(%4.0f)) ///
intensity(25)///
asyvars stack
I hope your help.
Thanks,
S.
0 Response to How to add another variable as a label above stacked bar chart
Post a Comment