Hi:
You may want to consider moving toward an approach like the one shown in this Tech Support note.
http://support.sas.com/kb/24/874.html
It uses a SAS Macro program to guarantee that the ice cream flavors get the right color for the bar chart, even if there is no flavor in a particular group.
The key is specifying an explicit numbered PATTERN statement value in a macro program. Then the correct PATTERN statement is used for every group, so that strawberry is always pink, chocolate is always brown, etc, etc.
The other approach that folks use is to put a "dummy" obs into the data for every category or combination of category and by group. In this way, they ensure that there will be the right number of categories. See the program example below. SASHELP.CLASS only has 1 student -- a male in the age 16 group -- so by putting an extra observation for F in the dataset to graph, I can ensure that the bar for M uses the color in the second PATTERN statement.
cynthia
[pre]
ods listing;
proc freq data=sashelp.class;
title 'note that there are no F in Age 16';
where age in (14, 15, 16);
tables age*sex / list;
run;
** now, ADD an F observation with a very, very LOW value for the SUMVAR variable;
data class;
set sashelp.class end=eof;
where age in (14, 15, 16);
output;
if eof then do;
** make sure that age 16 has an obs for F;
name = 'extra';
sex = 'F';
height=.0001;
age = 16;
output;
end;
run;
proc sort data=class out=class;
by age;
run;
goptions reset=all;
pattern1 c=pink v=s;
pattern2 c=blue v=s;
proc gchart data=class;
title 'By Age #byval1';
by age;
vbar sex / sumvar=height patternid=midpoint;
run;
quit;
goptions reset=all;
[/pre]