Statistical Graphics Using ODS


Overriding How Groups Are Distinguished

In the statistical graphics (SG) procedures, you can override the style attributes and modify how groups are distinguished by using the STYLEATTRS statement:

ods graphics on / attrpriority=none;

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

ods graphics / reset;

The results are displayed in FigureĀ 21.20.

Figure 21.20: Iris Data

Iris Data


The STYLEATTRS statement options are as follows:

DATACOLORS=(color-list)

specifies the fill colors. You can specify common color names or values of the form CXrrggbb, where the last six characters specify RGB (red, green, blue) values on the hexadecimal scale of 00 to FF (0 to 255, base 10).

DATACONTRASTCOLORS=(color-list)

specifies the contrast colors, which are used for lines and markers. You can specify common color names or values of the form CXrrggbb, where the last six characters specify RGB (red, green, blue) values on the hexadecimal scale of 00 to FF (0 to 255, base 10).

DATALINEPATTERNS=(line-pattern-list)

specifies the list of line patterns. Some of the available line patterns are Solid, MediumDash, MediumDashShortDash, LongDash, DashDashDot, LongDashShortDash, DashDotDot, Dash, ShortDashDot, MediumDashDotDot, and ShortDash.

DATASYMBOLS=(marker-symbol-list)

specifies the list of marker symbols. The available markers are ArrowDown, Asterisk, Circle, CircleFilled, Diamond, DiamondFilled, GreaterThan, Hash, HomeDown, HomeDownFilled, Ibeam, LessThan, Plus, Square, SquareFilled, Star, StarFilled, Tack, Tilde, Triangle, TriangleDown, TriangleDownFilled, TriangleFilled, TriangleLeft, TriangleLeftFilled, TriangleRight, TriangleRightFilled, Union, X, Y, and Z.

In the SG procedures, you can override the style attributes and modify how groups are distinguished by using attribute maps:

data myattrmap;
   retain ID 'Attr1' MarkerSymbol 'CircleFilled';
   input Value $ LineColor $ 3-11 MarkerColor $ 13-20;
   datalines;
F pink      cxFFCCEE
M lightblue blue
;

proc sgplot data=sashelp.class dattrmap=myattrmap;
   title 'Separate Fit by Sex';
   reg y=weight x=height / group=sex degree=3 attrid=Attr1;
run;

The results are displayed in FigureĀ 21.21.

Figure 21.21: Color Changes with an Attribute Map

Color Changes with an Attribute Map


You can set the following variables and values in the PROC SGPLOT DATTRMAP=SAS-data-set option:

FillColor

color or style attribute

FillStyle

style element

ID

text string that contains the attribute map ID

LineColor

color or style attribute

LinePattern

line pattern or style attribute

LineStyle

style element

MarkerColor

color or style attribute

MarkerStyle

style element

MarkerSymbol

symbol name or style attribute

Value

text string that contains the group