Statistical Graphics Using ODS


Grouped Scatter Plot with PROC SGPLOT

This example is taken from Example 35.1 in Chapter 35: The DISCRIM Procedure. It uses the Fisher iris data set, which is available from the Sashelp library.

The following statements run PROC SGPLOT to make a scatter plot, grouped by iris species:

proc sgplot data=sashelp.iris;
   title 'Fisher (1936) Iris Data';
   scatter x=petallength y=petalwidth / group=species;
run;

The results are shown in Figure 21.12.

Figure 21.12: Iris Data

Iris Data


For more information about PROC SGPLOT (statistical graphics plot) and other SG procedures, see the section Statistical Graphics Procedures and the SAS ODS Graphics: Procedures Guide. You do not need to enable ODS Graphics in order to use SG procedures (because making plots by using ODS Graphics is their sole function). However, you can use the ODS GRAPHICS statement to change options, as in the following example:

ods graphics on / attrpriority=none;

proc sgplot data=sashelp.iris;
   title 'Fisher (1936) Iris Data';
   styleattrs datasymbols=(circlefilled squarefilled starfilled);
   scatter x=petallength y=petalwidth / group=species markerattrs=(size=5px);
run;

ods graphics / reset;

The STYLEATTRS statement specifies the symbols for the three groups of observations. The results are shown in Figure 21.13. The groups in Figure 21.13 are distinguished by varying colors and symbols. In contrast, the groups in Figure 21.12 are distinguished only by colors. The ATTRPRIORITY=NONE option in the ODS GRAPHICS statement ensures that the second and third symbols are used. The HTMLBLUE style is an ATTRPRIORITY="Color" style, so by default, the symbol and line style attributes are not used to distinguish groups. The ATTRPRIORITY=NONE option in the ODS GRAPHICS statement overrides the ATTRPRIORITY="Color" option in the style, so that all three symbols are used. For more information, see the sections Attribute Priorities and Overriding How Groups Are Distinguished.

Figure 21.13: Iris Data Controlling the Symbols

Iris Data Controlling the Symbols