1
votes

I am trying to using PROC SGPLOT to draw a bar graph. Groups are differentiate by color. Below is the code I wrote:

proc sgplot data=comb(where=(PFS_weeks ne .));
yaxis discreteorder=data;
hbar Pt_Info / response=PFS_weeks group=Diagnosis; 

The code works fine. However, I have 18 groups but there are only 12 the default group color. So the colors for my group will cycle to the #1 default color from group 13.

My question is, is there a way to increase the number of default group color so that all my groups can have different color?

1

1 Answers

0
votes

The best way to get colors assigned the way you want is to use attribute maps. If you're not using them, you're limited to the GRAPHDATAn (1-12) colors, or using GTL (which I highly recommend, but is more than you need here).

Create an attribute map data set, which maps values to colors (or other attributes). ie:

data attrs;
input id $ value $ fillcolor $;
datalines;
Diagnosis 1 Blue
Diagnosis 2 Black
Diagnosis 3 Green
Diagnosis 4 Yellow
;;;;
run;

You then call it via

proc sgplot data=comb(where=(PFS_weeks ne .)) attrmap=attrs;
yaxis discreteorder=data;
hbar Pt_Info / response=PFS_weeks group=Diagnosis attrid=Diagnosis;
run;

The values for value need to be the actual labelled values of the variable in question; not the underlying value, but the label if there is any formatting done. The id, on the other hand, does not have to be identical to the grouping variable.

See the documentation page on attribute maps for more detail.