Hi all,

I wanted to create stacked bars for some variables where the bar's divisions would be different categories of that variable. For this, I created dummies of the different categories and used graph bar with the stack option (so that I would essentially get their proportions by graphing their means). For example, one variable is asset_built which can take 5 values (what I refer to as categories above). I created 5 dummies as you can see in the data below. As you can see, there are some categories with mean 0. What I want is that these categories should not show up either in the legend or in the labels.

My current command is something like "graph bar(mean) varlist, percentages stack" with some other options for appearance.

How could I edit this?


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(asset_built_yes asset_built_yes_other_place asset_built_no asset_built_not_located asset_built_unclear)
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
0 0 1 0 0
0 0 1 0 0
1 0 0 0 0
1 0 0 0 0
end

Thanks