since I can't post a .dta file, I try to explain my problem. I can't create an example dataset since that's the reason I ask my question, because I can't figure out why Stata reacts the way it reacts with my data.
My dataset consists of 3 variables: age group, categories (which has 12 categories cat1 to cat12, coded by the numbers 180 to 200) and a string variable for departments, called dep. The dep variable looks like this "#B#Y#aa#aa#aa#aa#aa#aa#" and is coded that way for some reasons.
Since I want to keep all categories shown in the graph (because of the same color), I used 2 options for my stacked bar chart: allcategories and nofill. This is the first graph I create:
Code:
global options = "stack asyvars percent allcategories nofill" graph bar if categories < 190 & strmatch(dep,"*A*"), over(categories) over(agegrp5) $options
Code:
graph bar if categories < 190 & strmatch(dep,"*A*"), over(categories) over(agegrp5) $options
Code:
tab agegrp5 categories if categories < 190 & strmatch(dep,"*A*"), miss
Now I tried the following:
Code:
keep if strmatch(dep,"*A*") == 1 drop if strmatch(dep,"*A*") & agegrp5 == 1 graph bar if categories<190 & strmatch(dep,"*A*"), over(categories) over(agegrp5) $options
Code:
drop if strmatch(dep,"*A*") & agegrp5 == 2 graph bar if categories < 190 & strmatch(dep,"*A*"), over(categories) over(agegrp5) $options
Code:
if strmatch(dep,"*A*") & agegrp5 == 1 if strmatch(dep,"*A*") & agegrp5 == 2
Hopy you can help me.
-Nick
0 Response to Graph Bar problem with allcategories and nofill option
Post a Comment