I have been using SGDESIGN to build customized graphic templates with great success. My question is how do I change the default colors used for the bars to say GREEN, CYAN, RED? Specifying a bar color in SGDESIGN applies the color to all groups. Do I need to modify the styles.listing template? How do I assign a style in PROC SGRENDER?
The easiest way to change the bar colors is to use a modified style template. The style attribute values GDATA1-GDATA12 set the colors for grouped data. The program below does a very simple bar chart in the template and then shows the default colors from the LISTING style and then the new colors from the CARCOLORS style template.
The STYLE= option on the ODS invocation statement will be the appropriate place to change the style used for the SGRENDER...so for example:
ods listing style=styles.carcolors;
** sgrender step;
ods html file=... style=styles.carcolors;
** sgrender step;
ods html close;
%let _mytitle_ = The Default Style for ODS LISTING;
proc sgrender data=carsum template=carplot;
** now make a new style template;
define style styles.carcolors;
class GraphColors /
The solution Cynthia has provided is one of the right answers. Since one of the motivations for Designer is to avoid such coding, there is, "hidden" deep inside Designer, an early version of a GRAPH STYLE EDITOR.
In Designer, Click Tools->Style Editor. It will bring up the Graph Style Editor GUI. Starting with the current style (usually LISTING) as parent you can derive a new style. Once inside the Style Editor, you can change this initial parent style to another one.
Now, you can change the various color, marker, pattern, etc attributes for each of the style elements using the GUI. If you don't know the name of the element, click on the graphs on the right, and it will take you to the right one. Click the title, or background, or a bar, marker, etc. Make your changes, and save the style as a user custom style (give it a different name). You cannot overwrite a SAS supplied style.
Now, back in your graph, click Format->Style-> and select your new style. It may be in "More Styles" in the Custom Styles list.
It is called a "Graph Style Editor" because it only allows you to change the style elements that are applicable to the graph, not other things like tables, etc.
You can also export a generated style (File->Export Style) to a .sas file for use with your code. Note, for SAS 9.2M3, this contains the full definition, even if you have only made a few changes. This will be fixed in the next release.
Documentation for Style Editor can be found in the SAS Help and Documentation:
- SAS Products
- SAS/GRAPH 9.2 ODS Graphics Designer User's Guide:
- Changinfg Appearance of a Graph
- Customizing Graph Styles.