I am trying to use the SGPLOT procedure to create a stacked horizontal bar chart with four categories and apply a color scheme using the attrid statement. In order to get the four categories in the proper order (rather than alphabetical), each category was assigned a numeric variable (1-4) and a format statement is used to convert the numeric variable back into the category label. The issue is that I can either get the format to work but the attrid statement won't work to assign the appropriate colors or the attrid statement works to assign the colors and I am left with (1,2,3,4) in my legend. The first statement produces an output with the appropriate values for label but not the colors specified by the evh type proc sgplot data=combined5 dattrmap=formatdw.evhstyle;
format value valfmt.;
hbar &sumvar. / response=pcs1 stat=sum
group=value groupdisplay=stack nooutline attrid=evh;
title "Primary Care Services by Type";
run; The second statement produces a graph with the appropriate colors but leaves (1,2,3,4) in the legend as the values used to order the stacked bars proc sgplot data=combined5 dattrmap=formatdw.evhstyle;
hbar &sumvar. / response=pcs1 stat=sum
group=value groupdisplay=stack nooutline attrid=evh;
title "Primary Care Services by Type";
run; Ideally, I'd like the bars stacked in the proper order, with the color scheme applied and the service types labeled in the legend. Thanks in advance for any help.
... View more