Previous Page | Next Page

Statistical Graphics Using ODS

Creating an All-Color Style by Using the ModStyle Macro

Many styles are designed to make color plots where lines, functions, and groups of observations can be distinguished even when the plot is sent to a black-and-white printer. Hence, lines differ not only in color but also in pattern. Similarly, markers differ in color and symbol.

You can change that behavior with the ModStyle autocall macro. It creates a new style by modifying a parent style and reordering the colors, line patterns, and marker symbols in the GraphDatan style elements (see section Some Common Style Elements). By default, the macro creates a new style that distinguishes lines and groups only by color. The macro is documented in its header.

The following example illustrates the default use of the macro and is taken from the section Fitting a Curve through a Scatter Plot of Chapter 90, The TRANSREG Procedure. The data come from an experiment in which nitrogen oxide emissions from a single cylinder engine are measured for various combinations of fuel and equivalence ratio. The following statements create the SAS data set:

   data Gas;
      input Fuel :$8. EqRatio NOx @@;
      label EqRatio = 'Equivalence Ratio'
            NOx     = 'Nitrogen Oxide Emissions';
   Ethanol  0.907 3.741 Ethanol  0.761 2.295 Ethanol  1.108 1.498
   ... more lines ...   


The following statements fit separate curves for each group and produce Figure 21.24 and Figure 21.25:

   ods listing style=statistical;
   ods graphics on;
   proc transreg data=Gas ss2 plots=transformation lprefix=0;
      model identity(nox) = class(Fuel / zero=none) * pbspline(EqRatio);
   %modstyle(parent=statistical, name=StatColor)
   ods listing style=StatColor;
   proc transreg data=Gas ss2 plots=transformation lprefix=0;
      model identity(nox) = class(Fuel / zero=none) * pbspline(EqRatio);

The first PROC TRANSREG step uses the STATISTICAL style to create the fit plot in Figure 21.24, which uses different colors, line patterns, and markers for each group. Then the macro creates a new style, called STATCOLOR, that inherits its characteristics from the STATISTICAL style. Only the attributes of the lines and markers are changed. In Figure 21.25, which is created with the modified style, the groups are differentiated only by color. This is the easiest and most common way for you to use this macro. However, you can use it to perform other style modifications as illustrated in the section Changing the Default Markers and Lines. See the macro header for more information.

You do not have to include autocall macros (for example, with a %include statement). You can call them directly once they are properly installed. If your site has installed the autocall libraries supplied by SAS and uses the standard configuration of SAS supplied software, you need to ensure that the SAS system option MAUTOSOURCE is in effect to begin using the autocall macros. For more information about autocall libraries, see the SAS Macro Language: Reference. For details about installing autocall macros, consult your host documentation.

Figure 21.24 Fit Plot with the STATISTICAL Style
Fit Plot with the STATISTICAL Style

Figure 21.25 Fit Plot with the Modified Style
Fit Plot with the Modified Style

Previous Page | Next Page | Top of Page