Dear User,

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
I uploaded the graph as "correct1.png". So everything is fine with the graph. Not I try to create the next graph:

Code:
graph bar if categories < 190 & strmatch(dep,"*A*"), over(categories) over(agegrp5) $options
This graph is "wrong1a.png" in the attachments. There is an empty space on the right side of the graph wich I expected not to be there. I used a tabulate command
Code:
tab agegrp5 categories if categories < 190 & strmatch(dep,"*A*"), miss
to have a look at missings, but there are none.

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
As you can see in "wrong1b.png", now the graph is looking correct. Using the same tabulte command as above, the table looks the same, no missings and nothing that tells me why there is an empy space on the right of "wrong1a.png". So the strange thing is, when using

Code:
drop if strmatch(dep,"*A*") & agegrp5 == 2
graph bar if categories < 190 & strmatch(dep,"*A*"), over(categories) over(agegrp5) $options
The graph looks like "correct2.png" with no empty space. So I was trying to figure out the difference between my data between my 2 filters:
Code:
if strmatch(dep,"*A*") & agegrp5 == 1
if strmatch(dep,"*A*") & agegrp5 == 2
which seems to be the reason of the empty space, but there is no difference in the data I can see. So that's why I think allcategories and nofill must handle the data somehow different.

Hopy you can help me.

-Nick