You can modify the colors in a style as follows:
%macro reorder(from, to, list); proc template; define style styles.&to; parent=styles.&from; %do i = 1 %to 12; %let s = %scan(&list, &i); %if &s ne %then %do; style GraphData&i from GraphData&i / contrastcolor = GraphColors("gcdata&s") color = GraphColors("gdata&s"); %end; %end; end; run; %mend; %reorder(htmlblue, /* Parent style. */ MyStyle, /* New style to create. Specify it in an ODS */ /* destination statement. */ 3 2 1) /* Replace the first few GraphData colors */ /* (1 2 3) with the colors from the specified */ /* GraphData style elements (3 2 1). */ /* You can specify up to 12 integers in the */ /* range 1 - 12. */
The %Reorder macro creates a new style called MyStyle that inherits most of its attributes from the HTMLBlue style. However,
in the new style, the colors for groups 1, 2, and 3 have been replaced by the colors for groups 3, 2, and 1. In other words,
the colors for GraphData1
and GraphData3
have been switched.
The following step creates the plot:
ods html style=mystyle; proc lifetest data=sashelp.BMT plots=survival(cb=hw test atrisk(outside maxlen=13)); time T * Status(0); strata Group; run; ods html close;
The survival plot is not shown, but it matches the plot in FigureĀ 23.37.
The rest of this section is optional. It explains how you can directly modify colors in a style template when the %Reorder macro or the technique illustrated in the section Changing the Group Color is not sufficient.
The source code for the MyStyle style (as generated by the %Reorder macro) is as follows:
proc template; define style Styles.MyStyle; parent = styles.htmlblue; style GraphData1 from GraphData1 / color = GraphColors('gdata3') contrastcolor = GraphColors('gcdata3'); style GraphData2 from GraphData2 / color = GraphColors('gdata2') contrastcolor = GraphColors('gcdata2'); style GraphData3 from GraphData3 / color = GraphColors('gdata1') contrastcolor = GraphColors('gcdata1'); end; run;
You can create a modified style that has direct color specifications by using the colors in FigureĀ 23.35 as follows:
proc template; define style Styles.MyStyle; parent = styles.htmlblue; style GraphData1 from GraphData1 / color = cx66A5A0 contrastcolor = cx01665E; style GraphData2 from GraphData2 / color = cxD05B5B contrastcolor = cxA23A2E; style GraphData3 from GraphData3 / color = cx6F7EB3 contrastcolor = cx445694; end; run;
You can define additional GraphDataN style elements as well. For more information about how to define style elements, see the section Displaying Other Style Elements.
You can delete the new style template as follows:
proc template; delete Styles.MyStyle / store=sasuser.templat; run;