Dear Statalists
I am using Stata 15.0. Here is the data:
When i now run the following code:
Stata draws the graphs being attached (I combined them;colors are from a custom scheme being used). As you might assume already all variables were possible to have value=1 as well, which just doesn't apply for this subgroup of the dataset (while these variables' values spread from 1-3 in other subgroups). Now I want to compare the graphs of all subgroups. So so in every other group, there are three bars on each side, value=1 has a pink bar, value=2 a green bar and value=3 a lighter green bar. Just for this subgroup it's messed up. The absence of value=1 on the left side makes the colors stand for different values than usual. So it does on the right side, plus omitting the legend since only one value is left.
So my question is: is there any way to display values with a percentage of 0, or adding placeholder bars or anything, so that the left side for example would look like
empty space (maybe labelled with '0') green bar lighter green bar
and the right side would look accordingly, with all values being listed in the legend (even the ones with no occurrence)?
Thanks for your help in advance.
Best
Adam
I am using Stata 15.0. Here is the data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(BA7a BA7b) float(BA7a_copy BA7b_copy) 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 3 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 2 3 2 3 3 3 3 3 3 . 3 . 3 3 3 3 3 3 3 3 end label values BA7a BA7a label values BA7b BA7b
When i now run the following code:
Code:
graph bar (percent) BA7a_copy, over(BA7a) asyvars legend(size(small)) ytitle("Anteil der SchülerInnen",size(small)) name(Studiumidealistisch,replace) ylabel(1 20 40 60 80) graph bar (percent) BA7b_copy, asyvars over(BA7b) legend(size(small)) ytitle("Anteil der SchülerInnen", size(small)) name(Studiumrealistisch,replace) ylabel(1 20 40 60 80 100)
So my question is: is there any way to display values with a percentage of 0, or adding placeholder bars or anything, so that the left side for example would look like
empty space (maybe labelled with '0') green bar lighter green bar
and the right side would look accordingly, with all values being listed in the legend (even the ones with no occurrence)?
Thanks for your help in advance.
Best
Adam
Comment