Display Attributes documents the attribute settings that you can specify for
the lines, data markers, text, or area fills in a plot. For grouped
data (that is, when you use the GROUP= option in a plot statement),
each distinct group value can be represented in the graph by a different
combination of line pattern, fill pattern, color, and marker symbol
(depending on the graph type). The defaults for these features are
set by the LineStyle, Color, ContrastColor, FillPattern, and MarkerSymbol
attributes of the GraphData1–GraphDataN style elements.
Note: The MarkerSize and LineThickness
style attributes are not honored in the case of grouped data.
For grouped plots, the
style in effect and the plot settings determine which line patterns,
area fills, and plot symbols are used. If different line patterns,
colors, or marker symbols are used to represent group values, then
the style determines the sequences of the line patterns, colors, or
marker symbols that are used for the group values. (As discussed in
Cycling through Group Attributes in Overlaid Plots, other plot
settings might also influence the sequence.) If the number of group
values exceeds the number of style elements, the following occurs
for the subsequent group values:
-
The sequence of line patterns and
plot markers that are specified by the style is repeated.
-
New fill colors are generated by
repeating the GraphData1–GraphDataN colors and varying the
shade of each original color on each cycle. The shade variations alternate
between one shade lighter and one shade darker on each cycle.
You can use attribute
options on the plot statement to change the default display attributes
used for group data. For example, in the following template definition,
the LINEPARM statement’s LINEATTRS= option specifies PATTERN=DASH.
This explicit setting overrides the default line pattern for the plot
lines and uses dashed lines for all of the plots, leaving color to
distinguish among group values.
proc template;
define statgraph dashedline;
begingraph;
layout overlay;
scatterplot y=height x=weight / group=gender;
lineparm yintercept=intercept slope=slope / group=gender
lineattrs=(pattern=dash);
endlayout;
endgraph;
end;
Rather than setting
the same line pattern on all group values, you can change the default
sequence of line patterns that is used for grouped values. To do so,
set the LineStyle attribute in some of the style elements GraphData1
through GraphDataN.
In the following example, a style
is defined to change the default line pattern for the first two lines
in the pattern sequence. In this example, the style is derived from
the DEFAULT style, which is available for the HTML destination. Values
are set for the LineStyle attributes in the GraphData1 and GraphData2
style elements. The first default line in the sequence has long dashes
(style value 6) and the second line has short dashes (style value
4). The LineStyle settings for the remaining GraphData elements are
not set, so are derived from the parent style (DEFAULT). This new
line sequence is used as the default line sequence for any plot that
uses the MyDefault style. To apply the style to a graph, the STYLE=
option is used in the ODS HTML statement to specify the style name.
Here is the code for
this example.
/* Sort the SASHELP.CLASS data by sex and age. */
proc sort data=sashelp.class(keep=height weight sex age)
out=class;
by sex age;
run;
/* Generate slope and intercept data for plot reference lines. */
proc robustreg data=class method=m
outest=stats(rename=(weight=slope));
by sex;
model height=weight;
run;
data class;
merge class stats(keep=intercept slope sex);
run;
proc template;
/* Create custom style STYLES.MYDEFAULT from the STYLES.DEFAULT style. */
define style Styles.MyDefault;
parent=Styles.Default;
style GraphData1 from GraphData1 /
LineStyle=6;
style GraphData2 from GraphData2 /
LineStyle=4;
end;
/* Create the plot template. */
define statgraph testPattern;
begingraph;
layout overlay;
scatterplot y=height x=weight / group=sex;
lineparm x=0 y=intercept slope=slope / group=sex name="lines";
discretelegend "lines";
endlayout;
endgraph;
end;
run;
/* Generate the plot. */
ods _all_ close;
ods html style=MyDefault; /* Apply style MyDefault to the graph. */
proc sgrender data=class template=testPattern;
run;
Similarly, for grouped
data, you can set the MarkerSymbol attribute in each of the style
elements GraphData1 through GraphDataN. In the following example,
a style is defined to change the default sequence that is used for
the first three marker symbols in grouped plots. Values are set for
the MarkerSymbol attributes in the GraphData1 through GraphData3 style
elements. This new sequence is used as the default marker symbol sequence
for any plot that uses the MyDefault style.
Here is the code for
this example.
Note: The data that was generated
in the previous example is used again in this example.
proc template;
/* Create custom style STYLES.MYDEFAULT from the STYLES.DEFAULT style. */
define style Styles.MyDefault;
parent=Styles.Default;
style GraphData1 from GraphData1 /
MarkerSymbol="DIAMOND";
style GraphData2 from GraphData2 /
MarkerSymbol="CROSS";
style GraphData3 from GraphData3 /
MarkerSymbol="CIRCLE";
end;
/* Create the plot template. */
define statgraph testSymbols;
begingraph;
layout Overlay;
scatterPlot y=height x=weight / group=age name="symbols";
discretelegend "symbols" / title="Age";
endlayout;
endgraph;
end;
run;
/* Generate the plot. */
ods html close;
ods html style=MyDefault; /* Apply style MyDefault to the graph. */
proc sgrender data=class template=testSymbols;
run;