SAS 9.4 Graph Template Language Reference 5e (2016)
SAS 9.4 Graph Template Language Reference 5e (2016)
4 Graph Template
®
Language: Reference,
Fifth Edition
SAS® Documentation
May 8, 2024
The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2016. SAS® 9.4 Graph Template Language: Reference, Fifth
Edition. Cary, NC: SAS Institute Inc.
SAS® 9.4 Graph Template Language: Reference, Fifth Edition
Copyright © 2016, SAS Institute Inc., Cary, NC, USA
PART 1 Fundamentals 1
Chapter 1 / Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Graph Template Language (GTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Components of a Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Graphical Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Legends . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Flexible Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
About the Examples in This Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Examples and Resources on the Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
n style conventions
n special characters
Syntax Components
The components of the syntax for most language elements include a keyword and
arguments. For some language elements, only a keyword is necessary. For other
language elements, the keyword is followed by an equal sign (=). The syntax for
arguments has multiple forms in order to demonstrate the syntax of multiple
arguments, with and without punctuation.
viii Syntax Conventions Used in this Document
keyword
specifies the name of the SAS language element that you use when you write
your program. Keyword is a literal that is usually the first word in the syntax. In a
CALL routine, the first two words are keywords.
In this example, the first two words of the CALL routine are the keywords:
CALL RANBIN(seed, n, p, x)
DO;
... SAS code ...
END;
Some system options require that one of two keyword values be specified:
DUPLEX | NODUPLEX
In this example, string and position follow the keyword CHAR. These arguments
are required arguments for the CHAR function:
Each argument has a value. In this example of SAS code, the argument string has
a value of 'summer', and the argument position has a value of 4:
x=char('summer', 4);
In this example, string and substring are required arguments, whereas modifiers
and startpos are optional.
argument(s)
specifies that one argument is required and that multiple arguments are
allowed. Separate arguments with a space. Punctuation, such as a comma ( , ) is
not required between arguments.
MISSING character(s);
<LITERAL_ARGUMENT> argument-1 <<LITERAL_ARGUMENT> argument-2 ... >
specifies that one argument is required and that a literal argument can be
associated with the argument. You can specify multiple literals and argument
pairs. No punctuation is required between the literal and argument pairs. The
ellipsis (...) indicates that additional literals and arguments are allowed.
Style Conventions
The style conventions that are used in documenting SAS syntax include uppercase
bold, uppercase, and italic:
UPPERCASE BOLD
identifies SAS keywords such as the names of functions or statements. In this
example, the keyword ERROR is written in uppercase bold:
ERROR <message>;
UPPERCASE
identifies arguments that are literals.
In this example of the CMPMODEL= system option, the literals include BOTH,
CATALOG, and XML:
LINK label;
n nonliteral values that are assigned to an argument.
Special Characters
The syntax of SAS language elements can contain the following special characters:
=
an equal sign identifies a value for a literal in some language elements such as
system options.
In this example of the MAPS system option, the equal sign sets the value of
MAPS:
MAPS=location-of-maps
<>
angle brackets identify optional arguments. A required argument is not enclosed
in angle brackets.
Syntax Conventions for the SAS Language xi
In this example of the CMPMODEL= system option, you can choose only one of
the arguments:
In this example of the CAT function, multiple item arguments are allowed, and
they must be separated by a comma:
If you use a logical name, you typically have a choice of using a SAS statement
(LIBNAME or FILENAME) or the operating environment's control language to make
the reference. Several methods of referring to SAS libraries and external files are
available, and some of these methods depend on your operating environment.
xii Syntax Conventions Used in this Document
In the examples that use external files, SAS documentation uses the italicized
phrase file-specification. In the examples that use SAS libraries, SAS
documentation uses the italicized phrase SAS-library enclosed in quotation marks:
infile file-specification obs = 100;
libname libref 'SAS-library';
Boolean Values
ON OFF
_ON_ _OFF_
TRUE FALSE
YES NO
_YES_ _NO_
1 0
color
specifies a string that identifies a color. A color can be one of the following:
n any of the color names that are supported by SAS. See “Color-Naming
Schemes” on page 1609.
n one of the colors that exists in the SAS session when the style template is
used, such as DMSBLACK or DMSCYAN. (Use these color specifications
only if you are running SAS in the windowing environment.)
n an English description of an Hue/Light/Saturation (HLS) value. Such
descriptions use a combination of words to describe the lightness, the
Value Type Notation Used for GTL Statement Options xiii
saturation, and the hue (in that order). You can use the Color Naming System
to form a color by doing one of the following:
o combining a chromatic hue with a lightness, a saturation, or both
o combining the achromatic hue gray with a lightness
o combining the achromatic hue black or white without qualifiers.
o combining words to form a wide variety of colors, such as light vivid
green, dark vivid orange, or light yellow.
n specify hues that are intermediate between two neighboring colors. To do so,
combine one of the following adjectives with one of its neighboring colors:
brownish, greenish, purplish, or yellowish (for example, bluish purple or
reddish orange).
column
specifies a column variable that contains either double-precision values or
string values, or a dynamic variable that refers to such a column.
Unit Description
CM centimeters
IN inches
MM millimeters
PCT or % percentage
PX pixels
expression
specifies a selective, relational, or logical program structure that calculates
values when those values are not stored in the data. The expression must be
specified as an EVAL() argument. The following shows the structure of an
EVAL() argument:
x = EVAL(expression)
The expression returns a number and can be formed with consonants, data
columns, dynamic variables, functions, or other expressions. The following
example uses the data column Time and the SGE functions MEAN and ACF:
xiv Syntax Conventions Used in this Document
For more information about expressions, see Chapter 21, “Expressions,” on page
1539.
fill-pattern
specifies a fill pattern as a two-character code that consists of a line-direction
prefix (R for right, L for left, or X for cross hatch) and a line identification
number, 1–5. For more information about fill patterns, see “Fill Pattern Options”
on page 1601.
format
specifies a SAS format or a user-defined format.
integer, integer-column
specifies a member of the set of positive whole numbers, negative whole
numbers, and zero.
For details about line attributes, see “Line Options” on page 1602.
marker-name
specifies a string value of a maker symbol, a dynamic variable that contains a
marker symbol, or a style reference to a marker symbol.
For details about marker attributes, see “Marker Options” on page 1604.
number, numeric-column
specifies a value, a dynamic variable that contains a double-precision value, an
expression that resolves to a double-precision value, or a style reference to a
double-precision value.
Note: For quoted character string options in GTL, a space enclosed in quotation
marks (" " or ' ') and empty quotation marks ("" or '') are not equivalent. A space
enclosed in quotation marks specifies a blank space or a missing string value.
Empty quotation marks have the same effect as not setting the option. To
Value Type Notation Used for GTL Statement Options xv
specify a blank space or missing value in a quoted string option, use a space
enclosed in quotation marks (" " or ' ').
style-reference
specifies a reference to an attribute that is defined in a style element.
In the ODS Graphics templates that SAS provides, options for plot features are
specified with a style reference in the form style-element-name:attribute-name,
rather than a specific value. For example, the symbol, color, and size of markers
for a basic scatter plot is specified in a SCATTERPLOT statement as follows:
The above style references guarantee a common appearance for markers used in
all basic scatter plots. For non-grouped data, the marker appearance is
controlled by the GraphDataDefault style element in the style template that
you specify.
In order to create your own style template, or to modify a style template to use
with ODS Graphics, you need to understand the relationship between style
elements and graph features. For more information, see the usage guide.
xvi Syntax Conventions Used in this Document
xvii
Overview
New and enhanced statements for the Graph Template Language (GTL) extend the
versatility of the language and introduce new plot types. The following changes are
included in this release:
n new plot statements
releases, STAT=PCT displays proportional values in the range 0–1. To restore the
proportional values in SAS 9.4 and later releases, change STAT=PCT to
STAT=PROPORTION.
n SYMBOLIMAGE defines a marker symbol from a GIF, JPG, or PNG image that is
stored in a file.
You can use these statements to define custom marker symbols for your graphs.
For information about subsequent enhancements to these statements, see “Marker
Definition Statement Enhancements” on page lvi.
New Function
SAS 9.4M1 adds the TYPEOF function. This function returns the type (numeric or
character) of a specified column at run time. You can use the TYPEOF function to
take specific actions in your template at run time based on the input data type.
xxii What’s New in SAS 9.4 Graph Template Language
When none of these conditions are true, the default rotation pattern is used. For
more information, see “BEGINGRAPH Statement Enhancements” on page xxiv.
n a list of contrast colors that replace the graph data contrast colors in the current
style
n a list of marker symbols that replace the graph data marker symbols in the
current style
New Features for General Use xxiii
n a list of line patterns that replace the graph data line patterns in the current
style
In addition, you can specify a priority for the group value attribute cycling. For more
information, see “BEGINGRAPH Statement Enhancements” on page xxiv.
Outer Padding
GTL provides a new OUTERPAD= option that enables you to control the padding
around the outside of layouts, legends, titles, footnotes, and text entries. You can
use this option to modify the outer padding when the default padding is not
sufficient. You can specify a single padding value for all four sides, or you can
specify different values for each side.
ODS Graphics does not support the use of a user-defined ODS escape character to
escape Unicode values in user-defined formats.
o HEADERPACK= specifies whether the values listed in the cell headers are
displayed as a delimited list in a single header cell in order to save space.
o HEADERSEPARATOR= specifies a separator to place between each value in
the cell header.
o HEADERSPLITCOUNT= specifies the number of class variables in the cell
header after which the cell header wraps to a separate line.
n SAS 9.4M2 has the following enhancements:
LAYOUT GLOBALLEGEND:
n SAS 9.4M1 changes the default padding between the global legend and the plot
area (including the axes) to 10 pixels. Use the OUTERPAD= option to adjust the
padding, if necessary.
LAYOUT OVERLAY:
n INNERMARGIN statement:
o ALIGN= now supports LEFT and RIGHT in addition to TOP and BOTTOM.
xxvi What’s New in SAS 9.4 Graph Template Language
LAYOUT OVERLAYEQUATED:
n The HEATMAPPARM statement is now supported.
LAYOUT PROTOTYPE:
n The HEATMAPPARM statement is now supported.
DISCRETELEGEND:
n SAS 9.4M1 has the following enhancements:
o The default padding between the legend and the plot area (including the
axes) is 10 pixels, depending on the context. You can use the OUTERPAD=
option to adjust the padding if necessary.
o ITEMSIZE= specifies the size of specific types of items in a discrete legend.
n SAS 9.4M2 changes the BORDER= option default to style reference
GraphLegendBackground:FrameBorder.
n SAS 9.4M3 has the following enhancements:
CONTINUOUSLEGEND:
n EXTRACTSCALE= specifies whether to extract a scale factor from the tick
values and use it to reduce the tick value width.
n EXTRACTSCALETYPE= specifies whether to extract a named scale or a
scientific-notation scale.
n SAS 9.4M2 changes the BORDER= option default to style reference
GraphLegendBackground:FrameBorder.
n SAS 9.4M3 adds option INTEGER=, which specifies whether only integer tick
values are used in the continuous legend.
LEGENDITEM:
n FILLEDOUTLINEDMARKERS= specifies whether markers are drawn with both
fills and outlines.
n SAS 9.4M3 adds option FILLDISPLAY=, which specifies whether the fill swatch
for this legend item displays fill only or displays fill and outline.
MERGEDLEGEND:
n SAS 9.4M1 has the following enhancements:
o CLASSORDER= specifies the order in which the class values are displayed.
o CLUSTERWIDTH= specifies the width of the group clusters as a fraction of
the midpoint spacing.
o DISPLAY= now supports VALUES, which displays the table values.
o DROPONMISSING= specifies whether the entire axis table is dropped when
all of the VALUE= column values are missing.
o GUTTER= specifies the gap between rows when a class variable is used.
o INCLUDEMISSINGCLASS= specifies whether missing class values are
represented in the table.
o LABEL= specifies the text for the table label.
o LABELHALIGN= specifies the horizontal alignment of the column labels
relative to the column width in a Y-axis table.
o LABELJUSTIFY= specifies the justification of the column label, when
displayed.
o PAD= specifies the amount of extra space that is added inside the table
border.
o SHOWMISSING= specifies whether missing values are represented in the
table.
o TITLE= specifies the text for the table title.
o TITLEATTRS=specifies the color and font attributes of the table title.
o TITLEHALIGN= specifies the horizontal alignment of the axis table header
label relative to the table width for a Y-axis table.
o TITLEJUSTIFY= specifies the justification of the title string.
o VALUEFORMAT= specifies a SAS format or a user-defined format for the
table values.
o VALUEHALIGN= specifies the horizontal alignment of the column values
relative to the column width in a Y-axis table.
o VALUEJUSTIFY= specifies the justification of the values in the axis table.
o The following options are replaced and considered deprecated:
n HEADERLABEL= is replaced with TITLE=.
n HEADERLABELATTRS= is replaced with TITLEATTRS=.
The deprecated options are still honored, but the new options are the
preferred options.
n SAS 9.4M3 adds option TITLEHALIGN=, which specifies the horizontal
alignment of the axis table header label relative to the table width for Y-axis
tables and X-axis tables.
BANDPLOT:
n TIP= now supports NONE, which suppressed data tips from the plot.
BARCHART:
n X= is changed to CATEGORY= in order to be consistent with the other GTL plot
statements. The X= option is still valid for backward compatibility. However,
you should change the X= option to CATEGORY= in your BARCHART
statements.
Note: If you specify X as a data tip role when you change X= to CATEGORY=,
then you must also change X to CATEGORY in your data tip options.
Note: If you specify Y as a data tip role when you change Y= to RESPONSE=,
then you must also change Y to RESPONSE in your data tip options.
n The baseline is now drawn by default. To suppress the baseline, use the
BASELINEATTRS= option to set the line thickness to 0.
n DATALABELFITPOLICY= specifies a policy for avoiding collisions among the
bar labels when bar labels are displayed.
n STAT= now supports PROPORTION, which displays proportions in the range 0–
1.
n STAT=PCT now displays percentages in the range 0–100 in order to be
consistent with other GTL statements.
n TIP= now supports NONE, which suppressed data tips and URLs from the plot.
BARCHARTPARM:
Enhancements to SAS 9.4 Statements xxxi
n The baseline is now drawn by default. To suppress the baseline, use the
BASELINEATTRS= option to set the line thickness to 0.
n DATALABELFITPOLICY= specifies a policy for avoiding collisions among the
bar labels when bar labels are displayed.
n DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
n DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
n ERRORBARCAPSHAPE= specifies whether the error bars have a serif cap.
n TIP= now supports NONE, which suppressed data tips and URLs from the plot.
BLOCKPLOT:
n BLOCKLABEL= specifies alternative text to display for the internal block text
values.
n VALUEFITPOLICY= now supports the SPLIT, SPLITALWAYS, and NONE
policies.
n VALUESPLITCHAR= specifies one or more characters on which the values can
be split if needed.
n VALUESPLITCHARDROP= specifies whether the split characters are included in
the displayed values.
BOXPLOT:
n CAPSHAPE= now supports NONE, which specifies that no shape is displayed at
the ends of the box whiskers.
n DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
n DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
n DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
Enhancements to SAS 9.4 Statements xxxiii
n DISPLAYSTATS= specifies the statistics that are displayed for each box.
n TIP= now supports NONE, which suppressed data tips from the plot.
o DISPLAYSTATS= can be used with both vertical and horizontal box plots.
o CONNECTBREAK= specifies whether the connect line is broken for values
that have no observations.
o CAPSCALE= specifies a positive number to use as a multiplier for
determining the default width of the whisker caps.
o FILLPATTERNATTRS= specifies the appearance of the pattern-filled areas.
o DISPLAY= now supports FILLPATTERN, which displays the box fill pattern.
BOXPLOTPARM:
n CAPSHAPE= now supports NONE, which specifies that no shape is displayed at
the ends of the box whiskers.
n DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
n DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
n DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
n DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
n DATASKIN= enhances the visual appearance of the filled boxes.
n TIP= now supports NONE, which suppresses data tips from the plot.
o DISPLAYSTATS= can be used with both vertical and horizontal box plots.
o CONNECTBREAK= specifies whether the connect line is broken for values
that have no observations.
o CAPSCALE= specifies a positive number to use as a multiplier for
determining the default width of the whisker caps.
o FILLPATTERNATTRS= specifies the appearance of the pattern-filled areas.
o DISPLAY= now supports FILLPATTERN, which displays the box fill pattern.
BUBBLEPLOT:
n DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
n DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
n DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
n DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
n TIP= now supports NONE, which suppresses data tips and URLs from the plot.
n SAS 9.4M3 adds option DRAWORDER=, which specifies whether the bubbles
are drawn according to bubble size or according to data order.
n SAS 9.4M5 has the following enhancements:
CONTOURPLOTPARM:
n LEVELS= specifies a list of contour level values.
DENDROGRAM:
n TIP= now supports NONE, which suppresses data tips and URLs from the plot.
Enhancements to SAS 9.4 Statements xxxv
DENSITYPLOT:
n CURVELABELSPLIT= specifies whether to split the curve label at the specified
split characters.
n CURVELABELSPLITCHAR= specifies one or more characters on which the curve
label can be split if needed.
n CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the curve label text.
n CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the curve label block.
n WEIGHT= specifies a column that contains a density-curve calculation a priori
weight for each observation of the input data object.
n The KERNEL() distribution option WEIGHT= is changed to
WEIGHTFUNCTION=. This change enables the addition of the WEIGHT= option
in the DENSITYPLOT statement.
Note: The WEIGHT= option is not valid in the KERNEL() distribution option in
SAS 9.4. If you used the WEIGHT= option in the KERNEL() distribution option in
prior SAS releases, then you must change it to WEIGHTFUNCTION= in SAS 9.4
and later releases.
o GROUP= creates a separate density curve for each unique group value of the
specified column.
o INCLUDEMISSINGGROUP= specifies whether missing values of the group
variable are included in the plot.
DROPLINE:
n DATASKIN= enhances the appearance of the drop line.
n SAS 9.4M1 adds option DROPTO=BOTH, which draws one or more drop lines to
both the X and Y axes.
ELLIPSE:
n SAS 9.4M2 has the following enhancements:
o GROUP= creates a separate ellipse for each unique group value of the
specified column.
o INCLUDEMISSINGGROUP= specifies whether missing values of the group
variable are included in the plot.
n SAS 9.4M5 has the following enhancements:
ELLIPSEPARM:
n DISPLAY= now supports FILLPATTERN, which displays the ellipse fill pattern.
FRINGEPLOT:
n GROUP= creates a distinct set of lines for each unique group value in the
specified column.
n INCLUDEMISSINGGROUP= specifies whether missing values in the group
column are included in the plot.
n INDEX= specifies indices for mapping line attributes (color and line pattern) to
one of the GraphData1–GraphDataN style elements.
n TIP= now supports NONE, which suppresses data tips from the plot.
HEATMAPPARM:
n URL= specifies an HTML page to display when a rectangle is selected.
n TIP= now supports NONE, which suppresses data tips and URLs from the plot.
HIGHLOWPLOT:
n CLIPCAP= specifies whether a special clip cap is displayed to indicate where
clipping occurred.
n CLIPCAPSHAPE= specifies the shape of the arrowhead on the clipped end of a
line.
n DATASKIN= enhances the visual appearance of the high-low chart filled bars or
lines.
n ENDCAPDISPLAYPOLICY= specifies the policy for displaying end caps when
end caps are present.
n TIP= now supports NONE, which suppresses data tips from the plot.
HISTOGRAM:
n DATALABELTYPE= specifies the statistic to display at the end of each bar.
Enhancements to SAS 9.4 Statements xxxvii
o DATALABELATTRS= specifies the color and font attributes of the bar labels.
o FILLENDCOLOR=color specifies the end color of the bar fill color gradient.
o FILLTYPE=ALPHAGRADIENT replaces FILLTYPE=GRADIENT from the
previous releases. This option fills each bar with a color and a transparency
gradient that starts at the bar top with the initial transparency that is
assigned to that bar, and ends with full transparency at the bar baseline.
o FILLTYPE=COLORGRADIENT fills each bar with a color gradient that starts
with the fill color that is assigned to that bar and ends with the color that is
specified in the FILLENDCOLOR= option.
o FILLTYPE=GRADIENT is changed to an alias of
FILLTYPE=COLORGRADIENT.
HISTOGRAMPARM:
n DATALABELFITPOLICY= specifies a policy for avoiding collisions among the bin
labels when bin labels are displayed.
n DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
n DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
n DATASKIN= enhances the visual appearance of the filled bars.
n TIP= now supports NONE, which suppresses data tips from the plot.
o FILLENDCOLOR=color specifies the end color of the bar fill color gradient.
o FILLTYPE=ALPHAGRADIENT replaces FILLTYPE=GRADIENT from the
previous releases. This option fills each bar with a color and a transparency
gradient that starts at the bar top with the initial transparency that is
assigned to that bar, and ends with full transparency at the bar baseline.
o FILLTYPE=COLORGRADIENT fills each bar with a color gradient that starts
with the fill color that is assigned to that bar and ends with the color that is
specified in the FILLENDCOLOR= option.
o FILLTYPE=GRADIENT is changed to an alias of
FILLTYPE=COLORGRADIENT.
LINECHART:
n SAS 9.4M2 adds option GROUPORDER=REVERSEDATA, which orders the
groups within a category in the reverse group-column data order.
n SAS 9.4M3 has the following enhancements:
LINEPARM:
n CURVELABELSPLIT= specifies whether to split the line label at the specified
split characters.
n CURVELABELSPLITCHAR= specifies one or more characters on which the line
label can be split if needed.
n CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the line label text.
n CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the line label block.
LOESSPLOT:
n CURVELABELSPLIT= specifies whether to split the curve label at the specified
split characters.
n CURVELABELSPLITCHAR= specifies one or more characters on which the curve
label can be split if needed.
n CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the curve label text.
Enhancements to SAS 9.4 Statements xxxix
MODELBAND:
n SAS 9.4M2 has the following enhancements:
NEEDLEPLOT:
n BASELINEATTRS= specifies the appearance of the baseline. This option enables
you to suppress the baseline by setting the line thickness to 0.
n DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
n DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
n DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
n DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
n DATASKIN= enhances the appearance of the needle plot lines.
n TIP= now supports NONE, which suppresses data tips and URLs from the plot.
PBSPLINEPLOT:
n CURVELABELSPLIT= specifies whether to split the curve label at the specified
split characters.
n CURVELABELSPLITCHAR= specifies one or more characters on which the curve
label can be split if needed.
n CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the curve label text.
n CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the curve label block.
n SAS 9.4M2 changes the range of the PBSPLINEPLOT DEGREE= option from 0–
174 to 0–10 .
PIECHART:
n TIP= now supports NONE, which suppresses data tips and URLs from the plot.
xl What’s New in SAS 9.4 Graph Template Language
n SAS 9.4M1 adds option CENTERFIRSTSLICE=, which specifies whether the first
pie slice is centered on the starting angle or starts on it.
n SAS 9.4M3 adds sub option TRANSPARENCY= to the PIECHART statement
FILLATTRS= option. The new TRANSPARENCY= sub option sets the
transparency of the other slice unless transparency is specified in the
OTHERSLICEOPTS= option.
POLYGONPLOT:
n SAS 9.4M2 has the following enhancements:
REFERENCELINE:
n CURVELABELSPLIT= specifies whether to split the reference line label at the
specified split characters.
n CURVELABELSPLITCHAR= specifies one or more characters on which the
reference line label can be split if needed.
n CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the reference line label text.
n CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the reference line label block.
n DATASKIN= enhances the visual appearance of the reference line.
REGRESSIONPLOT:
n CURVELABELSPLIT= specifies whether to split the regression line label at the
specified split characters.
n CURVELABELSPLITCHAR= specifies one or more characters on which the
regression line label can be split if needed.
n CURVELABELSPLITCHARDROP= specifies whether the split characters are
included in the regression line label text.
n CURVELABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the regression line label block.
n SAS 9.4M2 changes the range of the DEGREE= regression option from 0–174 to
1–10.
Enhancements to SAS 9.4 Statements xli
SCATTERPLOT:
n CLUSTERAXIS= specifies the axis to use for clustering groups when
GROUPDISPLAY=CLUSTER.
n DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
n DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
n DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
n DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
n ERRORBARCAPSHAPE= specifies whether the error bars have a serif cap. SAS
9.4M2 changes the default of this option to style reference
GraphError:CapStyle.
n FILLEDOUTLINEDMARKERS= specifies whether markers are drawn with both
fills and outlines.
n JITTER= specifies whether to jitter data markers.
n LABELSTRIP= specifies whether leading and trailing blanks are stripped from
marker characters or fixed-position data labels before they are displayed in the
plot.
n MARKERATTRS= now supports transparency.
n TIP= now supports NONE, which suppresses data tips and URLs from the plot.
The new options are functionally the same as the deprecated options and
are more consistent with the other plot statements. The deprecated options
are still honored, but the new options are the preferred options.
o The OUTLINEDMARKERCHARACTERS= option is deprecated. It is still
honored, but the TEXTPLOT statement is now the preferred method for
creating scatter plots using text markers.
n SAS 9.4M3 adds option SUBPIXEL=, which specifies whether subpixel rendering
is used for image output when the scatter plot is rendered.
n SAS 9.4M5 adds option ERRORBARCAPSCALE=, which specifies a positive
number to use as a multiplier for determining the default width of the error-bar
caps.
SCATTERPLOTMATRIX:
n DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
n DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
n DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
n DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
n DATASKIN= enhances the visual appearance of the plot markers.
n ELLIPSE= now supports the CLIP= option, which specifies whether clipped
confidence ellipses are included in the plot.
n LABELSTRIP= specifies whether leading and trailing blanks are stripped from
marker characters or fixed-position data labels before they are displayed in the
plot.
n MARKERATTRS= now supports transparency.
SERIESPLOT:
n CLUSTERAXIS= specifies the axis to use for clustering groups when
GROUPDISPLAY=CLUSTER.
Enhancements to SAS 9.4 Statements xliii
n TIP= now supports NONE, which suppresses data tips and URLs from the plot.
Note: If you want to break the series line at missing X or Y variable values in
SAS 9.4M4 and later releases, set the Y variable value to missing when the X
variable value is missing. See “Programs That Use the SERIESPLOT
Statement” on page xix.
STEPPLOT:
n CLUSTERAXIS= specifies the axis to use for clustering groups when
GROUPDISPLAY=CLUSTER.
n DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
n DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
n DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
n DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
n DATASKIN= enhances the appearance of the step plot lines.
n TIP= now supports NONE, which suppresses data tips and URLs from the plot.
SURFACEPLOTPARM:
n SAS 9.4M2 replaces option SURFACECOLORGRADIENT= with the
COLORRESPONSE= option. The SURFACECOLORGRADIENT= option is
considered deprecated. The COLORRESPONSE= option is more consistent with
the other plot statements. The SURFACECOLORGRADIENT= option is still
honored, but the COLORRESPONSE= option is the preferred option.
TEXTPLOT:
n SAS 9.4M3 has the following experimental options:
o OUTFILE= specifies a file for storing information about the text bounding-
box for each text value in the column specified in the OUTID= option.
o OUTID= specifies a column that contains text values to write to the file
specified in the OUTFILE= option.
n SAS 9.4M5 has the following enhancements:
VECTORPLOT:
n DATALABELSPLIT= specifies whether to split the data labels at specified split
characters.
n DATALABELSPLITCHAR= specifies one or more characters on which the data
labels can be split if needed.
n DATALABELSPLITCHARDROP= specifies whether the split characters are
included in the data labels.
n DATALABELSPLITJUSTIFY= specifies the justification of the strings that are
inside the data label blocks.
n DATASKIN= enhances the appearance of the vector plot lines.
n TIP= now supports NONE, which suppresses data tips from the plot.
WATERFALLCHART:
n BARLABELFITPOLICY= specifies a policy for avoiding collisions among the bar
labels when bar labels are displayed.
n BASELINEATTRS= specifies the appearance of the baseline. This option enables
you to suppress the baseline by setting the line thickness to 0.
n TIP= now supports NONE, which suppresses data tips and URLs from the plot.
n SAS 9.4M3 adds option COLORSTAT=, which specifies the statistic to use for
computing the response colors.
n SAS 9.4M5 adds option CONNECTBREAK=, which specifies whether the
connect line is broken for values that have no observations.
ENTRYFOOTNOTE:
n HALIGNCENTER= specifies whether the footnote is centered automatically by
the system or is always centered in the graph area.
n SAS 9.4M1 removes the 512-character limit on the length of the footnote text.
ENTRYTITLE:
n HALIGNCENTER= specifies whether the title is centered automatically by the
system or is always centered in the graph area.
n SAS 9.4M1 removes the 512-character limit on the length of the title text.
xlviii What’s New in SAS 9.4 Graph Template Language
o TICKDISPLAYLIST= specifies the text that is displayed for the tick values
that are defined in the TICKVALUELIST= option.
o TICKVALUEFITPOLICY= supports new fit policies: ROTATE,
ROTATEALWAYS, ROTATELAWAYSDROP, SPLIT, SPLITALWAYS,
SPLITALWAYSTHIN, SPLITTHIN, and SPLITROTATE.
o TICKVALUELIST= specifies the list of tick values that are displayed on the
axis.
o TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
Enhancements to SAS 9.4 Statements xlix
o MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
o MINORGRIDATTRS= specifies the attributes of the minor grid lines.
o MINORTICKCOUNT= specifies the number of minor ticks that are displayed
on the axis.
o MINORTICKS= specifies whether the minor tick marks are displayed on the
axis.
o TICKDISPLAYLIST= specifies the text that is displayed for the tick values
that are defined in the TICKVALUELIST= option.
o TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
o TICKVALUEFORMAT= now supports EXTRACTSCALETYPE=, which enables
you to specify the type of scale that you want to extract.
o TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
o SAS 9.4M1 adds option INCLUDERANGES=, which specifies the ranges for a
broken axis.
o SAS 9.4M2 has the following enhancements:
n The MINORGRID= option defaults to style reference
GraphMinorGridLines:DisplayOpts.
n The MINORGRIDATTRS= option defaults to style element
GraphMinorGridLines in order to visually contrast the major and minor
grid lines.
n The MINORTICKCOUNT= option for linear axes defaults to one minor
tick and two intervals.
l What’s New in SAS 9.4 Graph Template Language
o MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
o MINORGRIDATTRS= specifies the attributes of the minor grid lines.
o MINORTICKCOUNT= specifies the number of minor ticks that are displayed
on the axis.
o TICKVALUELIST= specifies the tick values for a log axis as a space-
separated list.
o TICKVALUEPRIORITY= specifies whether the TICKVALUELIST=
specification can extend the axis data range.
o VALUETYPES= specifies how the VIEWMIN=, VIEWMAX=, and
TICKVALUELIST= option values are interpreted.
o SAS 9.4M2 has the following enhancements:
n The MINORGRID= option defaults to style reference
GraphMinorGridLines:DisplayOpts.
n The MINORGRIDATTRS= option defaults to style element
GraphMinorGridLines in order to visually contrast the major and minor
grid lines.
o SAS 9.4M3 adds option TICKVALUEFORMAT=, which specifies how to
format the values for major tick marks.
n TIMEOPTS= supports the following new features for time axes:
o MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
o MINORGRIDATTRS= specifies the attributes of the minor grid lines.
o MINORTICKINTERVAL= specifies the time interval between minor ticks.
o TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
o TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
o SAS 9.4M1 adds option INCLUDERANGES=, which specifies the ranges for a
broken axis.
o SAS 9.4M2 has the following enhancements:
n The MINORGRID= option defaults to style reference
GraphMinorGridLines:DisplayOpts.
n The MINORGRIDATTRS= option defaults to style element
GraphMinorGridLines in order to visually contrast the major and minor
grid lines.
o SAS 9.4M3 adds option INTERVALMULTIPLIER=, which specifies a multiplier
to apply to the time interval that is in effect for the axis.
Enhancements to SAS 9.4 Statements li
LAYOUT OVERLAY3D:
n LINEAROPTS= supports the following new features for linear axes:
o MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
o MINORGRIDATTRS= specifies the attributes of the minor grid lines.
o MINORTICKCOUNT= specifies the number of minor ticks that are displayed
on the axis.
o MINORTICKS= specifies whether the minor tick marks are displayed on the
axis.
o TICKDISPLAYLIST= specifies the text that is displayed for the tick values
that are defined in the TICKVALUELIST= option.
o TICKVALUEFORMAT= now supports EXTRACTSCALETYPE=, which enables
you to specify the type of scale that you want to extract.
o TICKVALUEPRIORITY= specifies whether the TICKVALUELIST=
specification can extend the axis data range.
o SAS 9.4M2 changes the MINORGRIDATTRS= option default to style element
GraphMinorGridLines in order to visually contrast the major and minor grid
lines.
n TIMEOPTS= supports the following new features for time axes:
o MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
o MINORGRIDATTRS= specifies the attributes of the minor grid lines.
o MINORTICKINTERVAL= specifies the time interval between minor ticks.
o SAS 9.4M2 changes the MINORGRIDATTRS= option default to style element
GraphMinorGridLines in order to visually contrast the major and minor grid
lines.
o SAS 9.4M3 adds option INTERVALMULTIPLIER=, which specifies a multiplier
to apply to the time interval that is in effect for the axis.
LAYOUT OVERLAYEQUATED:
n MINORGRID= specifies whether grid lines are displayed at the minor tick values.
n VIEWMAX= specifies the maximum data value to include in the display (the
value might be adjusted by the threshold calculation).
n VIEWMIN= specifies the minimum data value to include in the display (the
value might be adjusted by the threshold calculation).
n SAS 9.4M3 adds option LINEEXTENT=, which specifies the extent of the axis
lines.
LAYOUT LATTICE:
n LABELFITPOLICY= specifies a policy for fitting axis labels in the available
space.
n LABELPOSITION= specifies the position of the axis label.
o TICKDISPLAYLIST= specifies the text that is displayed for the tick values
that are defined in the TICKVALUELIST= option.
o TICKVALUEFITPOLICY= supports new fit policies: ROTATE,
ROTATEALWAYS, ROTATEALWAYSDROP, SPLIT, SPLITALWAYS,
SPLITALWAYSTHIN, and SPLITTHIN.
o TICKVALUELIST= specifies the list of tick values that are displayed on the
axis.
o TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
o TICKVALUESPLITCHAR= specifies a list of characters on which the tick
values can be split if needed.
o TICKVALUESPLITJUSTIFY= specifies justification of the strings that are
inside the tick value block.
o TICKVALUESPLITCHARDROP= specifies whether the split characters are
included in the displayed tick values.
o SAS 9.4M3 adds option TICKVALUEFORMAT=, which specifies how to
format the values for major tick marks.
o SAS 9.4M5 has the following enhancements:
Enhancements to SAS 9.4 Statements liii
o MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
o MINORGRIDATTRS= specifies the attributes of the minor grid lines.
o MINORTICKCOUNT= specifies the number of minor ticks that are displayed
on the axis.
o MINORTICKS= specifies whether the minor tick marks are displayed on the
axis.
o TICKDISPLAYLIST= specifies the text that is displayed for the tick values
that are defined in the TICKVALUELIST= option.
o TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
o TICKVALUEFORMAT= now supports EXTRACTSCALETYPE=, which enables
you to specify the type of scale that you want to extract.
o TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
o SAS 9.4M3 adds option TICKVALUEFORMAT=, which specifies how to
format the values for major tick marks.
o SAS 9.4M5 adds option TICKVALUEROTATION=DIAGONAL2, which rotates
the tick values to a –45-degree diagonal position.
n LOGOPTS= supports the following new features for log axes:
o MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
o MINORGRIDATTRS= specifies the attributes of the minor grid lines.
o MINORTICKCOUNT= specifies the number of minor ticks that are displayed
on the axis.
o TICKVALUELIST= specifies the tick values for a log axis as a space-
separated list.
o TICKVALUEPRIORITY= specifies whether the TICKVALUELIST=
specification can extend the axis data range.
o VALUETYPES= specifies how the VIEWMIN=, VIEWMAX=, and
TICKVALUELIST= option values are interpreted.
o SAS 9.4M3 adds option TICKVALUEFORMAT=, which specifies how to
format the values for major tick marks.
liv What’s New in SAS 9.4 Graph Template Language
o MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
o MINORGRIDATTRS= specifies the attributes of the minor grid lines.
o MINORTICKINTERVAL= specifies the time interval between minor ticks.
o TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
o TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
o SAS 9.4M3 has the following enhancements:
n TICKVALUEFORMAT= specifies how to format the values for major tick
marks.
n INTERVALMULTIPLIER= specifies a multiplier to apply to the time
interval that is in effect for the axis.
o SAS 9.4M5 adds option TICKVALUEROTATION=DIAGONAL2, which rotates
the tick values to a –45-degree diagonal position.
o TICKDISPLAYLIST= specifies the text that is displayed for the tick values
that are defined in the TICKVALUELIST= option.
o TICKVALUEFITPOLICY= supports new fit policies: ROTATE,
ROTATEALWAYS, ROTATEALWAYSDROP, SPLIT, SPLITALWAYS,
SPLITALWAYSTHIN, and SPLITTHIN.
o TICKVALUELIST= specifies the list of tick values that are displayed on the
axis.
Enhancements to SAS 9.4 Statements lv
o MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
o MINORGRIDATTRS= specifies the attributes of the minor grid lines.
o MINORTICKCOUNT= specifies the number of minor ticks that are displayed
on the axis.
o MINORTICKS= specifies whether the minor tick marks are displayed on the
axis.
o TICKDISPLAYLIST= specifies the text that is displayed for the tick values
that are defined in the TICKVALUELIST= option.
o TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
o TICKVALUEFORMAT= now supports EXTRACTSCALETYPE=, which enables
you to specify the type of scale that you want to extract.
o TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
o SAS 9.4M2 changes the MINORGRIDATTRS= option default to style element
GraphMinorGridLines in order to visually contrast the major and minor grid
lines.
o SAS 9.4M5 adds option TICKVALUEROTATION=DIAGONAL2, which rotates
the tick values to a –45-degree diagonal position.
n LOGOPTS= supports the following new features for log axes:
o MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
lvi What’s New in SAS 9.4 Graph Template Language
o MINORGRID= specifies whether grid lines are displayed at the minor tick
values.
o MINORGRIDATTRS= specifies the attributes of the minor grid lines.
o MINORTICKINTERVAL= specifies the time interval between minor ticks.
o TICKVALUEFITPOLICY= now supports policies NONE and
ROTATEALWAYS.
o TICKVALUEROTATION= specifies how the tick values are rotated on the X
and X2 axes.
o SAS 9.4M2 changes the MINORGRIDATTRS= option default to style element
GraphMinorGridLines in order to visually contrast the major and minor grid
lines.
o SAS 9.4M3 adds option INTERVALMULTIPLIER=, specifies a multiplier to
apply to the time interval that is in effect for the axis.
o SAS 9.4M5 adds option TICKVALUEROTATION=DIAGONAL2, which rotates
the tick values to a –45-degree diagonal position.
VALUE statement:
n TEXTATTRS= specifies the text attributes to use when an attribute map is
applied to text in a plot.
Documentation Enhancements
In SAS 9.4M2, SAS Graph Template Language: User’s Guide is reorganized to make it
easier to find information about how to use the Graph Template Language.
lviii What’s New in SAS 9.4 Graph Template Language
1
PART 1
Fundamentals
Chapter 1
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2
3
1
Overview
using GTL, you can generate Model-Fit plots, Distribution Plots, Comparative plots,
Prediction Plots, and more.
The graphics produced by GTL are generated by template definitions that control
the graph format and appearance and specify the variable roles to represent in the
graph display. The graph can then be rendered by associating the templates with a
data source.
n The GTL templates are defined with PROC TEMPLATE. GTL includes
conditional statements that can be used to determine what graph features are
rendered. It also includes layout statements that specify the arrangement of
graph features, plot statements that request specific plot types (such as
histograms and scatter plots), and text and legend statements that specify
titles, footnotes, legends, and other text-based graph elements.
n The GTL templates are rendered using the SGRENDER procedure, which
specifies a data source that contains appropriate data values and the template
to use for rendering the graph.
n You can also modify predefined GTL templates that SAS delivers for use on the
SAS statistical procedures. For information about modifying existing templates,
refer to ODS Graphics Template Modification in SAS/STAT User’s Guide.
This manual provides a complete reference to the Graph Template Language. For
detailed usage information, consult the SAS Graph Template Language: User’s Guide.
Note: If you are also a SAS/GRAPH user, then you might want to consult the SAS
Graph Template Language: User’s Guide to learn about some of the distinctions
between ODS Graphics and SAS/GRAPH.
A Quick Example
The data set Sashelp.Class is delivered with SAS. It includes data columns named
Height and Weight, which store height and weight measures for a small sample of
subjects. The Graph Template Language can be used to generate a histogram that
shows the distribution of weight recorded in that data set:
Graph Template Language (GTL) 5
n The ODS GRAPHICS statement uses the WIDTH= option to set a width for the
output graph. Because the HEIGHT= option is not specified, GTL manages the
graph’s aspect ratio and sets an appropriate height.
n The DATA= option on PROC SGRENDER specifies Sashelp.Class as the data
source for the graph. TEMPLATE= specifies HISTOGRAM as the template
definition to use for rendering the graph.
Template Compilation
A GTL template describes the structure and appearance of a graph to be produced,
similar to how a TABLE template describes the organization and content of a table.
All templates are stored, compiled programs. The following source program
produces a simple GTL template named SCATTER:
proc template;
define statgraph scatter;
begingraph;
layout overlay;
scatterplot x=height y=weight;
endlayout;
endgraph;
end;
run;
When this code is submitted, the statement keywords and options are parsed, just
as with any other procedure. If no syntax error is detected, then an output template
named SCATTER is created and stored in the default template folder
Sasuser.Templat. No graph is produced. Note the following:
n Any required arguments in the template must be specified. In this example, X=
and Y= in the SCATTERPLOT statement must specify variables for the analysis,
but no checking for the existence of these variables is done at compile time.
(Unlike other SAS procedures, PROC TEMPLATE does not perform a compile
and then run sequence, which includes variable validation.)
n No reference to an input data set appears in the template.
Run-Time Actions
To produce a graph, a GTL template must be bound to a data source using the
SGRENDER procedure. The following example uses SGRENDER to bind the
SCATTER template to the SAS data set Sashelp.Class, which is delivered with SAS:
proc sgrender data=sashelp.class
template=scatter;
run;
Components of a Graph 7
After all the observations have been read, the data object and template definition
are passed to a graph renderer, which produces the graph image. The image is then
automatically integrated into the ODS destination. The visual properties of the
graph are determined by the ODS style that is in effect.
Note: Template SCATTER is a restrictive definition: it can create a plot only with
columns named Height and Weight. A GTL template can be made more flexible by
introducing dynamic variables or macro variables that supply variables and other
information at run time. For more information, see “Flexible Templates” on page
14.
Components of a Graph
In general, a graph is made of up of the following parts:
n titles and footnotes
1 Graph
a visual representation of data. The graph can contain titles, footnotes, legends,
and one or more cells that have one or more plots.
2 Cell
a distinct rectangular subregion of a graph that can contain plots, text, and
legends.
3 Title
descriptive text that is displayed above any cell or plot areas in the graph.
4 Plot
a visual representation of data such as a scatter plot, a series line, a bar chart, or
a histogram. Multiple plots can be overlaid in a cell.
5 Legend
refers collectively to the legend border, one or more legend entries (where each
entry has a symbol and a corresponding label) and an optional legend title.
6 Axis
refers collectively to the axis line, the major and minor tick marks, the major tick
mark values, and the axis label. Each cell has a set of axes that are shared by all
the plots in the cell. In multi‐cell graphs, the columns and rows of cells can
share common axes if the cells have the same data type.
7 Footnote
Graphical Layouts 9
descriptive text that is displayed below any cell or plot areas in the graph.
Graphical Layouts
One of most powerful features of GTL is the syntax built around hierarchical
statement blocks called “layouts.” The outermost layout block determines
n The overall organization of the graph—whether it uses a single-cell or a multi-
cell display.
n What statements are allowed in the block. Generally, layout blocks can contain
plots, lines of text, a legend, or even another layout.
n How the contained statements interact.
Layout Description
For example, the following graph is a two-cell graph produced using the LAYOUT
LATTICE statement as the outermost template in the layout.
10 Chapter 1 / Overview
layout overlay;
scatterplot x=weight y=mpg_city / group=origin;
regressionPlot x=weight y=mpg_city / degree=2;
endlayout;
sidebar;
discretelegend "cars";
endsidebar;
endlayout;
endgraph;
end;
run;
For detailed information about each layout, see the chapter for that layout type.
Axes 11
Plots
The plots in GTL are classified in different ways, depending on the context of the
discussion.
Within layout blocks, plots are often classified according to graphical dimension:
whether they are projected in two or three visual dimensions. Thus, plots in GTL are
often referred to as 2-D or 3-D plots, based on their graphical dimensions, not their
data dimensions.
Relative to their input data, plots are classified according to the statements that
calculate summary statistics from raw input data, and those that use calculated
statistics as input parameters on the plot statement. Thus, many GTL plot
statements have two versions: BARCHART and BARCHARTPARM, HISTOGRAM
and HISTOGRAMPARM, and so on. The main distinction between such plots is the
nature of the input data that they accept:
n The “non-parm” version (for example, BARCHART) computes its values from
raw, unsummarized data. For example, a BARCHART computes the summary
values it needs for the bars in the chart. Such plots are often referred to as
“computed plots.”
n The “parm” version (for example, BARCHARTPARM) does not summarize or
compute values from the input data but instead simply renders the input data it
is given. Thus, the input data must be pre-summarized, perhaps by a SAS
procedure. The “parm” version of plots, often referred to as “parameterized
plots,” produce the same result as the non-parm version. However, they do not
perform the calculations or data summarizations needed to achieve the result.
Chapter 5, “Key Concepts for Using Plots,” on page 201 discusses general concepts
that apply across plot types. For detailed information about a particular plot, see
the chapter for that plot.
Axes
GTL uses various criteria to determine the displayed axis features for a graph.
Generally, axis features are based on the following criteria:
n the layout type
n the order of plot statements in the layout and the options specified on those
statements
n the use of “primary” and “secondary” axes on the plots (when secondary axes
are supported)
12 Chapter 1 / Overview
Depending on the layout type, 2-D plots can have up to four independent axes that
can be displayed: X, Y, X2, and Y2. The X and Y axes are considered the primary
axes, and the X2 and Y2 axes are considered the secondary axes. By default, the X2
and Y2 axes are not displayed. When requested, the secondary axes can be
displayed as copies of the primary axes, or data can be mapped separately to them.
The following figure identifies the X, Y, X2, and Y2 axes.
For more information about axis features in GTL, see Chapter 7, “Axis Features in
Layouts,” on page 1039.
Legends 13
Legends
Many plot statements support a GROUP= option that partitions the data into
unique values, performs separate analysis, if necessary, and automatically assigns
distinct visual properties to each group value. The visual properties of group values
are defined by the style in effect.
Legends are not automatically displayed for plots with group values. Rather, an
appropriate legend statement must be added to the template to generate the
desired legend. In the following example, a legend is added to display markers and
line patterns that show the association between the group values from a scatter
plot and corresponding linear regression lines. The example shows the mechanism
that GTL uses to associate a legend with its corresponding plot(s): a name is
assigned to each plot that must be represented in the legend, and these names are
then used as arguments for the legend statement (in this case, MERGEDLEGEND).
proc template;
define statgraph scatterfit;
begingraph;
entrytitle "Linear Regression By Gender";
layout overlay;
scatterplot x=height y=weight / group=sex name="scat";
regressionplot x=height y=weight/ group=sex name="reg";
mergedlegend "scat" "reg" / border=true;
endlayout;
endgraph;
end;
run;
For more information about managing legends in GTL, see SAS Graph Template
Language: User’s Guide.
14 Chapter 1 / Overview
Flexible Templates
Several features in GTL can make template definitions less restrictive on input data
and more general in nature. These features enable a single compiled template to
produce many output variations.
Expressions are also useful in text statements like ENTRY and ENTRYTITLE. Both
of these statements support rich text and have special text commands such as
{SUP}, {SUB}, and {UNICODE}, which enable subscripting, superscripting, and
Unicode characters.
The following template shows how the ± symbol is included in the title line using
its hexadecimal Unicode value. Also, new data columns are computed for the upper
and lower error bars of the scatter plot, based on the input columns MeanWeight
and STDERR.
proc template;
define statgraph expression;
begingraph;
entrytitle "Errorbars show " {unicode "00B1"x} "2 SE";
layout overlay;
scatterplot x=age y=meanweight /
yerrorlower=eval(meanweight - 2*stderr)
yerrorupper=eval(meanweight + 2*stderr);
seriesplot x=age y=meanweight;
endlayout;
endgraph;
end;
run;
For more information about using expressions, see Chapter 21, “Expressions,” on
page 1539. For more information about using functions, see Chapter 22, “Functions,”
on page 1543.
Template
Statement Purpose Value supplied by...
The following example defines a template named DYNAMICS that can create a
histogram and density plot for any variable. It defines both macro variables and
dynamic variables for run-time substitution. No data-dependent information is hard
coded in the template.
Note: You can initialize macro variables with %LET statements and dynamic
variables with SGRENDER’s DYNAMIC statement.
proc template;
define statgraph dynamics;
mvar SYSDATE9 SCALE;
nmvar BINS;
dynamic VAR VARLABEL;
begingraph;
entrytitle "Histogram of " VAR;
entrytitle "with Normal Distribution";
layout overlay / xaxisopts=(label=VARLABEL);
histogram VAR / scale=SCALE nbins=BINS;
densityplot VAR / normal();
endlayout;
entryfootnote halign=right "Created: " SYSDATE9 /
textattrs=GraphValueText;
endgraph;
end;
run;
%let bins=6;
%let scale=count;
proc sgrender data=sashelp.class
16 Chapter 1 / Overview
template=dynamics;
dynamic var="Height" varlabel="Height in Inches";
run;
For more information about using dynamic variables and macro variables, see
Chapter 20, “Dynamic Variables and Macro Variables,” on page 1535.
Conditional Logic
Using conditional logic, you can create templates that have multiple visual results
or output representations, depending on existing conditions. The evaluation of a
logical expression must generate one or more complete statements (not portions of
statements). All conditional logic uses one of the following constructs:
if (condition) if (condition)
statement(s); statement(s);
endif; else
statement(s);
endif;
Note that the legend syntax does not have to be made conditional. At run time,
each plot name in the legend is checked. If the plot does not exist, then its name is
removed from the legend name list. If no names appear in the DISCRETELEGEND
statement, then the legend “drops out” and the histogram size is adjusted to fill the
remaining space.
For more information about using conditional logic, see Chapter 23, “Conditional
Logic,” on page 1555.
Output
When using GTL, you focus primarily on defining template definitions that produce
specific graphs and generate a particular output layout. Ultimately, you must also
customize the graphical environment to get the exact output that you desire. The
ODS GRAPHICS statement is available for customizing the graphical environment,
and ODS styles enable you to manage the output appearance.
The following ODS GRAPHICS statement uses the HEIGHT= and WIDTH= options
to set an aspect ratio for the output image.
18 Chapter 1 / Overview
For more information about using the ODS GRAPHICS statement in GTL, see SAS
Graph Template Language: User’s Guide. For a more complete discussion of the ODS
GRAPHICS statement, see “ODS GRAPHICS Statement” on page 1561.
ODS Styles
When any graphics template is executed, there is always an ODS style in effect
that governs the appearance of the output. The following ODS statement sends
graphics output to the RTF output destination using the LISTING style:
ods rtf style=listing;
Support for ODS styles is highly integrated into GTL syntax. By default, the
graphical appearance features of most plot and text statements are mapped to
corresponding style elements and associated attributes. Because of this, your
output tables and graphs always have a reasonable overall appearance. Moreover,
output for a given ODS destination has a consistent look (for example, table colors
and graph colors do not clash).
The following figures show how a graph’s appearance can be changed by using
references to style elements to set the graph’s appearance options. This technique
permits changes in graph appearance by style modification instead of graphical
template modification. The graphs in the figures are generated with the following
GTL statement:
contourplotparm x=x y=y z=density /
contourtype=fill nhint=9
colormodel=ThreeColorRamp ;
The following style template shows the definition for the ThreeColorRamp style
element:
style ThreeColorRamp /
endcolor = GraphColors("gramp3cend")
neutralcolor = GraphColors("gramp3cneutral")
startcolor = GraphColors("gramp3cstart");
About the Examples in This Documentation 19
For more information about the use of ODS styles in GTL, see SAS Graph Template
Language: User’s Guide. For a more complete discussion of ODS styles, see SAS
Output Delivery System: User’s Guide.
If you generate the example graphs using an HTML destination, they are typically
rendered as 640 pixel by 480 pixel images using the HTMLBlue style. Because of
size limitations, the graphs in this document are not shown in their default size.
They are scaled down to meet the size requirements of our documentation
production system. When graphs that are produced with ODS graphics are reduced
in size, several automatic processes take place to optimize the appearance of the
output. Among the differences between default size graphs and smaller graphs are
that the smaller graphs have scaled down font sizes. Also, their numeric axes might
display a reduced number of ticks and tick values. Thus, the graphs that you
generate from the example programs will not always look identical to the graphs
that are shown in the figures. However, both graphs will accurately represent the
data.
When you produce your own graphical output, you can change the graph size and
attributes, if needed. The SAS Graph Template Language: User’s Guide explains how
to set fonts, DPI, anti-aliasing, and other features that contribute to producing
professional-looking graphics of any size in any output format.
Note: The SAS Knowledge Base content is currently available only in English.
n The Graphics Samples Output Gallery in the SAS Knowledge Base is a collection
of graphs organized by SAS procedure. The graphs link to the source code. The
gallery is maintained by SAS Technical Support.
Examples and Resources on the Web 21
https://support.sas.com/en/knowledge-base/graph-samples-gallery.html
n The Focus Area Graphics site provides a simple interface to business and
analytical graphs. The site is maintained by the SAS Data Visualization team.
https://support.sas.com/rnd/datavisualization/index.htm
n You can share your questions, suggestions, and experiences related to graphics
on the Graphics Programming community site.
https://communities.sas.com/t5/Graphics-Programming/bd-p/sas_graph.
sas.com/training.
22 Chapter 1 / Overview
23
PART 2
Graph Block
Chapter 2
BEGINGRAPH Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
24
25
2
BEGINGRAPH Statement
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
BEGINGRAPH Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Dictionary
BEGINGRAPH Statement
Defines the outermost container for a graph template that is defined with GTL-statements.
Requirements: All STATGRAPH template definitions must start with a BEGINGRAPH statement
and end with an ENDGRAPH statement.
The BEGINGRAPH block must contain one and only one layout block.
The layout block and its nested layouts, if any, must contain at least one plot.
Syntax
BEGINGRAPH </options>;
<GTL-global-statements>
GTL-layout-block
<GTL-global-statements>
ENDGRAPH;
26 Chapter 2 / BEGINGRAPH Statement
Axis options
BEGINGRAPH Statement 27
Label options
LABELPLACEMENT=AUTO | GREEDY | SA
specifies the label-placement algorithm to use for positioning labels in
the graphs.
SAPLACEMENTOPTS=(placement-options)
specifies the options for the label-placement algorithm when
LABELPLACEMENT=SA.
Midpoint options
INCLUDEMISSINGDISCRETE=TRUE | FALSE
specifies whether missing values are displayed on a discrete axis.
Optional Arguments
ATTRPRIORITY=AUTO | COLOR | NONE
specifies a priority for cycling the group attributes.
AUTO
honors the current state of the attribute priority rotation pattern as specified
in the active style or in the ODS GRAPHICS statement.
COLOR
changes the current setting of attribute priority rotation pattern to the color-
priority pattern by cycling through the list of colors while holding the marker
symbol, line pattern, or fill pattern constant. When all of the colors are
exhausted, the MarkerSymbol, LineStyle, or FillPattern attribute increments
to the next element, and then the colors in the list are repeated. This pattern
repeats as needed.
NONE
changes the current setting of attribute priority rotation pattern to the
default pattern, which cycles progressively through the attribute lists.
Tip Use NONE if you want groups to be distinguished by color, marker, and
line changes for all ODS styles that use color.
Default The attribute priority pattern that is specified in the active style or
in the ODS GRAPHICS statement.
28 Chapter 2 / BEGINGRAPH Statement
Interactions This option overrides the attribute priority rotation pattern that is
specified in the current style and the ATTRPRIORITY= option in the
ODS GRAPHICS statement.
Default SQUIGGLE
Requirements The AXISBREAKTYPE= option must be set to AXIS for this option
to have any effect.
The DISPLAY= option for the axis must include the axis line for
this option to have any effect.
AXISBREAKTYPE=FULL | AXIS
specifies whether the axis break is indicated in the full display or only on the
axis line.
BEGINGRAPH Statement 29
The following figure shows an example of each type for ranges 50–52 and 56–73
on a linear horizontal axis.
Default FULL
The axis line or the plot wall outline must be displayed for AXIS
to have any effect. Otherwise, FULL is used.
Interaction When AXIS is specified, if the secondary axis line or the plot wall
outline is displayed, then the axis break symbol is displayed on
both the primary and the secondary axis. Otherwise, the break
symbol is displayed only on the primary axis, as shown in Figure
2.2 on page 29.
Notes The axis break indicators pass through inner margin areas.
FULL
specifies axis lines that extend along the entire length of the axis.
DATA
specifies axis lines that extend through the data range from the minimum
offset to the maximum offset.
30 Chapter 2 / BEGINGRAPH Statement
number
specifies, as a decimal proportion, how much the axis line extends from
DATA toward FULL. A value of 0 is equivalent to DATA, and a value of 1 is
equivalent to FULL.
Range 0–1
Tip A numeric value is useful for bar charts when DATA terminates the
axis line at the midpoint positions of the minimum and maximum
bars. In that case, you can specify a numeric value to lengthen the
axis line so that it extends to the full width of both bars.
The following figure shows a simple example of each value for the X axis and Y-
axis lines. The light-blue dashed lines depict the minimum and maximum offsets
that are set on the axes.
Default FULL
Tips The graph wall outline might appear to be an axis line. In that case,
use the WALLDISPLAY=NONE or WALLDISPLAY=(FILL) option in
the layout statement to suppress the wall outline.
Use the LINEEXTENT= axis option to control the axis line extent on
a per-axis basis.
BACKGROUNDCOLOR=style-reference | color
specifies the color of the graph background.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the
style attribute named Color or ContrastColor is used.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the graph.
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element .
DATACOLORS=(color-list)
specifies the list of fill colors that will replace the graph data colors from the
GraphData1–GraphDataN style elements.
(color-list)
a space-separated list of colors, enclosed in parentheses. You can use a style
attribute reference such as GraphData3:color, a color name, or an RGB,
CMYK, HLS, or HSV (HSB) color code to specify a color. The list can contain
a mix of style attribute references, color names, and color codes.
When this option is specified, the fill colors rotate through this color list rather
than through the colors that are defined in the GraphData1–GraphDataN style
elements. For information about the attribute rotation patterns, see “Attribute
Rotation Patterns” in SAS Graph Template Language: User’s Guide.
Tip When specifying data attributes for multiple plots, the attributes
might not be assigned consistently in some cases. To ensure
consistent attribute assignments, specify option
CYCLEATTRS=FALSE in the layout statement.
DATACONTRASTCOLORS=(color-list)
specifies the list of contrast colors that will replace the graph data contrast
colors from the GraphData1–GraphDataN style elements.
(color-list)
a space-separated list of contrast colors, enclosed in parentheses. You can
use a style attribute reference such as GraphData3:color, a color name, or an
32 Chapter 2 / BEGINGRAPH Statement
RGB, CMYK, HLS, or HSV (HSB) color code to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
When this option is specified, the contrast colors cycle through this color list
rather than through the contrast colors that are defined in the GraphData1–
GraphDataN style elements. For information about the attribute rotation
patterns, see “Attribute Rotation Patterns” in SAS Graph Template Language:
User’s Guide.
Tip When specifying data attributes for multiple plots, the attributes
might not be assigned consistently in some cases. To ensure
consistent attribute assignments, specify option
CYCLEATTRS=FALSE in the layout statement.
DATAFILLPATTERNS=(fill-pattern-list)
specifies the list of fill patterns that will replace the graph data fill patterns
from the GraphData1–GraphDataN style elements, if specified.
(fill-pattern-list)
a space-separated list of fill patterns, enclosed in parentheses. You can use a
style attribute reference such as GraphData3:fillpattern or a two-character
fill-pattern name such as L1, X5, and so on, to specify a fill pattern. The list
can contain a mix of style attribute references and pattern names.
When this option is specified, the fill patterns rotate through this fill-pattern list
rather than through the fill patterns that are defined in the GraphData1–
GraphDataN style elements, if any. For information about the attribute rotation
patterns, see “Attribute Rotation Patterns” in SAS Graph Template Language:
User’s Guide.
Tip When specifying data attributes for multiple plots, the attributes
might not be assigned consistently in some cases. To ensure
consistent attribute assignments, specify option
CYCLEATTRS=FALSE in the layout statement.
DATALINEPATTERNS=(line-pattern-list)
specifies the list of line patterns that will replace the graph data line patterns
from the GraphData1–GraphDataN style elements.
(line-pattern-list)
a space-separated list of line patterns, enclosed in parentheses. You can use
a style attribute reference such as GraphData3:LineStyle, a line pattern
number, or a line pattern name (where applicable) to specify a pattern. The
list can contain a mix of style attribute references, line pattern numbers, and
line pattern names.
When this option is specified, the line patterns cycle through this line-pattern
list rather than through the line patterns that are defined in the GraphData1–
GraphDataN style elements. When the patterns in line-pattern-list are
exhausted, the patterns repeat.
Tip When specifying data attributes for multiple plots, the attributes
might not be assigned consistently in some cases. To ensure
consistent attribute assignments, specify option
CYCLEATTRS=FALSE in the layout statement.
Restriction Starting with SAS 9.4M1, the maximum number of skinned graphical
elements is limited to 200 per plot in an OVERLAY or PROTOTYPE
layout. When this limit is exceeded for a plot, the specified data skin
is not applied to that plot. In that case, use the DATASKINMAX=
option in your ODS GRAPHICS statement to increase the maximum
limit.
Note Applying data skins to a graph that has a very large number of
markers can negatively impact performance.
DATASYMBOLS=(marker-symbol-list)
specifies the list of marker symbols that will replace the graph data marker
symbols from the marker symbols that are defined in the GraphData1–
GraphDataN style elements.
(marker-symbol-list)
a space-separated list of marker symbols, enclosed in parentheses. You can
use a style attribute reference such as GraphData5:markerSymbol or a
marker symbol name to specify a marker. The list can contain a mix of style
attribute references and marker symbol names.
When this option is specified, the marker symbols cycle through this marker
symbol list rather than through the line patterns that are defined in the
GraphData1–GraphDataN style elements. When the symbols in marker-symbol-
list are exhausted, the symbols repeat.
DESIGNHEIGHT=DEFAULTDESIGNHEIGHT | dimension
specifies the design height of the graph.
Restriction The minimum dimension value that you can set is 2 pixels. If a
smaller setting is specified, then the default design height is used.
Interactions The design height can be overridden at run time with a render
height that is specified with the HEIGHT= option in the ODS
GRAPHICS statement (external to the template). Also, the ODS
destination statement’s IMAGE_DPI= option can affect the height.
BEGINGRAPH Statement 35
You can change the value of the Design Height registry key in the
SAS registry. However, doing so affects the design height of all
templates that do not include an explicit dimension for the design
height. You can also change the height setting in the graph style,
but doing so affects the height of all templates that use that style.
DESIGNWIDTH=DEFAULTDESIGNWIDTH | dimension
specifies the design width of the graph.
Restriction The minimum dimension value that you can set is 2 pixels. If a
smaller setting is specified, then the default design width is used.
Interactions The design width can be overridden at run time with a render width
that is specified with the WIDTH= option in the ODS GRAPHICS
statement (external to the template). Also, the ODS destination
statement’s IMAGE_DPI= option can affect the width.
You can change the value of the Design Width registry key in the
SAS registry. However, doing so affects the design width of all
templates that do not include an explicit dimension for the design
width. You can also change the width setting in the graph style, but
doing so affects the width of all templates that use that style.
DISCRETEAXISOFFSETPAD=TRUE | FALSE
specifies whether additional padding is added to the minimum and maximum
axis offsets for discrete axes. When set to TRUE, an additional 5 pixels of
padding are added to the minimum and maximum axis offsets.
Default TRUE
Tip This option is useful for heat maps when you want the heat map to
occupy the entire plot area. In that case, in addition to setting this
option to FALSE, set OFFSETMIN= and OFFSETMAX= to 0 for the
discrete axes.
Default LAYOUTPERCENT
See “About the Drawing Space and Drawing Units” on page 1398
INCLUDEMISSINGDISCRETE=TRUE | FALSE
specifies whether missing values are displayed on a discrete axis.
Default FALSE
Interaction This option affects all charts and plots within the template.
See “boolean ” on page xii for other Boolean values that you can use.
LABELPLACEMENT=AUTO | GREEDY | SA
specifies the label-placement algorithm to use for positioning labels in the
graphs. The following labels are affected:
n data labels for needle plots, scatter plots, series plots, step plots, and vector
plots
n vertex labels for line charts
n curve labels when the curve label is positioned at the start or end of the
curve
AUTO
always selects GREEDY.
GREEDY
specifies the Greedy method for managing label collision. The Greedy
method tries different placement combinations in order to find an optimal
approximation that avoids collisions. Label placement using this method is
often less optimal than label placement using the Simulated Annealing (SA)
method. However, depending on the number of data points and the potential
for label collisions, the Greedy process can be significantly faster.
SA
specifies the Simulated Annealing method for managing label collision. The
SA method attempts to determine the global minimization-of-cost function,
which is based on a simulated annealing algorithm. The resulting label
placement is usually better than placement using the Greedy method.
However, depending on the number of data points and the potential for label
collisions, the SA method can be significantly slower.
Restriction The data label placement algorithm is not aware of bar labels,
curve labels, box plot outlier labels, and marker characters.
BEGINGRAPH Statement 37
OPAQUE=TRUE | FALSE
specifies whether the graph background is opaque or transparent.
Default TRUE
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the graph border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the layout border.
(pad-options)
a space-separated list of one or more of the following name-value-pair
options enclosed in parentheses:
Note Sides that are not assigned padding are padded with the default
amount.
SAPLACEMENTOPTS=(placement-options)
specifies the options for the label-placement algorithm when
LABELPLACEMENT=SA. Placement options can be any of the following:
MAXITERATIONS=positive-integer
specifies the maximum number of iterations for the SA label-placement
algorithm.
Default 100
WEIGHTS=(keyword-number-list)
specifies the relative weight to give to a particular cost when determining
the best label position. The keyword number list is a space-separated list of
keyword = number pairs.
The higher the number, the more weight is assigned to the specified cost. For
example, if MARKER is given more weight than OBSTACLE, avoiding marker
collisions is given a higher priority than avoiding line collisions.
Example saplacementopts=(maxiterations=100
weights=(LABEL=2.0 OBSTACLE=10.0))
SEED=positive-integer
specifies a random number seed for the Simulated Annealing algorithm.
BEGINGRAPH Statement 39
Default 1234567
SUBPIXEL=AUTO | OFF | ON
specifies whether subpixel rendering is used for drawing smooth curved lines or
for spacing bars more precisely.
Note: Starting with SAS 9.4M3, this option controls subpixel rendering only for
image output. For vector-graphics output, subpixel rendering is always enabled.
AUTO
the system determines whether to use subpixel rendering. In SAS 9.4M2 and
in earlier releases, the system uses the default rendering for the rendering
technology. Starting with SAS 9.4M3, for image output, if the SUBPIXEL=
option is explicitly set in an ODS GRAPHICS statement, the system honors
its setting. Otherwise, the system determines whether to use subpixel
rendering based on the following criteria:
n If a SCATTERPLOT or SCATTERPLOTMATRIX statement is used,
subpixel rendering is OFF for the graph.
n If neither a SCATTERPLOT nor a SCATTERPLOTMATRIX statement is
used, subpixel rendering is turned ON for the graph if one or more of the
following statements is also used:
OFF
never uses subpixel rendering.
ON
always uses subpixel rendering, when applicable, for image output when
rendering graphs.
Default AUTO
Requirement Anti-aliasing must be enabled for this option to have any effect.
Interaction Starting with SAS 9.4M3, this option overrides the SUBPIXEL=
option in the ODS GRAPHICS statement.
Details
The GTL global statements apply to the entire template and can include
ENTRYTITLE and ENTRYFOOTNOTE statements, attribute maps, draw
statements, conditional statements, and so on. Any of these global statements can
precede or follow the GTL layout block.
height to 320px. To prevent the graph width from automatically scaling to preserve
the 4:3 aspect ratio, it uses DESIGNWIDTH= to maintain the 640px width. In this
instance, the setting renders each graph cell as a 320px by 320px square. (The cells
are square in this case, but the resulting cell size depends on the graph definition
and would not be the same for all graphs.)
Note: To change the graph sizes for all templates in the current SAS session, you
can use the WIDTH= and HEIGHT= options in the ODS GRAPHICS statement. Size
settings in the ODS GRAPHICS statement override size settings in the
BEGINGRAPH statement and remain in effect unless they are changed in another
ODS GRAPHICS statement. You can also use WIDTH= and HEIGHT= settings in the
graph style to modify the graphs sizes across template definitions. Be aware,
however, that if you explicitly manage the graph output size, then the graph
elements might be scaled so that the size specification is honored.
The following template defines a square graph (equal height and width, 1:1 aspect
ratio) by setting the design width equal to the internal default height (480px). The
setting is made with DESIGNWIDTH=DEFAULTDESIGNHEIGHT:
Note: A “square graph” means that the output graph’s width and height are equal.
That does not imply that the X axis and Y-axis lengths are equal if the graph
contains only one cell.
proc template;
define statgraph squareplot;
dynamic title xvar yvar;
begingraph / designwidth=defaultDesignHeight;
entrytitle title;
layout overlayequated / equatetype=square;
scatterplot x=xvar y=yvar;
regressionplot x=xvar y=yvar;
endlayout;
endgraph;
end;
run;
If the ODS GRAPHICS statement’s WIDTH= or HEIGHT= options change the render
width or render height, then the squareplot template’s 1:1 aspect ratio would still be
honored. Thus, both of the following GRENDER procedure statements would create
a 550px by 550px graph:
ods graphics / width=550px;
proc sgrender data=mydata template="squareplot" ;
dynamic title="Square Plot" xvar="time1" yvar="time2";
run;
Example Program
The BEGINGRAPH statement block is a required outermost container for any graph
template. One of its purposes is to support options that apply to the entire graph.
For example, the default graph size that a template produces is typically 640x480
pixels. If you need a different size, then you can declare the alternative size on this
statement. To do so, use the DESIGNWIDTH= option, or the DESIGNHEIGHT=
option, or both. This program shows one way to set the width and height of two
graph cells to be equal.
proc template;
define statgraph begingraph;
dynamic XVAR YVAR;
begingraph / designwidth=640px designheight=320px;
layout lattice / columns=2;
layout overlayequated / equatetype=square;
entry "Linear Regression Fit" /
valign=top textattrs=(weight=bold);
scatterplot x=XVAR y=YVAR / datatransparency=0.5;
regressionplot x=XVAR y=YVAR;
endlayout;
layout overlayequated / equatetype=square;
entry "Loess Fit" /
valign=top textattrs=(weight=bold);
scatterplot x=XVAR y=YVAR / datatransparency=0.5;
loessplot x=XVAR y=YVAR;
BEGINGRAPH Statement 43
endlayout;
endlayout;
endgraph;
end;
run;
PART 3
Layout Statements
Chapter 3
Summary of Layout Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Chapter 4
Layout Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
46
47
3
Summary of Layout Statements
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Single-cell Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Multi-cell Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Data-driven Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Legend Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Overview
Layout blocks always begin with the LAYOUT keyword followed by a keyword
indicating the purpose of the layout. All layout blocks end with an ENDLAYOUT
statement.
The following sections summarize the available layouts. To learn more about a
layout, see the chapter devoted to that layout.
Single-cell Layouts
Graphics
Allowed and
Cells
Layout (Description) Produced Comments Example
Graphics
Allowed and
Cells
Layout (Description) Produced Comments Example
Multi-cell Layouts
Graphics
Layout Allowed and
(Description) Cells Produced Comments Example
Data-driven Layouts
Graphics
Layout Allowed and
(Description) Cells Produced Comments Example
Legend Layout
Layout Cells Produced Comments
4
Layout Statements
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
LAYOUT DATALATTICE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
LAYOUT DATAPANEL Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
LAYOUT GLOBALLEGEND Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
LAYOUT GRIDDED Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
LAYOUT LATTICE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
LAYOUT OVERLAY Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
LAYOUT OVERLAYEQUATED Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
LAYOUT OVERLAY3D Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
LAYOUT PROTOTYPE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
LAYOUT REGION Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
INNERMARGIN Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Dictionary
Restriction: You can specify only one LAYOUT PROTOTYPE block in the LAYOUT
DATALATTICE block. If you specify more than one, then only the last prototype
block specified is honored. The remaining prototype blocks are ignored.
Requirement: You must specify at least one ROWVAR= option or one COLUMNVAR= option. You
can specify both.
52 Chapter 4 / Layout Statements
Syntax
LAYOUT DATALATTICE ROWVAR=class-variable
COLUMNVAR=class-variable < /options >;
LAYOUT PROTOTYPE </options>;
GTL-statements;
ENDLAYOUT;
<SIDEBAR </options>;
GTL-statements;
ENDSIDEBAR;>
ENDLAYOUT;
Axis options
COLUMN2AXISOPTS=(axis-options)
specifies X2-axis options for all columns.
COLUMN2DATARANGE=AUTO | UNIONALL | UNION
specifies how the X2-axes of instances of the graph-prototype are scaled.
COLUMNAXISOPTS=(axis-options)
specifies X-axis options for all columns.
COLUMNDATARANGE=AUTO | UNIONALL | UNION
specifies how the X-axes of instances of the graph-prototype are scaled.
ROW2AXISOPTS=(axis-options)
specifies Y2-axis options for all rows.
ROW2DATARANGE=AUTO | UNIONALL | UNION
specifies how the Y2-axes of instances of the graph-prototype are scaled.
ROWAXISOPTS=(axis-options)
specifies Y-axis options for all rows.
ROWDATARANGE=AUTO | UNIONALL | UNION
specifies how the Y-axes of instances of the graph-prototype are scaled.
54 Chapter 4 / Layout Statements
Inset options
INSET=(variable-list)
specifies what information is displayed in an inset.
INSETOPTS=(appearance-options)
specifies location and appearance options for the inset information.
Layout options
COLUMNS=integer
specifies the number of columns in the layout.
COLUMNWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the columns widths.
HEADERLABELDISPLAY=NAMEVALUE | VALUE | NONE
specifies the content of the cell headers.
INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether to include grid cells for crossings of the ROWVAR and
COLUMNVAR variables that contain a missing value.
PANELNUMBER=positive-integer
specifies the number of the panel to produce.
ROWGUTTER=dimension
specifies the amount of empty space between the rows.
ROWHEADERS=RIGHT | LEFT | BOTH
specifies where to position the outside row heading.
ROWS=integer
specifies the number of rows in the layout.
ROWWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the row heights.
SKIPEMPTYCELLS=TRUE | FALSE
specifies whether the external axes skip the empty cells in a partially
filled grid.
START=TOPLEFT | BOTTOMLEFT
indicates whether to start populating the grid from the top left or bottom
left corner.
Required Arguments
You must specify at least one of the following arguments. You can specify both.
ROWVAR=class-variable
specifies the classification variable for the rows. One row of cells is created for
each unique value of the row class variable.
COLUMNVAR=class-variable
specifies the classification variable for the columns. One column is created of
each unique value of the column class variable.
Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
CELLHEIGHTMIN=dimension
specifies the minimum height of a cell in the grid. Use this option in conjunction
with the CELLWIDTHMIN= option to set the minimum cell size.
The overall size of the panel is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the number of cells in the grid
increases, the size of each cell decreases. At some point the cell becomes so
small that a meaningful graph cannot be rendered. This option sets the
minimum height threshold for all cells. If the actual cell height becomes smaller,
then no panel is drawn.
Default 100px
CELLWIDTHMIN=dimension
specifies the minimum width of a cell in the grid. Use this option in conjunction
with the CELLHEIGHTMIN= option to set the minimum cell size.
The overall size of the panel is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the number of cells in the grid
increases, the size of each cell decreases. At some point the cell becomes so
small that a meaningful graph cannot be rendered. This option sets the
minimum width threshold for all cells. If the actual cell width becomes smaller,
then no panel is drawn.
Default 100px
COLUMNAXISOPTS=(axis-options)
specifies X-axis options for all columns.
COLUMN2AXISOPTS=(axis-options)
specifies X2-axis options for all columns.
Restriction This option is needed only if you use a plot statement that
supports a secondary X2 axis. If you do not use that statement’s
XAXIS= option to map data to the X2 axis, then this option is
ignored. For more information about how data are mapped to the
axes, see “Plot Data Are Mapped to a Designated Axis” on page
1040
AUTO
selects the X-axis scale based on the COLUMNWEIGHT= option.
UNIONALL
scales the X-axis data ranges across all layout columns and panels (when
PANELNUMBER= is in effect).
LAYOUT DATALATTICE Statement 57
UNION
scales the X-axis data ranges separately for each column on a per-panel
basis.
Default AUTO
AUTO
automatically selects the X2-axis scale based on the COLUMNWEIGHT=
option and the column axis type.
UNIONALL
scales the X2-axis data ranges across all layout columns and panels (when
PANELNUMBER= is in effect).
UNION
scales the X2-axis data ranges separately for each column on a per-panel
basis.
Default AUTO
Interaction This option is needed only if you use a plot statement that supports
a secondary X2 axis. If you do not use that statement’s XAXIS=
option to map data to the X2 axis, then this option is ignored. For
more information about how data are mapped to the axes, see “Plot
Data Are Mapped to a Designated Axis” on page 1040
COLUMNGUTTER=dimension
specifies the amount of empty space that is between the columns.
58 Chapter 4 / Layout Statements
Default 0
TOP
specifies that column heading text appears at the top of the layout.
BOTTOM
specifies that column heading text appears at the bottom of the layout.
BOTH
specifies that column heading text alternates between the top and bottom
of the layout column by column.
Default TOP
COLUMNS=integer
specifies the number of columns in the layout.
Interactions The overall grid size is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the grid size grows,
the cell size shrinks. To control the minimum size of a cell use the
CELLHEIGHTMIN= and CELLWIDTHMIN= options.
COLUMNWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the columns widths.
EQUAL
all columns have equal width.
LAYOUT DATALATTICE Statement 59
PROPORTIONAL
each column has a width that is proportional to the number of discrete
midpoint values that it contains.
If all of the following conditions are true, then the discrete axis
is used to proportion the columns: PROPORTIONAL is in effect,
both the X and X2 axes are used, and only one of the two axes is
discrete. If both axes are discrete, then the X axis is used to
proportion the columns.
Default EQUAL
HEADERBACKGROUNDCOLOR=style-reference | color
specifies the background color of the cell headers.
style-reference
specifies a style reference in the form style-element:style-attribute.
HEADERBORDER=TRUE | FALSE
specifies whether a border is drawn around the header cells.
Default TRUE
See “boolean ” for other Boolean values that you can use.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
NAMEVALUE
displays the classification variable name and value as a name=value pair in
each cell header.
Country=CANADA
Product=TABLE
VALUE
displays the classification variable value only in each cell header.
CANADA
TABLE
NONE
suppresses the cell headers.
Default NAMEVALUE
HEADERLABELLOCATION=OUTSIDE | INSIDE
indicates whether the cell header is placed within each cell (INSIDE) or as row
and column headers external to the lattice (OUTSIDE).
Default OUTSIDE
HEADEROPAQUE=TRUE | FALSE
specifies whether the background for cell headers is opaque (TRUE) or
transparent (FALSE).
Default TRUE
Interaction When this option is set to FALSE, the background color for cell
headers is not used.
See “boolean ” on page xii for other Boolean values that you can use.
LAYOUT DATALATTICE Statement 61
HEADERPACK=TRUE | FALSE
specifies whether the header cells are consolidated into a comma-separated list
in order to save space.
The following figure shows the effect of HEADERPACK= on the cell headers in
one row of a data lattice. The data lattice contains classification variables
Country and Year.
The following figure shows the effect of HEADERPACK= on the cell headers in
one row of a data lattice. The data lattice contains classification variables
Country, Year, and Product.
Default FALSE
Note If the length of the cell header text exceeds the available width, then
the text is truncated.
See “boolean ” on page xii for other Boolean values that you can use.
HEADERSEPARATOR="string"
specifies one or more characters to place between each value in the cell header
when HEADERPACK=TRUE.
HEADERSPLITCOUNT=positive-integer
specifies the number of headers to consolidate on a header line before splitting
the text to the next line.
62 Chapter 4 / Layout Statements
The following figure shows how HEADERSPLITCOUNT=2 splits the cell header
value in a data panel of classification variables Country, Year, and Product.
Note If the length of the cell header text exceeds the available width, then
the text is truncated.
INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether to include grid cells for crossings of the ROWVAR and
COLUMNVAR variables that contain a missing value.
TRUE
any crossing of the class variables that includes a missing value produces a
row or column of cells in the grid.
FALSE
any crossing of the class variables that includes a missing value does not
produce a row or columns of cells in the grid.
By default, missing class values are included in the classification. When the data
contains missing classification values, cells are created for the missing classes.
The classification headers for the missing values are blank for missing string
values or a dot for missing numeric values. You can use the
INCLUDEMISSINGCLASS=FALSE option to exclude the missing values. If you
want to keep the missing values, then you can create a format that specifies
more meaningful headings for the missing classes. For an example, see “Missing
Class Values” in SAS Graph Template Language: User’s Guide.
Note: ODS Graphics does not support Unicode values in user-defined formats
in SAS 9.4M2 and in earlier releases. Starting with SAS 9.4M3, ODS Graphics
supports Unicode values in user-defined formats only if they are preceded by
the (*ESC*) escape sequence. Example: "(*ESC*){unicode beta}". ODS
Graphics does not support an escape character that is defined in an ODS
ESCAPECHAR statement in user-defined formats.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
INSET=(variable-list)
specifies what information is displayed in an inset. The variable-list defines one
or more variables whose names and values appear as a small table in the data
cells. The variables can be either numeric or character. Variable names are
separated by spaces.
LAYOUT DATALATTICE Statement 63
Note The variable values are associated with the data cells by data
order. That is, the first observation from all the variables in
variable-list are used in the first data cell, the second observation
from all variables in variable-list are used in the second data cell,
and so on. If a value is missing for an observation, then the
corresponding name-value pair is skipped in the affected data cell.
INSETOPTS=(appearance-options)
specifies location and appearance options for the inset information. The
appearance options can be any one or more of the following values:
NONE
does not automatically align the inset.
AUTO
attempts to center the inset in the area that is farthest from any
surrounding markers.
(location-list)
restricts the inset’s possible locations to those locations in the specified
location-list, and uses the location-list position that least collides with
the data cell’s other graphics features.
Default NONE
BACKGROUNDCOLOR=style-reference | color
specifies the color of the inset background.
style-reference
specifies a style reference in the form style-element : style-attribute.
64 Chapter 4 / Layout Statements
BORDER=TRUE | FALSE
specifies whether a border is displayed around the inset.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
CONTENTDISPLAY=LABELVALUE | VALUE
specifies whether the variable information that is displayed in the inset
includes the column label and value, or only the column value.
If a label is not assigned to a column, then the column name is used as the
label for that column. Consider the following inset data:
F
Obs _TYPE_ Value Pr > F
1 SS1 94.359 <.0001
The following figure shows the effect that the CONTENTDISPLAY= option
has on the content of an inset that displays this data.
Default LABELVALUE
Tip Use the SEPARATOR= option to specify a separator other than the
default blank space.
DATASCHEME=LIST | MATCHED
specifies the scheme that was used to merge the inset information into the
analysis data.
LIST
one-to-one merging (no BY statement) was used to merge the inset and
analysis data.
The variable values are associated with the cells of the data lattice by
using data order. That is, the inset variable values in the first observation
are used in the inset for the first cell, the inset variable values in the
second observation are used in the inset for the second cell, and so on.
MATCHED
match-merging (using a BY statement) was used to merge the inset and
analysis data.
LAYOUT DATALATTICE Statement 65
Tip MATCHED is the preferred data scheme for merging the inset and
analysis data.
Default LEFT
Interaction This option has an effect only when this layout is nested within a
REGION layout or when this layout is nested in an overlay-type
layout and AUTOALIGN=NONE.
OPAQUE=TRUE | FALSE
specifies whether the inset background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
SEPARATOR="string"
specifies a new separator for the column label and value.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TITLE="string"
specifies a title for the inset.
The title is added at the top of the inset and spans the full inset width.
Note Space is not reserved for the title when this value is not specified.
66 Chapter 4 / Layout Statements
Tip Text properties for the title string can be specified with
TITLEATTRS=.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Default TOP
Interaction This option has effect only when this layout is nested within a
REGION layout or when this layout is nested in an overlay-type
layout and AUTOALIGN=NONE.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the layout border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can contain one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
LAYOUT DATALATTICE Statement 67
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the border.
(pad-options)
a space-separated list of one or more name-value-pair pad options enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
Default 0
RIGHT=dimension
specifies the amount of extra space added to the right side.
Default 0
TOP=dimension
specifies the amount of extra space added to the top.
Default 0
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Default 0
Note Sides that are not assigned padding are padded with the default
amount.
PANELNUMBER=positive-integer
specifies the number of the panel to produce. This option enables you to
partition a large grid into a number of smaller grids under these conditions:
n You set a grid size explicitly (ROWS= and COLUMNS= when ROWVAR and
COLUMNVAR variables are specified; ROWS= when only a ROWVAR
variable is specified; COLUMNS= when only a COLUMNVAR variable is
specified)
n The grid size is smaller in one or both of the dimensions of the default
dynamically generated grid.
n You execute the template N times and increment the panel number each
time. N is determined by CEIL(all rows * all columns / grid rows * grid
columns).
Default 1
ROWAXISOPTS=(axis-options)
specifies Y-axis options for all rows.
ROW2AXISOPTS=(axis-options)
specifies Y2-axis options for all rows.
Interaction This option is needed only if you use a plot statement that
supports a secondary Y2 axis. If you do not use that statement’s
YAXIS= option to map data to the Y2 axis, then this option is
ignored. For more information about how data are mapped to the
axes, see “Plot Data Are Mapped to a Designated Axis” on page
1040
LAYOUT DATALATTICE Statement 69
AUTO
automatically selects the Y-axis scale based on the ROWWEIGHT= option
and the column axis type.
UNIONALL
scales the Y-axis data ranges across all layout rows and panels (when
PANELNUMBER= is in effect).
UNION
scales the Y-axis data ranges separately for each row in the layout on a per-
panel basis.
Default AUTO
AUTO
automatically selects the Y2-axis scale based on the ROWWEIGHT= option
and the column axis type.
UNIONALL
scales the Y2-axis data ranges across all layout rows and panels (when
PANELNUMBER= is in effect).
UNION
scales the Y2-axis data ranges separately for each row in the layout on a
per-panel basis.
Default AUTO
Interaction This option is needed only if you use a plot statement that supports
a secondary Y2 axis. If you do not use that statement’s YAXIS=
option to map data to the Y2 axis, then this option is ignored. For
more information about how data are mapped to the axes, see “Plot
Data Are Mapped to a Designated Axis” on page 1040
ROWGUTTER=dimension
specifies the amount of empty space between the rows.
Default 0
RIGHT
specifies that row heading appears at the right of the layout.
LEFT
specifies that row heading appears at the left of the layout.
BOTH
specifies that row heading alternates between the right and left of the
layout row by row.
Default RIGHT
ROWS=integer
specifies the number of rows in the layout.
Interactions The overall grid size is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the grid size grows,
the cell size shrinks. To control the minimum size of a cell use the
CELLHEIGHTMIN= and CELLWIDTHMIN= options.
ROWWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the row heights.
EQUAL
all rows have equal height.
PROPORTIONAL
each row has a height that is proportional to the number of discrete midpoint
values that it contains.
If all of the following conditions are true, then the discrete axis
is used to proportion the rows: PROPORTIONAL is in effect,
both the Y and Y2 axes are used, and only one of the two axes is
discrete. When both axes are discrete, the Y axis is used to
proportion the rows.
Default EQUAL
SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled down.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
72 Chapter 4 / Layout Statements
SKIPEMPTYCELLS=TRUE | FALSE
specifies whether the external axes skip the empty cells in a partially filled grid.
TRUE
skips empty cells and "snaps" the external axes to the nearest data cell, both
vertically and horizontally.
Though the empty cells are not displayed, the data cells in the grid are not
enlarged to fill the area.
FALSE
displays external axes at their normal locations, even if there are empty cells
at one or more of the locations.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
LAYOUT DATALATTICE Statement 73
SORTORDER=(COLUMNVAR=sort-order-keyword | ROWVAR=sort-order-
keyword)
specifies the order of the cells along the columns and rows.
COLUMNVAR
the column role.
ROWVAR
the row variable role.
sort-order-keyword
a sort-order keyword.
AUTO
sorts using DATA for character data and ascending unformatted for
numeric data.
DATA
retains the data order.
Note In SAS 9.4M6 and SAS 9.4M5, when data stored in a CAS in-
memory table is used and DATA is specified, unpredictable results
might occur. To generate consistent graphs in that case, specify
ASCENDINGFORMATTED or DESCENDINGFORMATTED. Starting
with SAS Viya 3.5 and SAS Studio 5.2, when data stored in a CAS
in-memory table is used and DATA is specified, DATA is ignored,
and AUTO is used instead.
ASCENDINGFORMATTED
sorts in ascending order, using the formatted values.
DESCENDINGFORMATTED
sorts in descending order, using the formatted values.
Defaults AUTO for all roles if the data is a SAS data set
Tip The placement of the cells within the layout also depends on the
starting location, which is controlled by the START= option.
START=TOPLEFT | BOTTOMLEFT
indicates whether to start populating the grid from the top left or bottom left
corner. If ROWVAR=R has values in the sort order 1 and 2 and COLUMNVAR=C
has values in the sort order a and b, then START=BOTTOMLEFT is populated as
follows:
74 Chapter 4 / Layout Statements
Default TOPLEFT
Default BOTTOM
SPACEFILL=TRUE | FALSE
specifies whether to fill all the area of the sidebar with its contents.
Default TRUE
Tip To prevent a layout block within the sidebar from expanding to the
sidebar boundaries, set this option to FALSE.
See “boolean ” on page xii for other Boolean values that you can use.
Details
Statement Description
The LAYOUT DATALATTICE statement makes it easy to create a grid of graphs,
based on the values of one or two classifications variables. To create a grid that is
based on more than two classification variables, or to have more control over the
grid layout, use LAYOUT DATAPANEL instead.
By default, the number of cells in the layout is determined by the number of value
pairings that are possible for the classification values plus any empty cells needed
to complete the last row or column of the grid. The contents of each data cell are
based on a graph prototype that you specify in the graph-prototype-block. You can
enhance the display using one or more sidebar-statement-blocks. For classification
LAYOUT DATALATTICE Statement 75
variables that have many values, you can use the COLUMNS= and or ROWS=
options and the PANELNUMBER= option to generate multiple panel displays.
Classification variables for the layout are specified on the ROWVAR= argument (to
specify a row variable), or the COLUMNVAR= argument (to specify a column), or
both arguments to specify both a column and a row variable. The graph prototype
for each data cell’s contents is specified within a “LAYOUT PROTOTYPE Block” on
page 77 block, and sidebars are specified within SIDEBAR blocks. The LAYOUT
PROTOTYPE and SIDEBAR blocks are nested within the LAYOUT DATALATTICE
block.
By default, the first data cell to be filled is in the layout’s top left corner. Use the
START= option to change the starting data cell to the bottom left corner.
Rather than display the header labels outside the grid, you can set
HEADERLABELLOCATION= INSIDE to display them inside the grid, as shown in the
following figure:
If the class variable is of type character, then its values are returned in data order.
To control the ordering of the values, you can sort the input data by the
classification variables. If the class variable is of type numeric, then the values are
displayed in ordinal order.
The output size does not grow automatically as the number of cells increases. To
set a panel size for the current template, use the DESIGNHEIGHT= and
DESIGNWIDTH= options in the BEGINGRAPH statement. To set a panel size for all
templates in the current SAS session, use the HEIGHT= and WIDTH= options in the
ODS GRAPHICS statement. Size settings in the ODS GRAPHICS statement
override size settings in the BEGINGRAPH statement. The default output width is
640px, and the default output height is 480px.
As the number of cells in the grid increases, the size of each cell decreases. At some
point the cells might become so small that a meaningful graph cannot be rendered.
The CELLHEIGHTMIN= and CELLWIDTHMIN= options set a threshold for the
smallest cell. If the actual cell height or width becomes smaller, then no panel is
drawn. The default minimum cell size is CELLHEIGHTMIN=100px and
CELLWIDTHMIN=100px.
Using the default panel size and cell size, the DATALATTICE layout accommodates
a grid of about 24 cells (6 columns by 4 rows). If you know that the number of cells
is larger, then you should increase the overall panel size, or decrease the minimum
cell size, or both. You can also use ROWS= , COLUMNS= , and PANELNUMBER=
options to partition your data so that a number of smaller grids are produced that
cumulatively show all of the value crossings.
processing). The resulting data set typically has the inset columns padded with
missing values.
n Use the merged data set to produce the graph, specifying the inset column
names in this option’s variable-list.
The LAYOUT PROTOTYPE block determines the graphical content of each data cell
and is repeated within each data cell, based on the subsets of the classification
variables.
For more information about the LAYOUT PROTOTYPE block and the list of
available options, see “LAYOUT PROTOTYPE Statement” on page 186.
SIDEBAR Blocks
A LAYOUT DATALATTICE enables you to display one or more sidebars outside of
the axes. A sidebar spans across columns or rows and is useful for displaying
information that applies to all of the columns or all of the rows. For example,
sidebars are useful for displaying a legend.
The following example shows a SIDEBAR block that displays a legend at the top of
the layout grid.
sidebar / align=top;
discretelegend 'p' 'a' / across=2;
endsidebar;
n A SIDEBAR block is used to place the legend at the bottom of the lattice.
Example Graph
The following graph was generated by the “Example Program” on page 78:
Example Program
proc template;
define statgraph layoutdatalattice;
begingraph;
entrytitle "Annual Furniture Sales Comparisons";
layout datalattice rowvar=country columnvar=year /
rowdatarange=union
headerlabeldisplay=value
headerbackgroundcolor=GraphAltBlock:color
rowaxisopts=(display=(tickvalues) griddisplay=on
linearopts=(tickvalueformat=dollar12.))
columnaxisopts=(display=(tickvalues)
timeopts=(tickvalueformat=monname3.));
layout prototype / cycleattrs=true;
seriesplot x=month y=TotalActual / name="Actual";
seriesplot x=month y=TotalPredict / name="Predict";
endlayout;
LAYOUT DATAPANEL Statement 79
sidebar / align=bottom;
discretelegend "Actual" "Predict" / border=false;
endsidebar;
endlayout;
endgraph;
end;
run;
Restriction: You can specify only one LAYOUT PROTOTYPE block in the LAYOUT DATAPANEL
block. If you specify more than one, then only the last prototype block specified is
honored. The remaining prototype blocks are ignored.
Tip: The DATAPANEL layout should be the outermost layout in the template.
Syntax
LAYOUT DATAPANEL CLASSVARS=(class-var1…class-varN) < /options > ;
LAYOUT PROTOTYPE < /options >;
GTL-statements;
ENDLAYOUT;
<SIDEBAR < / options >;
GTL-statement(s);
ENDSIDEBAR;
<… more-sidebar-statement-blocks …> >
ENDLAYOUT;
Axis options
COLUMN2AXISOPTS=(axis-options)
specifies X2-axis options for all columns.
COLUMN2DATARANGE=AUTO | UNIONALL | UNION
LAYOUT DATAPANEL Statement 81
Inset options
INSET=(variable-list)
specifies what information is displayed in an inset.
INSETOPTS=(appearance-options)
specifies location and appearance options for the inset information.
Layout options
COLUMNS=integer
specifies the number of columns in the layout.
COLUMNWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the columns widths.
HEADERLABELDISPLAY=NAMEVALUE | VALUE | NONE
specifies the content of the cell headers.
INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether to include grid cells for crossings of the CLASSVARS
variables that contain a missing value.
ROWGUTTER=dimension
specifies the amount of empty space between the rows.
ROWS=integer
specifies the number of rows in the layout.
ROWWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the row heights.
Panel options
ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether data cells are populated by column priority or by row
priority.
PANELNUMBER=positive-integer
specifies the number of the panel to produce.
SKIPEMPTYCELLS=TRUE | FALSE
specifies whether the external axes skip the empty cells in a partially
filled grid.
SPARSE=TRUE | FALSE
82 Chapter 4 / Layout Statements
Role options
ROLENAME=(role-name-list)
specifies user-defined roles for information contained in data columns.
Required Argument
CLASSVARS=(column-list)
specifies a list of classification variables. By default, a data cell is created for
each crossing of these variables in the input data. The total number of grid cells
created is the result of a crosstabulation table of all the classification variables
plus any empty cells needed to complete the last row or column of the grid. You
can request that data cells be generated for all possible crossings, even when
the class variables have no values at those crossings. For more information, see
the SPARSE= option.
If the class variable is of type character, then its values are returned in data
order. To control the ordering of the values, you can sort the input data by the
classification variables. If the class variable is of type numeric, then the values
are displayed in ordinal order.
The output size does not grow automatically as the number of cells increases.
To set a panel size for the current template, use the DESIGNHEIGHT= and
DESIGNWIDTH= options in the BEGINGRAPH statement. To set a panel size for
all templates in the current SAS session, use the HEIGHT= and WIDTH= options
in the ODS GRAPHICS statement. Size settings in the ODS GRAPHICS
statement override size settings in the BEGINGRAPH statement. The default
output width is 640px, and the default output height is 480px.
As the number of cells in the grid increases, the size of each cell decreases. At
some point the cells might become so small that a meaningful graph cannot be
rendered. The CELLHEIGHTMIN= and CELLWIDTHMIN= options set a threshold
for the smallest cell. If the actual cell height or width becomes smaller, then no
panel is drawn. The default minimum cell size is CELLHEIGHTMIN=100px and
CELLWIDTHMIN=100px.
Using the default panel size and cell size, the DATAPANEL layout
accommodates a grid of about 24 cells (6 columns by 4 rows). If you know that
the number of cells is larger, then you should increase the overall panel size, or
decrease the minimum cell size, or both. You can also use ROWS= ,
COLUMNS= , and PANELNUMBER= options to partition your data so that a
LAYOUT DATAPANEL Statement 83
number of smaller grids are produced that cumulatively show all of the value
crossings.
Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
HEADERBORDER=TRUE | FALSE
specifies whether a border is drawn around the header cells.
Default TRUE
See “boolean ” for other Boolean values that you can use.
CELLHEIGHTMIN=dimension
specifies the minimum height of a cell in the grid. Use this option in conjunction
with the CELLWIDTHMIN= option to set the minimum cell size.
The overall size of the panel is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the number of cells in the grid
increases, the size of each cell decreases. At some point the cell becomes so
small that a meaningful graph cannot be rendered. This option sets the
minimum height threshold for all cells. If the actual cell height becomes smaller,
then no panel is drawn.
Default 100px
CELLWIDTHMIN=dimension
specifies the minimum width of a cell in the grid. Use this option in conjunction
with the CELLHEIGHTMIN= option to set the minimum cell size.
The overall size of the panel is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the number of cells in the grid
increases, the size of each cell decreases. At some point the cell becomes so
small that a meaningful graph cannot be rendered. This option sets the
minimum width threshold for all cells. If the actual cell width becomes smaller,
then no panel is drawn.
Default 100px
COLUMNAXISOPTS=(axis-options)
specifies X-axis options for all columns.
COLUMN2AXISOPTS=(axis-options)
specifies X2-axis options for all columns.
Restriction This option is needed only if you use a plot statement that
supports a secondary X2 axis. If you do not use that statement’s
XAXIS= option to map data to the X2 axis, then this option is
ignored. For more information about how data are mapped to the
LAYOUT DATAPANEL Statement 85
AUTO
selects the X-axis scale based on the COLUMNWEIGHT= option.
UNIONALL
scales the X-axis data ranges across all layout columns and panels (when
PANELNUMBER= is in effect).
UNION
scales the X-axis data ranges separately for each column on a per-panel
basis.
Default AUTO
AUTO
automatically selects the X2-axis scale based on the COLUMNWEIGHT=
option and the column axis type.
UNIONALL
scales the X2-axis data ranges across all layout columns and panels (when
PANELNUMBER= is in effect).
86 Chapter 4 / Layout Statements
UNION
scales the X2-axis data ranges separately for each column on a per-panel
basis.
Default AUTO
Interaction This option is needed only if you use a plot statement that supports
a secondary X2 axis. If you do not use that statement’s XAXIS=
option to map data to the X2 axis, then this option is ignored. For
more information about how data are mapped to the axes, see “Plot
Data Are Mapped to a Designated Axis” on page 1040
COLUMNGUTTER=dimension
specifies the amount of empty space that is between the columns.
Default 0
COLUMNS=integer
specifies the number of columns in the layout.
Defaults If this option is not specified and ROWS= is specified, then the
number of data cells (and columns) increases dynamically to allow
all classifier values to be presented.
If both this option and ROWS= are specified, then a grid of that size
is created, regardless of the number of classifier values. If the
number of classifier values is greater than the grid size, then no
graphs are created for some classifier values. If the number of
classifier values is small and the grid size large, then there might be
empty cells created.
Interactions The overall grid size is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the grid size grows,
the cell size shrinks. To control the minimum size of a cell use the
CELLHEIGHTMIN= and CELLWIDTHMIN= options.
The START= and ORDER= options affect how the rows are
populated.
COLUMNWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the columns widths.
EQUAL
all columns have equal width.
PROPORTIONAL
each column has a width that is proportional to the number of discrete
midpoint values that it contains.
If all of the following conditions are true, then the discrete axis
is used to proportion the columns: PROPORTIONAL is in effect,
both the X and X2 axes are used, and only one of the two axes is
discrete. If both axes are discrete, then the X axis is used to
proportion the columns.
Default EQUAL
HEADERBACKGROUNDCOLOR=style-reference | color
specifies the background color of the cell headers.
style-reference
specifies a style reference in the form style-element:style-attribute.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
NAMEVALUE
displays the classification variable name and value as a name=value pair in
each cell header.
Country=CANADA
Product=TABLE
VALUE
displays the classification variable value only in each cell header.
CANADA
TABLE
NONE
suppresses the cell headers.
Default NAMEVALUE
HEADEROPAQUE=TRUE | FALSE
specifies whether the background for cell headers is opaque (TRUE) or
transparent (FALSE).
Default TRUE
Interaction When this option is set to FALSE, the background color for cell
headers is not used.
See “boolean ” on page xii for other Boolean values that you can use.
HEADERPACK=TRUE | FALSE
specifies whether the header cells are consolidated into a comma-separated list
in order to save space.
The following figure shows the effect of HEADERPACK= on the cell headers in
one row of a data lattice. The data lattice contains classification variables
Country and Year.
The following figure shows the effect of HEADERPACK= on the cell headers in
one row of a data lattice. The data lattice contains classification variables
Country, Year, and Product.
LAYOUT DATAPANEL Statement 89
Default FALSE
Note If the length of the cell header text exceeds the available width, then
the text is truncated.
See “boolean ” on page xii for other Boolean values that you can use.
HEADERSEPARATOR="string"
specifies one or more characters to place between each value in the cell header
when HEADERPACK=TRUE.
HEADERSPLITCOUNT=positive-integer
specifies the number of headers to consolidate on a header line before splitting
the text to the next line.
The following figure shows how HEADERSPLITCOUNT=2 splits the cell header
value in a data panel of classification variables Country, Year, and Product.
90 Chapter 4 / Layout Statements
Note If the length of the cell header text exceeds the available width, then
the text is truncated.
INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether to include grid cells for crossings of the CLASSVARS
variables that contain a missing value.
TRUE
any crossing of the class variables that includes a missing value produces a
row or column of cells in the grid.
FALSE
any crossing of the class variables that includes a missing value does not
produce a row or columns of cells in the grid.
By default, missing class values are included in the classification. When the data
contains missing classification values, cells are created for the missing classes.
The classification headers for the missing values are blank for missing string
values or a dot for missing numeric values. You can use the
INCLUDEMISSINGCLASS=FALSE option to exclude the missing values. If you
want to keep the missing values, then you can create a format that specifies
more meaningful headings for the missing classes. For an example, see “Missing
Class Values” in SAS Graph Template Language: User’s Guide.
Note: ODS Graphics does not support Unicode values in user-defined formats
in SAS 9.4M2 and in earlier releases. Starting with SAS 9.4M3, ODS Graphics
supports Unicode values in user-defined formats only if they are preceded by
the (*ESC*) escape sequence. Example: "(*ESC*){unicode beta}". ODS
Graphics does not support an escape character that is defined in an ODS
ESCAPECHAR statement in user-defined formats.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
INSET=(variable-list)
specifies what information is displayed in an inset. The variable-list defines one
or more variables whose names and values appear as a small table in the data
cells. The variables can be either numeric or character. Variable names are
separated by spaces.
Note The variable values are associated with the data cells by data
order. That is, the first observation from all the variables in
LAYOUT DATAPANEL Statement 91
variable-list are used in the first data cell, the second observation
from all variables in variable-list are used in the second data cell,
and so on. If a value is missing for an observation, then the
corresponding name-value pair is skipped in the affected data cell.
INSETOPTS=(appearance-options)
specifies location and appearance options for the inset information. The
appearance options can be any one or more of the following values:
NONE
does not automatically align the inset.
AUTO
attempts to center the inset in the area that is farthest from any
surrounding markers.
(location-list)
restricts the inset’s possible locations to those locations in the specified
location-list, and uses the location-list position that least collides with
the data cell’s other graphics features.
Default NONE
BACKGROUNDCOLOR=style-reference | color
specifies the color of the inset background.
style-reference
specifies a style reference in the form style-element : style-attribute.
BORDER=TRUE | FALSE
specifies whether a border is displayed around the inset.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
CONTENTDISPLAY=LABELVALUE | VALUE
specifies whether the variable information that is displayed in the inset
includes the column label and value, or only the column value.
If a label is not assigned to a column, then the column name is used as the
label for that column. Consider the following inset data:
F
Obs _TYPE_ Value Pr > F
1 SS1 94.359 <.0001
The following figure shows the effect that the CONTENTDISPLAY= option
has on the content of an inset that displays this data.
Default LABELVALUE
Tip Use the SEPARATOR= option to specify a separator other than the
default blank space.
DATASCHEME=LIST | MATCHED
specifies the scheme that was used to merge the inset information into the
analysis data.
LIST
one-to-one merging (no BY statement) was used to merge the inset and
analysis data.
The variable values are associated with the cells of the data lattice by
using data order. That is, the inset variable values in the first observation
are used in the inset for the first cell, the inset variable values in the
second observation are used in the inset for the second cell, and so on.
MATCHED
match-merging (using a BY statement) was used to merge the inset and
analysis data.
Tip MATCHED is the preferred data scheme for merging the inset and
analysis data.
Default LEFT
Interaction This option has an effect only when this layout is nested within a
REGION layout or when this layout is nested in an overlay-type
layout and AUTOALIGN=NONE.
OPAQUE=TRUE | FALSE
specifies whether the inset background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
SEPARATOR="string"
specifies a new separator for the column label and value.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TITLE="string"
specifies a title for the inset.
The title is added at the top of the inset and spans the full inset width.
Note Space is not reserved for the title when this value is not specified.
Tip Text properties for the title string can be specified with
TITLEATTRS=.
94 Chapter 4 / Layout Statements
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Default TOP
Interaction This option has effect only when this layout is nested within a
REGION layout or when this layout is nested in an overlay-type
layout and AUTOALIGN=NONE.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether data cells are populated by column priority or by row priority.
ROWMAJOR
fills the data cells by rows, from the starting position.
COLUMNMAJOR
fills the data cells by columns, from the starting position.
Default ROWMAJOR
Interaction The starting point for rendering data cells is controlled by the
START= option. See the START= option for examples.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the layout border.
LAYOUT DATAPANEL Statement 95
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can contain one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the border.
(pad-options)
a space-separated list of one or more name-value-pair pad options enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
Default 0
RIGHT=dimension
specifies the amount of extra space added to the right side.
Default 0
TOP=dimension
specifies the amount of extra space added to the top.
Default 0
96 Chapter 4 / Layout Statements
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Default 0
Note Sides that are not assigned padding are padded with the default
amount.
PANELNUMBER=positive-integer
specifies the number of the panel to produce. This option enables you to
partition a large grid into a number of smaller sized grids under these conditions:
n You set a grid size explicitly ( ROWS= and COLUMNS= options).
n The grid size (gridrows x gridcolumns) is smaller than the total number of
classifier levels.
n You execute the template N times and increment the panel number each
time. N is determined by CEIL(total-classification-levels / gridrows
x gridcolumns).
Default 1
Example Suppose there are two classifiers (CLASS1 has 10 unique values and
CLASS2 has 11 unique values). By setting some smaller grid size, say
ROWS=3 and COLUMNS=4, and making the value of
PANELNUMBER= a dynamic or macro variable, you can create 10
panels (9 panels with 12 data cells and 1 panel with 2 data cells) that
collectively display all 110 possible crossings. You simply invoke PROC
SGRENDER or a DATA step 10 times, incrementing the dynamic value
for PANELNUMBER each time.
ROLENAME=(role-name-list)
specifies user-defined roles for information contained in data columns. The role
name list is a space-separated list role-name=column pairs.
Requirement The role names that you choose must be unique and different from
the predefined roles.
Example The following example assigns the column Obs to the user-defined
role TIP1.
ROLENAME=(TIP1=OBS)
ROWAXISOPTS=(axis-options)
specifies Y-axis options for all rows.
LAYOUT DATAPANEL Statement 97
ROW2AXISOPTS=(axis-options)
specifies Y2-axis options for all rows.
Interaction This option is needed only if you use a plot statement that
supports a secondary Y2 axis. If you do not use that statement’s
YAXIS= option to map data to the Y2 axis, then this option is
ignored. For more information about how data are mapped to the
axes, see “Plot Data Are Mapped to a Designated Axis” on page
1040
AUTO
automatically selects the Y-axis scale based on the ROWWEIGHT= option
and the column axis type.
UNIONALL
scales the Y-axis data ranges across all layout rows and panels (when
PANELNUMBER= is in effect).
UNION
scales the Y-axis data ranges separately for each row in the layout on a per-
panel basis.
Default AUTO
AUTO
automatically selects the Y2-axis scale based on the ROWWEIGHT= option
and the column axis type.
UNIONALL
scales the Y2-axis data ranges across all layout rows and panels (when
PANELNUMBER= is in effect).
UNION
scales the Y2-axis data ranges separately for each row in the layout on a
per-panel basis.
Default AUTO
Interaction This option is needed only if you use a plot statement that supports
a secondary Y2 axis. If you do not use that statement’s YAXIS=
option to map data to the Y2 axis, then this option is ignored. For
more information about how data are mapped to the axes, see “Plot
Data Are Mapped to a Designated Axis” on page 1040
ROWGUTTER=dimension
specifies the amount of empty space between the rows.
Default 0
ROWS=integer
specifies the number of rows in the layout.
Defaults If this option is not specified and COLUMNS= is specified, then the
number of data cells (and rows) increases dynamically to allow all
classifier values to be presented.
If both this option and COLUMNS= are specified, then a grid of that
size is created, regardless of the number of classifier values. If the
number of classifier values is greater than the grid size, then no
graphs are created for some classifier values. If the number of
LAYOUT DATAPANEL Statement 99
classifier values is small and the grid size large, then there might be
empty cells created.
Interactions The overall grid size is constrained by the HEIGHT= and WIDTH=
options in the ODS GRAPHICS statement. As the grid size grows,
the cell size shrinks. To control the minimum size of a cell use the
CELLHEIGHTMIN= and CELLWIDTHMIN= options.
The START= and ORDER= options affect how the rows are
populated.
ROWWEIGHT=EQUAL | PROPORTIONAL
specifies how weights are assigned to the row heights.
EQUAL
all rows have equal height.
PROPORTIONAL
each row has a height that is proportional to the number of discrete midpoint
values that it contains.
If all of the following conditions are true, then the discrete axis
is used to proportion the rows: PROPORTIONAL is in effect,
both the Y and Y2 axes are used, and only one of the two axes is
discrete. When both axes are discrete, the Y axis is used to
proportion the rows.
Default EQUAL
SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled down.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
SKIPEMPTYCELLS=TRUE | FALSE
specifies whether the external axes skip the empty cells in a partially filled grid.
TRUE
skips empty cells and "snaps" the external axes to the nearest data cell, both
vertically and horizontally.
Though the empty cells are not displayed, the data cells in the grid are not
enlarged to fill the area.
FALSE
displays external axes at their normal locations, even if there are empty cells
at one or more of the locations.
Whenever the total number of classifier crossings (data cells) is not evenly
divisible by the panel size (columns * rows), the last panel is partially filled with
data cells and padded with empty cells to complete the grid.
When SKIPEMPTYCELLS=TRUE, the empty padding cells of the last panel are
removed and external axis ticks and tick values snap to the data cells:
LAYOUT DATAPANEL Statement 101
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
SORTORDER=(COLUMNVAR=sort-order-keyword | ROWVAR=sort-order-
keyword)
specifies the order of the cells along the columns and rows.
COLUMNVAR
the column role.
ROWVAR
the row variable role.
sort-order-keyword
a sort-order keyword.
AUTO
sorts using DATA for character data and ascending unformatted for
numeric data.
DATA
retains the data order.
Note In SAS 9.4M6 and SAS 9.4M5, when data stored in a CAS in-
memory table is used and DATA is specified, unpredictable results
might occur. To generate consistent graphs in that case, specify
ASCENDINGFORMATTED or DESCENDINGFORMATTED. Starting
with SAS Viya 3.5 and SAS Studio 5.2, when data stored in a CAS
in-memory table is used and DATA is specified, DATA is ignored,
and AUTO is used instead.
102 Chapter 4 / Layout Statements
ASCENDINGFORMATTED
sorts in ascending order, using the formatted values.
DESCENDINGFORMATTED
sorts in descending order, using the formatted values.
Defaults AUTO for all roles if the data is a SAS data set
Tip The placement of the cells within the layout also depends on the
starting location, which is controlled by the START= option.
SPARSE=TRUE | FALSE
specifies whether crossings of the class variables include only the crossings in
the data or all possible crossings.
FALSE
specifies that data cells are created only for crossings of the class variables
that are in the data.
TRUE
specifies that the number of data cells is the product of the unique values
for each classification variable.
By default, if a crossing of the class variables has a missing value as part of the
data, then a data cell is created for it.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
START=TOPLEFT | BOTTOMLEFT
indicates whether to start populating the grid cells from the top left or bottom
left corner. If ORDER=ROWMAJOR (the default) and START=TOPLEFT (the
default), then a 2 row 2 column grid is populated as shown in the following
figure.
Default TOPLEFT
Default BOTTOM
SPACEFILL=TRUE | FALSE
specifies whether to fill all the area of the sidebar with its contents.
Default TRUE
Tip To prevent a layout block within the sidebar from expanding to the
sidebar boundaries, set this option to FALSE.
See “boolean ” on page xii for other Boolean values that you can use.
Details
Statement Description
The LAYOUT DATAPANEL statement creates a grid of graphs, based on the values
of one or more classifications variables. The main differences between this layout
and the DATALATTICE layout are that this layout supports more than two
classification variables, and it provides more control over the grid layout.
LAYOUT DATAPANEL Statement 105
The order of the value pairings for the classification variables is determined by the
order that the variables are specified on the CLASSVARS= argument. The last
named variable’s values vary most rapidly (like nested DO loops). Variable values
are always returned in data order.
By default, the first data cell to be filled is in the layout’s top left corner, and data
cells are filled from left-to-right, top-to-bottom. Use the START= option to change
the starting data cell to the bottom left corner, and use the ORDER= option to
determine whether data cells fill by column or by row. See the START= option for
illustrations on how START= and ORDER= interact to manage the fill sequence for
data cells.
Prototype Block
You must specify a single graph-prototype-block within the LAYOUT DATAPANEL
block, using the following syntax:
The graph-prototype-block determines the graphical content of each data cell and
is repeated within each data cell, based on the subsets of the classification
variables.
For more information about the LAYOUT PROTOTYPE block and the list of
available options, see “LAYOUT PROTOTYPE Statement” on page 186.
Sidebar Blocks
A LAYOUT DATAPANEL enables you to display sidebars outside of the axis areas. A
sidebar spans across columns or rows and is useful for displaying information that
applies to all of the columns or all of the rows. For example, sidebars are useful for
displaying a legend.
The following example shows a SIDEBAR block that displays a legend at the top of
the layout grid.
sidebar / align=top;
discretelegend 'p' 'a' / across=2;
endsidebar;
Example Graph
The following graph was generated by the “Example Program” on page 107:
LAYOUT DATAPANEL Statement 107
Example Program
proc template;
define statgraph layoutdatapanel;
begingraph;
entrytitle "Annual Furniture Sales Comparisons";
layout datapanel classvars=(country year) /
columns=4 rows=3 rowdatarange=union
headerlabeldisplay=value
headerbackgroundcolor=GraphAltBlock:color
rowaxisopts=(display=(tickvalues) griddisplay=on
linearopts=(tickvalueformat=dollar12.))
columnaxisopts=(display=(tickvalues)
timeopts=(tickvalueformat=monname3.));
layout prototype / cycleattrs=true;
seriesplot x=month y=TotalActual / name="Actual";
seriesplot x=month y=TotalPredict / name="Predict";
endlayout;
sidebar / align=top;
discretelegend "Actual" "Predict" / border=false;
endsidebar;
endlayout;
endgraph;
end;
run;
Syntax
LAYOUT GLOBALLEGEND </options>;
<discreteLegend-statement(s) | mergedLegend-statement(s)>;
ENDLAYOUT;
specifies the amount of extra space that is added inside the layout
border.
TYPE=ROW | COLUMN
specifies whether nested legends are arranged into a single row or
column.
WEIGHTS=UNIFORM | PREFERRED | (weight-list)
specifies the preferred space allocation for the nested legends.
Location options
HALIGN=CENTER | LEFT | RIGHT
specifies the layout’s horizontal alignment within the graph area that is
defined by the BEGINGRAPH block.
Optional Arguments
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
DISPLAYCLIPPED=TRUE | FALSE
specifies whether the global legend is displayed when any portion of its nested
legends cannot be fully rendered because of space constraints. When the graph
size is reduced, parts of a nested legend (title, legend symbol, or legend value)
might be clipped (truncated). When clipping occurs and this option is FALSE,
the entire global legend is removed from the graph and the space for it is
reclaimed by the remainder of the graph. When this option is TRUE, the global
110 Chapter 4 / Layout Statements
legend always appears, even if some parts of the nested legends have been
clipped.
Default FALSE
Interaction This option overrides any DISPLAYCLIPPED option that is set on its
nested legend statements.
See “boolean ” on page xii for other Boolean values that you can use.
GUTTER=dimension
specifies the gap between nested layouts.
Default 0
Default CENTER
LEGENDTITLEPOSITION=LEFT | TOP
specifies the position of each nested legend’s title. Specifying LEFT places each
title to the left of the legend items for that legend. Specifying TOP places each
title above the legend items for that legend.
Default LEFT
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the layout border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can contain one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
LAYOUT GLOBALLEGEND Statement 111
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
Starting with SAS 9.4M1, the default padding between the global
legend and the plot area (including the axes) is increased to 10 pixels. If
the new default padding is not desirable, then use this option to adjust
it.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the border.
(pad-options)
a space-separated list of one or more name-value-pair pad options enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
Default 0
RIGHT=dimension
specifies the amount of extra space added to the right side.
Default 0
TOP=dimension
specifies the amount of extra space added to the top.
Default 0
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Default 0
112 Chapter 4 / Layout Statements
Note Sides that are not assigned padding are padded with the default
amount.
TITLE="string"
specifies a title for the global legend.
Tip The title for the global legend is independent of the titles for its
nested legends.
Interaction For this option to have any effect, the TITLE= option must also be
specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
TYPE=ROW | COLUMN
specifies whether nested legends are arranged into a single row or column.
Default ROW
Interaction When this option is set to ROW, the relative width of each legend is
determined by the setting for the WEIGHTS= option.
UNIFORM
allocates an equal amount of space for all nested legends.
PREFERRED
allocates the preferred amount of space for each nested legend.
(weight-list)
a space-separated list of preferred space allocations, enclosed in
parentheses. The list can combine numbers with the keyword PREFERRED.
Each number is a proportional weight for the corresponding nested legend
(the weights do not have to sum to 1.0). Keyword PREFERRED specifies that
the preferred space should be allocated to the corresponding nested legend.
The order of the weights that are specified in the list should correspond to
LAYOUT GLOBALLEGEND Statement 113
the order of the legend statements that are nested in the GLOBALLEGEND
layout.
Default UNIFORM
Details
A global legend layout can contain multiple discrete or merged legends. Continuous
legends are not supported inside the global legend block.
A global legend is placed at the bottom of the graph, just above the footnote(s). All
of the discrete or merged legend statements that are nested within the global
legend block are arranged into a single row or column, depending on the setting for
the TYPE= option.
Depending on the outermost layout type and the legend content, the legend is
centered on the graph wall area or on the graph output area. For example, if the
outermost layout is an OVERLAY layout, then when positioning the legend, the
GLOBALLEGEND statement first attempts to center the legend on the graph wall
area. If that position causes the legend to be clipped, then it attempts to center the
legend on the entire output area instead. In that case, the legend might appear to be
slightly off-center with respect to the graph.
Only one global legend block is permitted in a graph. The block must be located
within the BEGINGRAPH block, but outside of the outermost layout block.
When a global legend block is used, only the legend statements that are specified
within the global legend block are displayed in the graph. Any legend statements
that are specified outside of the global legend block are ignored.
Example Program
proc template;
define statgraph globallegend;
begingraph;
entrytitle "Prediction Ellipses";
layout overlay;
scatterplot x=petallength y=petalwidth / group=species
name="sp";
ellipse x=petallength y=petalwidth / type=predicted alpha=0.2
name="p80" legendlabel="80%" outlineattrs=graphconfidence;
ellipse x=petallength y=petalwidth / type=predicted alpha=0.05
name="p95" legendlabel="95%" outlineattrs=graphconfidence2;
endlayout;
layout globalLegend / type=column title="Sample Global Legend";
discretelegend "sp" / title="Species:";
discretelegend "p80" "p95" / title="Predictions:";
endLayout;
endgraph;
end;
run;
Note: Empty cells might be omitted from the grid. See “Details” on page 122.
Syntax
LAYOUT GRIDDED </options>;
GTL-statements;
ENDLAYOUT;
Grid options
COLUMNS=integer
specifies the number of columns in the layout.
ROWS=integer
specifies the number of rows in the layout.
Layout options
ROWGUTTER=dimension
116 Chapter 4 / Layout Statements
Legend options
LOCATION=INSIDE | OUTSIDE
specifies whether the legend appears inside or outside the plot area when
nested within an overlay-type layout.
Location options
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether this layout is automatically aligned within its parent
when nested within an overlay-type layout.
HALIGN=CENTER | LEFT | RIGHT | number
specifies this layout’s horizontal alignment within its parent when nested
within an overlay-type or REGION layout.
VALIGN=CENTER | TOP | BOTTOM | number
specifies this layout’s vertical alignment within its parent when nested
within an overlay-type or REGION layout.
Panel options
ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether data cells are populated by column priority or by row
priority.
Optional Arguments
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether this layout is automatically aligned within its parent when
nested within an overlay-type layout.
NONE
does not automatically align the layout within its overlay-type parent layout.
This layout’s position within its parent layout is therefore set by the
HALIGN= and VALIGN= options.
AUTO
within the overlay-type parent layout, attempts to center the layout in the
area that is farthest from any surrounding data point markers.
This option is available only if the parent layout contains a scatter plot.
Otherwise, it is ignored.
(location-list)
within the parent layout, restricts the layout’s possible locations to those
locations in the specified location-list, and uses the location-list position
that least collides with the parent layout’s other graphics features.
Default NONE
LAYOUT GRIDDED Statement 117
Interactions When this option is not NONE and the parent layout is an overlay-
type layout, the HALIGN= and VALIGN= options are ignored.
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
COLUMNGUTTER=dimension
specifies the amount of empty space between the columns.
Default 0
118 Chapter 4 / Layout Statements
COLUMNS=integer
specifies the number of columns in the layout. This option is used to create a
grid with a fixed number of columns, without concern for how many rows. For
example, the following settings ensure that columns 1 and 2 in the first row are
filled with content, as shown in the figure:
layout gridded / columns=2 order=rowmajor border=true ;
entry '1' /border=true;
entry '2' /border=true;
entry '3' /border=true;
endlayout;
number
specifies the horizontal alignment as a fraction of the parent container’s
width.
Range 0 to 1, where 0 is all the way to the left and 1 is all the way to the
right.
Default CENTER
Restriction This option has effect only when this layout is nested within a
REGION layout, or when this layout is nested in an overlay-type
layout and AUTOALIGN=NONE.
LOCATION=INSIDE | OUTSIDE
specifies whether the legend appears inside or outside the plot area when
nested within an overlay-type layout.
Default INSIDE
Restriction This option has effect only when the GRIDDED layout block
appears within an overlay-type layout. For more information about
how child positions are determined in an overlay-type layout, see
“LAYOUT OVERLAY Statement” on page 159.
Interactions If this option is set to OUTSIDE, then the HALIGN= and VALIGN=
options must specify a keyword (LEFT, RIGHT, or CENTER). The
number setting for the alignment is invalid when the layout is
positioned outside of the plot area.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether data cells are populated by column priority or by row priority.
ROWMAJOR
fills all the columns in a row, from left to right, before going to the next row.
COLUMNMAJOR
fills all the rows in a column, from top to bottom, before going to the next
column.
Default ROWMAJOR
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the layout border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can contain one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the border.
(pad-options)
a space-separated list of one or more name-value-pair pad options enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
Default 0
LAYOUT GRIDDED Statement 121
RIGHT=dimension
specifies the amount of extra space added to the right side.
Default 0
TOP=dimension
specifies the amount of extra space added to the top.
Default 0
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Default 0
Note Sides that are not assigned padding are padded with the default
amount.
ROWGUTTER=dimension
specifies the amount of empty space between the rows.
Default 0
ROWS=integer
specifies the number of rows in the layout. This option is used to create a grid
with a fixed number of rows, without concern for how many columns. For
example, the following settings ensure that rows 1 and 2 in the first column are
filled with content, as shown in the figure:
layout gridded / rows=2 order=columnmajor border=true ;
entry '1' /border=true;
entry '2' /border=true;
entry '3' /border=true;
endlayout;
SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled down.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
number
specifies the vertical alignment as a fraction of the parent container’s height.
Default CENTER
Restriction This option has effect only when this layout is nested within a
REGION layout, or when this layout is nested in an overlay-type
layout and AUTOALIGN=NONE.
Details
A GRIDDED layout is commonly used to create small tables of text that are nested
within other layouts. The layout might also be used to span and center a single
entry (a legend, for example) across a set of grids. Or it might be used to display a
grid of graphs when there is no need to scale axis data ranges or align graphs across
grid cells.
The GRIDDED layout automatically decides how much area to allocate to cell
contents:
n Text items have a fixed size based on the amount of text and the font
properties.
LAYOUT GRIDDED Statement 123
The layout’s grid size is determined by the COLUMNS= and ROWS= options. The
resulting columns and rows can be separated by areas called “gutters,” which are
controlled by the COLUMNGUTTER= and ROWGUTTER= options.
By default, the results of the GTL statements are placed into the grid sequentially
from left to right, wrapping to a new row each time the current row is filled. You can
use the ORDER= option to fill cells from top to bottom down a column. In that case,
the layout cells wrap to a new column each time the current column is filled. The
GTL statements can include text statements, plot statements, and layout blocks.
Each statement or layout block provides content for one cell in the grid.
If a statement or layout block for a grid cell does not produce any output, then the
space for that cell might not be retained as an empty cell in the grid. In that case,
the empty cell is removed, and the remaining cells (if any) fill the gap in the grid. A
statement produces no output when required data for that statement does not
resolve. A layout block produces no output when it contains no statements or when
none of the statements contained in the block produce any output.
Examples
Example Program
/* Define the graph template */
proc template;
define statgraph graphgridded;
begingraph / subpixel=on;
entrytitle "Automotive Data";
layout gridded / columns=2 rows=2 rowgutter=5 columngutter=5;
/* Define graph for row 1 cell 1 */
layout overlay / border=on pad=5
xaxisopts=(label="Mean Highway MPG"
griddisplay=on gridattrs=(color=lightgray pattern=dot))
yaxisopts=(label="Type" labelposition=top);
barchart x=type y=Mpg_Highway / stat=mean orient=horizontal
barlabel=true barlabelformat=5.0;
endlayout;
Example Program
The GRIDDED layout offers the best way to nest a table of information inside
another layout. In the GRIDDED layout, you can control the content, text
justification, and fonts of columns. Because this example nests the GRIDDED
layout within an OVERLAY layout, you can control where it appears within the plot
area. The AUTOALIGN= option enables you to specify a prioritized list of possible
positions where the layout should be drawn. The position actually used is the first
one that avoids collision with the histogram. Also, the GRIDDED layout is set to be
opaque so that the grid lines do not show through. This example also illustrates a
reusable template in the sense that it works for any numeric column specified by
the dynamic variable VAR. Also, SGE functions for computing the N, MEAN,
STDDEV of the column are used in the table to compute the statistics as the
template is executed.
proc template;
define statgraph inset;
dynamic VAR;
begingraph;
entrytitle "Distribution of " VAR;
layout overlay / yaxisopts=(griddisplay=on);
histogram VAR / scale=percent;
layout gridded / columns=2
autoalign=(topleft topright) border=true
opaque=true backgroundcolor=GraphWalls:color;
126 Chapter 4 / Layout Statements
Note: Empty cells might be omitted from the lattice. See “Cell Contents” on page 144.
Syntax
LAYOUT LATTICE </options>;
GTL-statement(s) | cell-statement-block(s);
<COLUMNAXES;
COLUMNAXIS / axis-options;
<… more-COLUMNAXIS-statements …>
ENDCOLUMNAXES;>
<COLUMN2AXES;
COLUMNAXIS / axis-options;
<… more-COLUMNAXIS-statements …>
ENDCOLUMN2AXES;>
<ROWAXES;
ROWAXIS / axis-options;
<… more-ROWAXIS-statements …>
ENDROWAXES;>
<ROW2AXES;
ROWAXIS / axis-options;
<… more-ROWAXIS-statements …>
ENDROW2AXES;>
LAYOUT LATTICE Statement 127
<COLUMNHEADERS;
GTL-statement(s);
ENDCOLUMNHEADERS;
<… more-header-statement-block(s) …> >
<SIDEBAR </options>;
GTL-statement(s);
ENDSIDEBAR;>
<… more-sidebar-statement-blocks …> >
ENDLAYOUT;
Cell options
COLUMNWEIGHTS=UNIFORM | PREFERRED | (weight-list)
specifies the proportional width of each column relative to the overall
grid width, not including the headings and sidebars.
ROWWEIGHTS=UNIFORM | PREFERRED | (weight-list)
specifies the proportional height of each row relative to the overall grid
height, not including the headings and sidebars.
Column options
COLUMN2DATARANGE=DATA | UNION | UNIONALL
specifies how the X2-axis data ranges of graphs within the lattice
columns are scaled.
COLUMNDATARANGE=DATA | UNION | UNIONALL
128 Chapter 4 / Layout Statements
specifies how the X-axis data ranges of graphs within the lattice columns
are scaled.
Lattice options
COLUMNS=integer
specifies the number of columns in the lattice.
ROWS=integer
specifies the number of rows in the lattice.
SKIPEMPTYCELLS=TRUE | FALSE
specifies whether row and column axes skip the unused cells in a
partially filled lattice.
Layout options
ROWGUTTER=dimension
specifies the amount of empty space between the rows.
Location options
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether this layout is automatically aligned within its parent
when nested within an overlay-type layout.
HALIGN=CENTER | LEFT | RIGHT | number
specifies this layout’s horizontal alignment within its parent when nested
within an overlay-type or REGION layout.
VALIGN=CENTER | TOP | BOTTOM | number
specifies this layout’s vertical alignment within its parent when nested
within an overlay-type or REGION layout.
Panel options
ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether data cells are populated by column priority or by row
priority.
Row options
ROW2DATARANGE=DATA | UNION | UNIONALL
specifies how the Y2-axis data ranges of graphs within the lattice rows
are scaled.
ROWDATARANGE=DATA | UNION | UNIONALL
specifies how the Y-axis data ranges of graphs within the lattice rows are
scaled.
Optional Arguments
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether this layout is automatically aligned within its parent when
nested within an overlay-type layout.
NONE
does not automatically align the layout within its overlay-type parent layout.
This layout’s position within its parent layout is therefore set by the
HALIGN= and VALIGN= options.
LAYOUT LATTICE Statement 129
AUTO
within the overlay-type parent layout, attempts to center the layout in the
area that is farthest from any surrounding data point markers.
This option is available only if the parent layout contains a scatter plot.
Otherwise, it is ignored.
(location-list)
within the parent layout, restricts the layout’s possible locations to those
locations in the specified location-list, and uses the location-list position
that least collides with the parent layout’s other graphics features.
Default NONE
Interaction When this option is not NONE and the parent layout is an overlay-
type layout, the HALIGN= and VALIGN= options are ignored.
Example In the following example, the LATTICE layout is the child of the
OVERLAY layout. The child layout appears in either the top right or
top left position, based on which position has more “unoccupied”
area.
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
DATA
scales the X-axis data ranges separately for each cell in the lattice.
UNION
scales the X-axis data ranges separately for each column in the lattice.
This setting is supported only if all plots across the column can share the
same data range and axis type. For more information, see “Plot Axis Types
Must Agree on Common Axes” on page 1049.
UNIONALL
scales the X-axis data ranges across all columns in the lattice.
This setting is supported only if all plots across the column can share the
same data range and axis type. For more information, see “Plot Axis Types
Must Agree on Common Axes” on page 1049.
Default DATA
Interactions The data ranges are scaled only if the data values are continuous
and the graphs have the same orientation. If graphs cannot use the
same X-axis range or if COLUMNDATARANGE=DATA, then the X-
axis range of each graph is determined from the data.
Tips If column axes are used and if a lattice cell contains a LAYOUT
OVERLAY statement with the XAXISOPTS= option specified, then
the XAXISOPTS= option is ignored. In that case, use the
COLUMNAXIS statement to specify the desired column X-axis
features. For more information, see “Row and Column Axis
Statements” on page 146 .
By default, each cell has its own axes, which are managed using axis
options in the layout statement for that cell. To consolidate the cell
X axes into column X axes, set this option to UNION or UNIONALL.
Then in the LAYOUT LATTICE statement block, specify a
COLUMNAXES block that includes a COLUMNAXIS statement for
each column X axis that needs to be managed.
DATA
scales the X2-axis data ranges separately for each cell in the lattice.
UNION
scales the X2-axis data ranges separately for each column in the lattice.
This setting is supported only if all plots across the column can share the
same data range and axis type. For more information, see “Plot Axis Types
Must Agree on Common Axes” on page 1049.
UNIONALL
scales the X2-axis data ranges across all columns in the lattice.
This setting is supported only if all plots across the column can share the
same data range and axis type. For more information, see “Plot Axis Types
Must Agree on Common Axes” on page 1049.
Default DATA
Interactions The data ranges are scaled only if the data values are continuous
and the graphs have the same orientation. If graphs cannot use the
same X2-axis range or if COLUMN2DATARANGE=DATA, then the
X2-axis range of each graph is determined from the data.
Tips By default, each cell has its own axes, which are managed using axis
options in the layout statement for that cell. To consolidate the cell
X2 axes into column X2 axes, set this option to UNION or
UNIONALL. Then in the LAYOUT LATTICE statement block, specify
a COLUMN2AXES block that includes a COLUMNAXIS statement
for each column X2 axes that needs to be managed.
COLUMNGUTTER=dimension
specifies the amount of empty space that is between the columns.
Default 0
COLUMNS=integer
specifies the number of columns in the lattice.
UNIFORM
equally divides the total available width among all of the columns.
PREFERRED
specifies that each column gets its preferred width.
Notes The PREFERRED option is used for LATTICE layouts that mix
one-dimensional and two-dimensional plots in the grid. It
LAYOUT LATTICE Statement 133
(weight-list)
a space-separated list of column weights.
The list should contain a weight for each column, which can be expressed as
one of the following:
PREFERRED
specifies that the corresponding column gets its preferred width as
described previously.
number
specifies that the corresponding column gets a width that is based on the
proportion of the specified number to the total of the numbers in the
weight list.
columnweights=(2 3 5)
In these examples, the first column gets 20% of the available width, the
second column gets 30%, and the third column gets 50%.
If the list contains the PREFERRED keyword, then the number specifies
the proportion of the width that remains after the preferred width or
widths are calculated and subtracted from the available width.
If there are n columns in the grid, then the weight list should
contain n weights, one for each column.
Example Here is an example that specifies the preferred width for the
first column, 20% of the remaining width to the second
column, and 80% of the remaining width to the third column.
134 Chapter 4 / Layout Statements
number
specifies the horizontal alignment as a fraction of the parent container’s
width.
Range 0 to 1, where 0 is all the way to the left and 1 is all the way to the
right.
Default CENTER
Restriction This option has effect only when this layout is nested within a
REGION layout, or when this layout is nested in an overlay-type
layout and AUTOALIGN=NONE.
Example In the following example, the LATTICE layout is the child of the
OVERLAY layout and is positioned in the OVERLAY’s top right
corner.
dynamic VAR STAT1 STAT2 STAT3;
layout overlay;
histogram VAR;
layout lattice / VALIGN=TOP HALIGN=RIGHT
columns=1;
entry STAT1;
entry STAT2;
entry STAT3;
endlayout;
endlayout;
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether data cells are populated by column priority or by row priority.
ROWMAJOR
fills all the columns in a row, from left to right, before going to the next row.
LAYOUT LATTICE Statement 135
COLUMNMAJOR
fills all the rows in a column, from top to bottom, before going to the next
column.
Default ROWMAJOR
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the layout border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can contain one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
136 Chapter 4 / Layout Statements
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the border.
(pad-options)
a space-separated list of one or more name-value-pair pad options enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
Default 0
RIGHT=dimension
specifies the amount of extra space added to the right side.
Default 0
TOP=dimension
specifies the amount of extra space added to the top.
Default 0
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Default 0
Note Sides that are not assigned padding are padded with the default
amount.
DATA
scales the Y-axis data ranges separately for each cell in the lattice.
UNION
scales the Y-axis data ranges separately for each row in the lattice.
This setting is supported only if all plots down the row can share the same
data range and axis type. For more information, see “Plot Axis Types Must
Agree on Common Axes” on page 1049.
UNIONALL
scales the Y-axis data ranges across all rows in the lattice.
LAYOUT LATTICE Statement 137
This setting is supported only if all plots down the row can share the same
data range and axis type. For more information, see “Plot Axis Types Must
Agree on Common Axes” on page 1049.
Default DATA
Interactions The data ranges are scaled only if the data values are continuous
and the graphs have the same orientation. If graphs cannot use the
same vertical range or if ROWDATARANGE=DATA, then the
vertical range of each graph is determined from the data.
Tips By default, each cell has its own axes, which are managed using axis
options in the layout statement for that cell. To consolidate the cell
Y axes into a row Y axis, set this option to UNION or UNIONALL.
Then in the LAYOUT LATTICE statement block, specify a
ROWAXES block that contains a ROWAXIS statement for each row
Y axis that needs to be managed.
DATA
scales the Y2-axis data ranges separately for each cell in the lattice.
UNION
scales the Y2-axis data ranges separately for each row in the lattice.
This setting is supported only if all plots down the row can share the same
data range and axis type. For more information, see “Plot Axis Types Must
Agree on Common Axes” on page 1049.
UNIONALL
scales the Y2-axis data ranges across all rows in the lattice.
This setting is supported only if all plots down the row can share the same
data range and axis type. For more information, see “Plot Axis Types Must
Agree on Common Axes” on page 1049.
Default DATA
Interactions The Y2-axis data ranges are scaled only if the data values are
continuous and the graphs have the same orientation. If graphs
cannot use the same vertical range or if ROW2DATARANGE=DATA,
then the vertical range of each graph is determined from the data.
138 Chapter 4 / Layout Statements
Tips By default, each cell has its own axes, which are managed using axis
options in the layout statement for that cell. To consolidate the cell
Y axes into row X2 axes, set this option to UNION or UNIONALL,
and then in the LAYOUT LATTICE statement block, specify a
ROW2AXES block that contains a ROWAXIS statement for each
row Y2 axis that needs to be managed.
ROWGUTTER=dimension
specifies the amount of empty space between the rows.
Default 0
ROWS=integer
specifies the number of rows in the lattice.
UNIFORM
equally divides the total available height among all of the rows.
PREFERRED
specifies that each row gets its preferred height.
LAYOUT LATTICE Statement 139
Notes The PREFERRED option is used for LATTICE layouts that mix one-
dimensional and two-dimensional plots in the grid. It enables the
layout to compute the weights automatically for rows that contain
one-dimensional plots.
(weight-list)
a space-separated list of row weights.
The list should contain a weight for each row, which can be expressed as one
of the following:
PREFERRED
specifies that the corresponding row gets its preferred height as
described previously.
Note The PREFERRED option should be used on rows that contain only
one-dimensional plots. Using the PREFERRED keyword on rows
that contain a mix of one-dimensional and two-dimensional plots
might cause unexpected results. In that case, use a numeric weight
instead.
number
specifies that the corresponding row gets a height that is based on the
proportion of the specified number to the total of the numbers in the
weight list.
rowweights=(2 3 5)
In these examples, the first row gets 20% of the available height, the
second row gets 30%, and the third row gets 50%.
If the list contains the PREFERRED keyword, then the number specifies
the proportion of the height that remains after the preferred height or
heights are calculated and subtracted from the available height.
If there are n rows in the grid, then the weight list should
contain n weights, one for each row.
Note The weights for all of the rows are specified as a proportion
and, as such, are not required to total 1.0.
SHRINKFONTS=TRUE | FALSE
specifies whether fonts in the layout are scaled down.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
SKIPEMPTYCELLS=TRUE | FALSE
specifies whether row and column axes skip the unused cells in a partially filled
lattice.
FALSE
displays row and column axes at their normal locations.
TRUE
skips empty cells and “snaps” the row and column axes to the nearest
populated cell, both vertically and horizontally.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
number
specifies the vertical alignment as a fraction of the parent container’s height.
Default CENTER
Restriction This option has effect only when this layout is nested within a
REGION layout, or when this layout is nested in an overlay-type
layout and AUTOALIGN=NONE.
LAYOUT LATTICE Statement 141
Example In the following example, the LATTICE layout is the child of the
OVERLAY layout. The child layout appears in either the top right or
top left position, based on which position has more "unoccupied"
area.
dynamic VAR STAT1 STAT2 STAT3;
layout overlay / height=500px width=600px;
histogram VAR;
layout lattice / VALIGN=TOP HALIGN=RIGHT
height=80px width=70px columns=1;
entry STAT1;
entry STAT2;
entry STAT3;
endlayout;
endlayout;
Default BOTTOM
Tip You can use ENTRY statements to place rotated text in the right or left
side bar.
SPACEFILL=TRUE | FALSE
specifies whether to fill all the area of the sidebar with its contents.
Default TRUE
Tip To prevent a layout block within the sidebar from expanding to the
sidebar boundaries, set this option to FALSE.
See “boolean ” on page xii for other Boolean values that you can use.
Details
Statement Description
The LAYOUT LATTICE statement creates a grid of graphs that are aligned across
rows and columns. For plot statements that are specified in the layout block or
nested in a LAYOUT OVERLAY statement, the LATTICE layout automatically aligns
the plot areas and tick display areas in the plots.
Note: To achieve the alignment, the LATTICE layout automatically aligns plot
areas and tick display areas across rows and columns. Also, it overrides axis offset
settings in the OVERLAY layouts that you specify in those rows and columns. (For
142 Chapter 4 / Layout Statements
details about offsets and the tick display area, see “Adjusting Axis Offsets” on page
1053.) If you do not want this alignment, then you might use LAYOUT GRIDDED
instead. For example, if you have a heterogeneous panel of graphs, such as a mix of
scatter plots, box plots, bar charts, or other types of graphs, then you might
consider using LAYOUT GRIDDED rather than LAYOUT LATTICE.
The layout can unify the scale of the data ranges that are displayed in the plots,
based on the values set for the COLUMNDATARANGE= and ROWDATARANGE=
options. If one or more plots within the template use the XAXIS= option to produce
independent X2 (top) axes, then the X2 data scales can be unified, based on the
values set for the COLUMN2DATARANGE= option. If one or more plots within the
template use the YAXIS= option to produce independent Y2 (right) axes, then the
Y2 data scales can be unified, based on the values set for the ROW2DATARANGE=
options. The data ranges can be scaled separately for each column, for each row, or
for both. Or they can be scaled across all columns, all rows, or all of both.
When the data-range scales are unified, you can simplify the lattice by displaying
only the row and column axes that apply to all of the graphs across the
corresponding columns or rows. See “Row and Column Axis Statements” on page
146 for more details.
The following figure shows the parts of the LATTICE layout with the default axis
display (internal axes are displayed).
LAYOUT LATTICE Statement 143
This next figure shows the parts of the LATTICE layout when the graph display is
simplified so that only row and column axes are displayed.
Note: The figure shows secondary X (top) and secondary Y (right) axes. The layout
also enables you to generate independent X2 (top) and independent Y2 (right)
axes. For details, see “Row and Column Axis Statements” on page 146
The rows and columns can be separated by areas called “gutters,” which are
controlled by the COLUMNGUTTER= and ROWGUTTER= options. In addition, the
COLUMNWEIGHTS= and ROWWEIGHTS= options can be used to allocate a
proportion of available space to each row and column.
The LATTICE layout automatically decides how much area to allocate to cell
contents:
n Text items have a fixed size based on the amount of text and the font
properties.
n Graphs take up the remaining space.
The layout’s grid size is determined by the COLUMNS= and ROWS= options.
By default, the results of the GTL-statements are placed into the grid sequentially
from left to right, wrapping to a new row each time the current row is filled. You can
144 Chapter 4 / Layout Statements
use the ORDER= option to fill cells from top to bottom down a column. In that case,
the lattice cells wrap to a new column each time the current column is filled.
Cell Contents
The following general syntax is used to define the contents of each cell in a
LAYOUT LATTICE:
GTL-statement(s) | cell-statement-block(s)
CELL;
<CELLHEADER; GTL-statement(s); ENDCELLHEADER;>
GTL-statement(s);
ENDCELL;
If a CELL block, or an independent statement or layout block for a lattice cell does
not produce any output, then the space for that cell might not be retained as an
empty cell in the lattice. In that case, the empty cell is removed, and the remaining
cells (if any) fill the gap in the lattice. A statement produces no output when
required data for that statement does not resolve. A layout block produces no
output when it contains no statements or when none of the statements contained
in the block produce any output.
LAYOUT LATTICE Statement 145
The example code shows a LAYOUT LATTICE block that uses one GTL statement
and one CELL block to generate the two-column lattice shown in the following
figure:
Figure 4.1 Lattice Layout with Independent Plot Statements and a CELL Block
proc template;
define statgraph cellcontents;
begingraph;
layout lattice /
columngutter=5 columns=2;
Overview
By default, each cell in the lattice has its own internal axes, which are managed
using axis options in the layout statement for that cell. Here is an example of a
lattice with internal axes.
Notice that the axes ranges for each plot in the lattice differ. If the data ranges for
each plot are comparable, you can unity the axes to a common scale for all of the
plots in the lattice. In that case, you can also simplify and clarify your lattice by
creating row and column axes that are shared by the cells in the lattice. Here is an
example of a lattice with row and column axes.
Row and column axes are defined by row and column axis statement blocks in the
LAYOUT LATTICE statement block. Row and column axis statement blocks are
LAYOUT LATTICE Statement 147
useful only if the data ranges across the affected columns or rows are comparable
and can be unified to a common scale. For example, row and column axes are not
supported if an affected lattice cell contains a LAYOUT OVERLAYEQUATED
statement. If the axis ranges are not unified for the affected columns or rows, then
the row and column axis statement blocks in the LAYOUT LATTICE statement
block are ignored.
Use the options shown in the following table to unify the axis data ranges in the
lattice.
Axis Option
X COLUMNDATARANGE=
X2 COLUMN2DATARANGE=
Y ROWDATARANGE=
Y2 ROW2DATARANGE=
If one or more plots within the LAYOUT LATTICE statement block use the
XAXIS=X2 option to produce independent X2 (top) axes, then axis features for the
column X2 axes are specified within a COLUMN2AXES block, nesting one
COLUMNAXIS statement for each column that contains an X2 axis that needs to be
managed. Within the COLUMN2AXES block, the COLUMNAXIS statement’s
DISPLAYSECONDARY= option enables you to display a column secondary X2
(bottom) axis that mirrors the column primary X2 axis but can have different
display features. Here again, the axis features that you specify in the COLUMNAXIS
statement apply to both the column primary and the column secondary X2 axes.
Note: If you specify independent X and X2 scales at the same time, then the
DISPLAYSECONDARY= option is ignored in the COLUMNAXIS statement. This is
true whether the COLUMNAXIS statement is specified in a COLUMNAXES or
COLUMN2AXES block.
For both the COLUMNAXES and COLUMN2AXES blocks, if a lattice cell within the
column contains a LAYOUT OVERLAY statement with the XAXISOPTS= or
X2AXISOPTS= option specified, these LAYOUT OVERLAY statement options are
ignored. In that case, specify the desired axis features in one or more
COLUMNAXIS statements in the COLUMNAXES block.
148 Chapter 4 / Layout Statements
For rows, axis features for the row Y axes (left) are specified within a ROWAXES
block, nesting one ROWAXIS statement for each row that contains a Y axis that
needs to be managed. The ROWAXIS statement provides a DISPLAYSECONDARY=
option, which enables you to display a row secondary Y (right) axis that mirrors the
row primary Y axis but can have different display features. In that case, the axis
features that you specify in the ROWAXIS statement apply to both the row primary
and row secondary Y axes.
If one or more plots within the LAYOUT LATTICE statement block use the YAXIS=
option to produce independent Y2 (right) axes, then axis features for the row Y2
axes (right) are specified within a ROW2AXES block, nesting one ROWAXIS
statement for each row that contains a Y2 axis that needs to be managed. Within
the ROW2AXES block, the ROWAXIS statement’s DISPLAYSECONDARY= option
enables you to display a row secondary Y2 (left) axis that mirrors the row primary
Y2 axis but can have different display features. Here again, the axis features that
you specify in the ROWAXIS statement apply to both the row primary and row
secondary Y2 axes.
Note: If you specify independent Y and Y2 scales at the same time, then the
DISPLAYSECONDARY= option is ignored in the ROWAXIS statement. This is true
whether the ROWAXIS statement is specified in a ROWAXES or ROW2AXES block.
For both the ROWAXES and ROW2AXES blocks, if a lattice cell within the row
contains a LAYOUT OVERLAY statement with the YAXISOPTS= or Y2AXISOPTS=
option specified, these LAYOUT OVERLAY statement options are ignored. In that
case, specify the desired axis features in one or more ROWAXIS statements in the
ROWAXES block.
COLUMNAXES; COLUMN2AXES;
COLUMNAXIS / axis-options; COLUMNAXIS / axis-options;
<…COLUMNAXIS-n;> <…COLUMNAXIS-n;>
ENDCOLUMNAXES; ENDCOLUMN2AXES;
ROWAXES; ROW2AXES;
ROWAXIS / axis-options; ROWAXIS / axis-options;
<…ROWAXIS-n;> <…ROWAXIS-n;>
ENDROWAXES; ENDROW2AXES;
n If the LAYOUT LATTICE statement sets the row or column axis data range to
DATA, then the corresponding axes block is ignored. The data range must be set
to UNION or UNIONALL to create row and column axes.
n Only one COLUMNAXES block can be used to manage column X axes, and only
one COLUMN2AXES block can be used to manage column X2 axes. If more than
one of either block is specified, then only the last one of that block type is used.
n Within a COLUMNAXES or COLUMN2AXES block, one COLUMNAXIS
statement should be specified for each column that contains axes that you need
to manage. Both axes blocks can contain a COLUMNAXIS statement for the
same column. For example, to manage the axes in the first column of the lattice,
the COLUMNAXES block can contain a COLUMNAXIS statement that manages
the column’s X axes. The COLUMN2AXES block can contain a COLUMNAXIS
statement that manages the column’s X2 axes.
n Only one ROWAXES block can be used to manage row Y axes, and only one
ROWAXES block can be used to manage row Y2 axes. If more than one of either
block is specified, then only the last one of that block type is used.
n Within a ROWAXES or ROW2AXES block, one ROWAXIS statement should be
specified for each row that contains axes that need to be managed. Both axes
blocks can contain a ROWAXIS statement for the same row. For example, to
manage the axes in the first row of the lattice, the ROWAXES block can contain
a ROWAXIS statement that manages the row’s Y axes. The ROW2AXES block
can contain a ROWAXIS statement that manages the column’s Y2 axes.
n If the number COLUMNLAXIS or ROWAXIS statements is greater than the
number needed, then the extra statements are ignored. If the number of
statements is fewer than the number needed, then the additional COLUMNAXIS
or ROWAXIS statements are automatically generated with DISPLAY=NONE
option in effect for each.
For the list of axis-options, see “Row and Column Axis Options for LAYOUT
LATTICE” on page 1140 .
The following example shows a LAYOUT LATTICE block that uses a ROWAXES
block to set the row Y axis and to display grid lines for the row display.
begingraph;
layout lattice /
rowdatarange=union
columns=2;
/* axis definitions */
rowaxes;
rowaxis /griddisplay=on;
endrowaxes;
/* cell contents */
scatterplot x=x y=t;
scatterplot x=x y=y;
endlayout;
endgraph;
specifies COLUMNS=2 and there are two plot statements in the template, the
resulting graph has two columns and only one row. Thus, only one ROWAXIS
statement is needed in the ROWAXES block to specify axis attributes for that row
of graphs. A ROW2AXES block is not needed because neither SCATTERPLOT
statement in the template maps data to the Y2 axis.
For more information and examples that demonstrate how data are mapped to the
axes, see “Plot Data Are Mapped to a Designated Axis” on page 1040 .
Header Statements
Header statements are used to display one or more headers for the rows and
columns in a LATTICE layout. Each statement is specified as a block in the form
statement - ENDstatement. The header block is typically used to specify one or
more text statements, but other statements are allowed within the block. For
example, you could specify a LAYOUT GRIDDED statement to produce a grid of
text for the header.
COLUMNHEADERS;
GTL-statement(s);
ENDCOLUMNHEADERS;
n The LAYOUT LATTICE aligns headers with the columns, or the rows, or both.
begingraph;
layout lattice / columns=2;
/* cell contents */
scatter x=x y=t;
scatter x=x y=y;
endlayout;
endgraph;
Sidebar Statements
A LAYOUT LATTICE supports the display of a sidebar between a row or column
header and a row or column axis. (See the figures in “Statement Description” on
page 141 .) A sidebar spans across columns or rows and is useful for displaying
information that applies to all of the columns or all of the rows. For example,
sidebars are useful for displaying legends.
SIDEBAR </options>;
GTL-statement(s);
ENDSIDEBAR;
n You can specify up to four SIDEBAR blocks in a LAYOUT LATTICE, one for each
of the top, bottom, left, and right sidebar positions.
n If two or more SIDEBAR blocks have the same alignment, then the sidebar
information forms two or more columns (ALIGN=LEFT or ALIGN=RIGHT) within
the sidebar area. Or it forms two or more rows (ALIGN=TOP or
ALIGN=BOTTOM) within the sidebar area.
n Only one statement (such as ENTRY or DISCRETELEGEND) or one layout block
(such as LAYOUT GRIDDED) is allowed in a SIDEBAR block. To create multi-line
text in a sidebar, nest ENTRY statements within a LAYOUT GRIDDED block.
n The LAYOUT LATTICE automatically aligns a sidebar with the lattice columns
or rows.
The following example shows a LAYOUT LATTICE block that uses a SIDEBAR
block to display a top sidebar in the lattice.
begingraph;
layout lattice / columns=2;
sidebar / align=top;
layout gridded / border=true ;
entry "Top Sidebar" ;
entry "(spans both columns)";
endlayout;
endsidebar;
152 Chapter 4 / Layout Statements
endlayout;
begingraph;
Examples
Example Graph
The following graph was generated by the “Example Program” on page 153:
LAYOUT LATTICE Statement 153
Example Program
/* Create the stock data for Microsoft for the years 2001 and 2002 */
data stockyear1 stockyear2;
set sashelp.stocks(where=(stock eq "Microsoft" and year(date) in
(2001 2002)));
volume = volume/1000000;
if year(date) = 2001 then
output work.stockyear1;
else if year(date)=2002 then
output work.stockyear2;
run;
data msstock;
merge work.stockyear1(rename=(date=year1date close=year1close
volume=year1vol))
work.stockyear2(rename=(date=year2date close=year2close
volume=year2vol));
format year1date year2date monname3. year1close year2close dollar6.;
run;
Lattice with Internal Axes” on page 152 to use common row and column axes for the
plots in the lattice. The following features are used in this example:
n the following LAYOUT LATTICE statement options:
Example Graph
The following graph was generated by the “Example Program” on page 156:
156 Chapter 4 / Layout Statements
Example Program
/* Create the stock data for Microsoft for the years 2001 and 2002 */
data stockyear1 stockyear2;
set sashelp.stocks(where=(stock eq "Microsoft" and year(date) in
(2001 2002)));
volume = volume/1000000;
if year(date) = 2001 then
output work.stockyear1;
else if year(date)=2002 then
output work.stockyear2;
run;
data msstock;
merge work.stockyear1(rename=(date=year1date close=year1close
volume=year1vol))
work.stockyear2(rename=(date=year2date close=year2close
volume=year2vol));
format year1date year2date monname3. year1close year2close dollar6.;
run;
/* Row 1 content */
layout overlay;
seriesplot x=year1date y=year1close / display=all
smoothconnect=true
lineattrs=GraphData1 markerattrs=GraphData1;
endlayout;
layout overlay;
seriesplot x=year2date y=year2close / display=all
smoothconnect=true
LAYOUT LATTICE Statement 157
lineattrs=GraphData2 markerattrs=GraphData2;
endlayout;
/* Row 2 content */
layout overlay;
needleplot x=year1date y=year1vol / displaybaseline=off
lineattrs=GraphData1;
endlayout;
layout overlay;
needleplot x=year2date y=year2vol / displaybaseline=off
lineattrs=GraphData2;
endlayout;
endlayout;
endgraph;
end;
run;
Example Graph
The following graph was generated by the “Example Program” on page 158:
158 Chapter 4 / Layout Statements
Example Program
proc template;
define statgraph layoutlattice;
begingraph;
entrytitle "Vehicle Gas Mileage";
entryfootnote "Averages of 428 models from 38 manufactures";
layout lattice / columns=2 rowdatarange=union;
layout overlay / cycleattrs=true;
barchart x=origin y=mpg_highway / stat=mean barwidth=.8
name="H" ;
barchart x=origin y=mpg_city / stat=mean barwidth=.5
name="C" ;
endlayout;
layout overlay / cycleattrs=true;
barchart x=type y=mpg_highway / stat=mean barwidth=.8;
barchart x=type y=mpg_city / stat=mean barwidth=.5;
endlayout;
sidebar / align=top;
discretelegend "H" "C" / border=false;
endsidebar;
rowaxes;
rowaxis / display=(tickvalues) displaysecondary=(tickvalues)
griddisplay=on;
endrowaxes;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.cars template=layoutlattice;
LAYOUT OVERLAY Statement 159
run;
Restrictions: You can add one or more 2-D plots to the graph area that the LAYOUT OVERLAY
statement creates, but all of the graphs will share the same set of axes.
3-D plots are not allowed.
Interaction: When nested within another layout type, the OVERLAY layout defines the graph
display for one cell of the parent layout. A separate OVERLAY layout is specified
for each cell.
Tips: If you want equal sized units on the X and Y axes, use the LAYOUT
OVERLAYEQUATED statement.
By default, the first plot specified in the LAYOUT OVERLAY block defines the axis
characteristics. If you want another plot to define the axis characteristics, specify
PRIMARY=TRUE in the statement for that plot.
Overlaid plots are stacked in the order in which they are specified. The last plot
specified is placed on top. When plots are stacked, a plots’s graphical data might
obscure the graphical data of the plots beneath it. In that case, you can change the
plot order or use transparency to make all of the graphical data visible.
The LAYOUT OVERLAY block is primarily used to specify 2-D plot statements, but
you can also specify other statements such as DISCRETELEGEND,
CONTINUOUSLEGEND, and ENTRY.
Syntax
LAYOUT OVERLAY </options>;
GTL-statements;
<INNERMARGIN </options(s)>;
block-plot-statement(s); | axis-table statement(s);
ENDINNERMARGIN;>
<… more-innermargin-blocks …> >
ENDLAYOUT;
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
BORDERATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the border line around the layout.
CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills
in nested plot statements automatically change from plot to plot.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or
transparent (FALSE).
OUTERPAD=AUTO | dimension | (pad-options)
specifies the amount of extra space to add outside the layout border.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout
border.
WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
WALLDISPLAY=STANDARD | ALL | NONE | (display-options)
specifies whether the plot’s wall and wall outline are displayed.
Axes options
X2AXISOPTS=(axis-options)
specifies one or more X2 axis options.
XAXISOPTS=(axis-options)
specifies one or more X-axis options.
Y2AXISOPTS=(axis-options)
specifies one or more Y2 axis options.
YAXISOPTS=(axis-options)
specifies one or more Y-axis options.
Optional Arguments
ASPECTRATIO=AUTO | positive-number
specifies the aspect ratio of the plot’s wall area. The ratio is expressed as a
positive decimal fraction representing wall-height divided by wall-width. For
example, 0.75 is a 3/4 aspect ratio and 1.0 is a square aspect ratio.
Default AUTO. The wall area is sized to the maximum area that can fill the
available space inside the OVERLAY layout.
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills in
nested plot statements automatically change from plot to plot.
FALSE
does not cycle the default visual attributes of multiple plots.
For example, if you overlay three series plots, then each series line has the
same default visual properties.
TRUE
attempts to use the GraphData1–GraphDataN style elements to assign
different visual properties to applicable plots (scatter plots and series plots
and others).
Some plots in the layout do not participate in the cycling (for example,
reference lines and drop lines).
162 Chapter 4 / Layout Statements
Default FALSE
See “Rotating Visual Attributes for Each Plot in an Overlay” on page 210
“boolean ” on page xii for other Boolean values that you can use.
Example In the following example, the first three series plots are assigned line
properties that are based on the GraphData1, GraphData2, and
GraphData3 style elements. The fourth series plot does not
participate in the attribute cycling because its LINEATTRS= option
assigns a line style.
layout overlay / cycleattrs=true;
seriesplot x=date y=var1;
seriesplot x=date y=var2;
seriesplot x=date y=var3;
seriesplot x=date y=var4 / lineattrs=GraphReference;
endlayout;
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the layout border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can contain one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
LAYOUT OVERLAY Statement 163
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the border.
(pad-options)
a space-separated list of one or more name-value-pair pad options enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
Default 0
RIGHT=dimension
specifies the amount of extra space added to the right side.
Default 0
TOP=dimension
specifies the amount of extra space added to the top.
Default 0
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Default 0
Note Sides that are not assigned padding are padded with the default
amount.
WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
164 Chapter 4 / Layout Statements
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
STANDARD
displays a filled wall.
ALL
displays a filled, outlined wall.
NONE
displays no wall and no wall outline.
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
Default STANDARD
Tips Use the WALLCOLOR= option to control the fill color of the wall.
The appearance attributes of the wall fill and outline for occupied cells
are set by the GraphWalls style element. For empty cells, the outline
color is set by the ContrastColor attribute of the GraphBorderLines
style element, the line style is solid, and the line thickness is 1 pixel.
XAXISOPTS=(axis-options)
specifies one or more X-axis options.
See “Axis Options for LAYOUT OVERLAY” on page 1055 for a list of
axis options.
X2AXISOPTS=(axis-options)
specifies one or more X2 axis options.
See “Axis Options for LAYOUT OVERLAY” on page 1055 for a list of
axis options.
YAXISOPTS=(axis-options)
specifies one or more Y-axis options.
See “Axis Options for LAYOUT OVERLAY” on page 1055 for a list of
options.
Y2AXISOPTS=(axis-options)
specifies one or more Y2 axis options.
See “Axis Options for LAYOUT OVERLAY” on page 1055 for a list of
options.
Details
The LAYOUT OVERLAY statement builds a composite using one or more GTL-
statements. You can specify one or more two-dimensional plots within the layout,
provided all plots can share the same type of axes. You can also specify one or
more insets, such as nested layout statements (for example, LAYOUT GRIDDED),
ENTRY statements, and legend statements (for example, CONTINUOUSLEGEND
or DISCRETELEGEND).
Note: The details for positioning insets also apply to insets that are specified
within a LAYOUT REGION block.
n All plot statements are rendered first. Plot statement results are always
rendered in the plot area. The plots are stacked on top of one another in the
order in which they are specified, with the last one on top. It is possible for one
plot’s graphical data to obscure graphical data beneath it. You can control this
by selectively ordering the plot statements, or by using transparency on the
individual plots, or by doing both.
n The insets are rendered next, in the order in which they are specified. As with
the plot statements, it is possible for the insets to obscure the results of other
statements in the layout.
n To control the horizontal and vertical positioning of some insets, you can use
the inset statement’s AUTOALIGN= option, or its HALIGN= and VALIGN=
options. Each nested inset determines its own relative position in the parent
OVERLAY. This positioning achieves the best results for text-based insets
whose size can be easily fit within an open area of the graph wall. A large text-
based inset might not fit well, and an inset that contains a plot might be
dropped from the display without warning when the template is executed.
n Some insets, like legends, can be positioned inside or outside of the plot area
using the inset statement’s LOCATION= option. The inset’s AUTOALIGN= or
HALIGN= and VALIGN= settings are then relative to that location.
Generally, the first specified plot determines the layout’s default axis
characteristics. To enable another plot to define the axis characteristics, set
PRIMARY=TRUE for that plot. For more information about the default axis
characteristics, see “When Plots Share Data and a Common Axis” on page 1046. See
also the LAYOUT OVERLAYEQUATED and the LAYOUT OVERLAY3D statements.
An OVERLAY layout can also contain an inner margin, which is a nested region at
the top or bottom of the OVERLAY container. One or more inner margin plots can
be specified, and each is specified within an INNERMARGIN block. Within the
INNERMARGIN block, only one-dimensional plot statements such as BLOCKPLOT
and AXISTABLE can be specified. See “INNERMARGIN Statement” on page 193.
This layout has only two independent axes from a data standpoint, X and Y. If any
contained plot uses an X=X2 or Y=Y2 option, then the option is ignored and the
data is mapped to the X or Y axis. However, the X2 and Y2 axes can be displayed
using the DISPLAYSECONDARY= suboption of the XAXISOPTS= and YAXISOPTS=
options.
Interaction: When nested within another layout type, the OVERLAYEQUATED layout defines
the graph display for one cell of the parent layout. A separate OVERLAYEQUATED
layout is specified for each cell.
Tips: By default, the first plot specified in the LAYOUT OVERLAYEQUATED block
defines the axis characteristics. If you want another plot to define the axis
characteristics, specify PRIMARY=TRUE in the statement for that plot.
Overlaid plots are stacked in the order in which they are specified. The last plot
specified is placed on top. When plots are stacked, a plots’s graphical data might
obscure the graphical data of the plots beneath it. In that case, you can change the
plot order or use transparency to make all of the graphical data visible.
Syntax
LAYOUT OVERLAYEQUATED </options>;
GTL-statements;
ENDLAYOUT;
Axes options
COMMONAXISOPTS=(common-axis-options)
specifies one or more options to apply to both the X and Y equated axes.
EQUATETYPE=FIT | SQUARE | SQUAREDATA | EQUATE
specifies how to draw the axis area.
XAXISOPTS=(axis-options)
specifies one or more X-axis options.
YAXISOPTS=(axis-options)
specifies one or more Y-axis options.
Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
COMMONAXISOPTS=(common-axis-options)
specifies one or more options to apply to both the X and Y equated axes.
See “Options That Apply to Both Equated Axes” on page 1197 for a list
of options.
CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills in
nested plot statements automatically change from plot to plot.
FALSE
does not cycle the default visual attributes of multiple plots.
For example, if you overlay three series plots, then each series line has the
same default visual properties.
TRUE
attempts to use the GraphData1–GraphDataN style elements to assign
different visual properties to applicable plots (scatter plots and series plots
and others).
Some plots in the layout do not participate in the cycling (for example,
reference lines and drop lines).
Default FALSE
See “Rotating Visual Attributes for Each Plot in an Overlay” on page 210
“boolean ” on page xii for other Boolean values that you can use.
FIT
specifies that the X and Y axes have equal increments between tick values.
The data ranges of both axes are compared to establish a common increment
size. The axes might be of different lengths and have a different number of
tick marks. Each axis represents its own data range. One axis might be
extended to use available space in the plot area. If a TICKVALUELIST= or
TICKVALUESEQUENCE= axis option is used on COMMONAXISOPTS= , then
it is ignored.
SQUARE
specifies that both the X and Y axes have the same length and the same
major tick values.
The axis length and tick values are chosen so that the minimum and
maximum of both X and Y appear in the range of values appearing on both
axes.
SQUAREDATA
specifies that both the X and Y axes have the same data range, but they can
have different tick values.
A UNION of the data ranges does not occur in this case. For example, if the
X-axis values are 20 to 40 (range of 20) and the Y-axis values are 200 to
260 (range of 60), then both axes have a range of 60 units, but the X axis can
have tick values 0, 20, 40, and 60, and the Y axis can have tick values 200,
220, 240, and 260.
EQUATE
same as FIT except that neither axis is extended to use available space in
the plot area.
Default FIT
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the layout border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
LAYOUT OVERLAYEQUATED Statement 173
The list can contain one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the border.
(pad-options)
a space-separated list of one or more name-value-pair pad options enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
Default 0
RIGHT=dimension
specifies the amount of extra space added to the right side.
Default 0
TOP=dimension
specifies the amount of extra space added to the top.
Default 0
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Default 0
174 Chapter 4 / Layout Statements
Note Sides that are not assigned padding are padded with the default
amount.
WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
STANDARD
displays a filled wall.
ALL
displays a filled, outlined wall.
NONE
displays no wall and no wall outline.
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
Default STANDARD
Tips Use the WALLCOLOR= option to control the fill color of the wall.
The appearance attributes of the wall fill and outline for occupied cells
are set by the GraphWalls style element. For empty cells, the outline
LAYOUT OVERLAYEQUATED Statement 175
XAXISOPTS=(axis-options)
specifies one or more X-axis options.
YAXISOPTS=(axis-options)
specifies one or more Y-axis options.
Details
The LAYOUT OVERLAYEQUATED statement is similar to the LAYOUT OVERLAY
statement: it builds a composite using one or more GTL-statements. Similar to a
LAYOUT OVERLAY, you can specify one or more 2-D plots within the layout,
provided all plots can share the same type of axes. (Additional restrictions are
discussed in a moment.) You can also specify one or more insets.
n For equal data intervals on both axes, the display distance is the same. For
example, an interval of 2 on the X axis maps to the same display distance as an
interval of 2 on the Y axis.
n The aspect ratio of the plot display equals the aspect ratio of the plot data. In
other words, a 45-degree slope in data is represented by a 45-degree slope in
the display. The EQUATETYPE= option determines how the axes are drawn.
The following figure illustrates how a series plot might map differently when
specified in an OVERLAYEQUATED layout versus an OVERLAY layout:
From a data standpoint, this layout has only two independent axes, X and Y. If any
plots within the layout block use an XAXIS=X2 or YAXIS=Y2 option, then the
option is ignored and the data are mapped to the X or Y axis. To display X2 and Y2
axes, use the DISPLAYSECONDARY= suboption of the XAXISOPTS= and
YAXISOPTS= options.
Example Program
proc template;
define statgraph layoutoverlayequated;
begingraph;
entrytitle "Gas Mileage for GMC Models";
layout overlayequated / equatetype=fit;
referenceline y=16.2 /
curvelabel="City Average for Trucks/SUVs"
curvelabellocation=inside
curvelabelattrs=GraphReference;
referenceline x=20.6 /
curvelabel="Highway Average for Trucks/SUVs"
curvelabellocation=inside
curvelabelattrs=GraphReference;
scatterplot x=mpg_highway y=mpg_city /
datalabel=model;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.cars
template=layoutoverlayequated;
where make="GMC";
run;
178 Chapter 4 / Layout Statements
Restriction: You can add one or more 3-D plots to the graph area that the LAYOUT OVERLAY3D
statement creates, but all of the graphs will share the same set of axes.
Tips: By default, the first plot specified in the LAYOUT OVERLAY3D block defines the
axis characteristics. If you want another plot to define the axis characteristics,
specify PRIMARY=TRUE in the statement for that plot.
Overlaid plots are stacked in the order in which they are specified. The last plot
specified is placed on top. When plots are stacked, a plots’s graphical data might
obscure the graphical data of the plots beneath it. In that case, you can change the
plot order or use transparency to make all of the graphical data visible.
The LAYOUT OVERLAY3D block is primarily used to specify 3-D plot statements,
but you can also specify other statements such as CONTINUOUSLEGEND.
Syntax
LAYOUT OVERLAY3D </options>;
GTL-statements;
ENDLAYOUT;
Axes options
XAXISOPTS=(axis-options)
specifies one or more X-axis options.
YAXISOPTS=(axis-options)
specifies one or more Y-axis options.
ZAXISOPTS=(axis-options)
specifies one or more Z-axis options.
Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CUBE=TRUE | FALSE
specifies whether the layout displays the lines that indicate the complete
bounding cube of the axis planes.
Default TRUE
Note The cube lines are displayed independently of the wall borders and axis
lines. Because some cube lines coincide with wall borders and axis
lines, it might appear that turning off wall borders or axis lines has no
effect when CUBE=TRUE.
Tip The color, thickness, and pattern of the cube lines are determined by
the GraphAxisLines style element.
See “boolean ” on page xii for other Boolean values that you can use.
CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills in
nested plot statements automatically change from plot to plot.
FALSE
does not cycle the default visual attributes of multiple plots.
For example, if you overlay three series plots, then each series line has the
same default visual properties.
TRUE
attempts to use the GraphData1–GraphDataN style elements to assign
different visual properties to applicable plots (scatter plots and series plots
and others).
Some plots in the layout do not participate in the cycling (for example,
reference lines and drop lines).
Default FALSE
See “Rotating Visual Attributes for Each Plot in an Overlay” on page 210
“boolean ” on page xii for other Boolean values that you can use.
LAYOUT OVERLAY3D Statement 181
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the layout border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can contain one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the border.
182 Chapter 4 / Layout Statements
(pad-options)
a space-separated list of one or more name-value-pair pad options enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
Default 0
RIGHT=dimension
specifies the amount of extra space added to the right side.
Default 0
TOP=dimension
specifies the amount of extra space added to the top.
Default 0
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Default 0
Note Sides that are not assigned padding are padded with the default
amount.
ROTATE=number
specifies the angle of rotation. Rotation is measured in a clockwise direction
about a virtual axis parallel to the Z axis (vertical) and passing through the
center of the bounding cube. A counterclockwise rotation can be specified with
a negative value.
Default 54
TILT=number
specifies the angle of tilt in degrees. Tilt is measured in a clockwise direction
about a virtual axis parallel to the X axis (vertical) and passing through the
center of the bounding cube. A counterclockwise rotation can be specified with
a negative value.
Default 20
WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
LAYOUT OVERLAY3D Statement 183
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
STANDARD
displays a filled wall.
ALL
displays a filled, outlined wall.
NONE
displays no wall and no wall outline.
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
Default STANDARD
Tips Use the WALLCOLOR= option to control the fill color of the wall.
The appearance attributes of the wall fill and outline for occupied cells
are set by the GraphWalls style element. For empty cells, the outline
color is set by the ContrastColor attribute of the GraphBorderLines
style element, the line style is solid, and the line thickness is 1 pixel.
XAXISOPTS=(axis-options)
specifies one or more X-axis options.
See “Axis Options for LAYOUT OVERLAY3D” on page 1119 for a list of
axis options.
YAXISOPTS=(axis-options)
specifies one or more Y-axis options.
See “Axis Options for LAYOUT OVERLAY3D” on page 1119 for a list of
axis options.
ZAXISOPTS=(axis-options)
specifies one or more Z-axis options.
See “Axis Options for LAYOUT OVERLAY3D” on page 1119 for a list of
axis options..
ZOOM=positive-number
specifies a zoom factor. Factors greater than 1 move closer to the bounding
cube, less than 1 move farther away
Default 1
Details
The LAYOUT OVERLAY3D statement builds a 3-D composite using one or more
GTL-statements. You can specify one or more 3-D plots within the layout, provided
all plots can share the same type of axes. You can also specify “annotations” (for
example, with one or more ENTRY statements or LAYOUT GRIDDED statements).
However, annotations in the OVERLAY3D layout are more likely to collide with
other graphics features than are annotations in other overlay-type layouts.
Within an OVERLAY3D layout, a graph’s bounding cube can be tilted, rotated, and
zoomed to provide a different viewpoint. By default, the outline of the bounding
cube is displayed and the viewing rotation angle is 57 degrees, the tilt angle is 20
degrees, and the zoom factor is 1. See the CUBE= , ROTATE= , TILT= , and ZOOM=
options for information about how to change the viewpoint.
Example Program
proc template;
define statgraph layoutoverlay3d;
begingraph;
entrytitle "Density Plot of Height and Weight";
layout overlay3d / tilt=10 rotate=54
walldisplay=none cube=false;
surfaceplotparm x=height y=weight z=density /
surfacecolorgradient=density;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.gridded template=layoutoverlay3d;
run;
186 Chapter 4 / Layout Statements
Restrictions: You can specify only one LAYOUT PROTOTYPE block in a LAYOUT DATAPANEL or
LAYOUT DATALATTICE block. If you specify more than one, then only the last
prototype block specified is honored. The remaining prototype blocks are ignored.
Only the following plots can be used in a LAYOUT PROTOTYPE block: BANDPLOT,
BARCHART, BARCHARTPARM, BLOCKPLOT, BOXPLOTPARM,
COUNTOURPLOTPARM, DROPLINE, ELLIPSEPARM, FRINGEPLOT,
HEATMAPPARM, HISTOGRAMPARM, LINECHART, LINEPARM, NEEDLEPLOT,
REFERENCELINE, SCATTERPLOT, SERIESPLOT, STEPPLOT, and VECTORPLOT.
SCATTERPLOTMATRIX plots, 3-D plots, and region plots such as PIECHART or
MOSAICPLOTPARM cannot be used in the LAYOUT PROTOTYPE block.
ENTRY, DISCRETELEGEND, and CONTINUOUSLEGEND statements cannot be
used in the LAYOUT PROTOTYPE block.
A plot statement cannot be used if it contains a column defined with an EVAL
expression.
You can add one or more two-dimensional plots and one-dimensional plots to the
graph area that the LAYOUT PROTOTYPE statement creates, provided all of the
graphs can share the same axis type.
If you include a plot statement with a CURVELABEL= option (such as
SERIESPLOT), then only CURVELABELLOCATION=INSIDE is supported.
If you include a plot statement that supports a CLIP= option (such as LINEPARM or
ELLIPSEPARM), then the CLIP value is always set to TRUE.
Requirement: The LAYOUT PROTOTYPE statement must be nested in a LAYOUT DATAPANEL or
LAYOUT DATALATTICE block.
Note: Nesting an INNERMARGIN block in the LAYOUT PROTOTYPE statement is valid in
SAS 9.4M1 and later releases.
See: “LAYOUT DATAPANEL Statement” on page 79
“LAYOUT DATALATTICE Statement” on page 51
Syntax
LAYOUT PROTOTYPE </option(s)>;
plot-statements;
<INNERMARGIN </options(s)>;
block-plot-statement(s); | axis-table statement(s);
ENDINNERMARGIN;>
<… more-innermargin-blocks …> >
ENDLAYOUT;
LAYOUT PROTOTYPE Statement 187
Optional Arguments
ASPECTRATIO=AUTO | positive-number
specifies the aspect ratio of the prototype cell. The ratio is expressed as a
positive decimal fraction representing wall-height divided by wall-width. For
example, 0.75 is a 3/4 aspect ratio and 1.0 is a square aspect ratio.
Default AUTO. The prototype cell is sized to the maximum area that can fill the
available space inside the layout cell.
Note If AUTO is not used for the aspect ratio, then the entire DATALATTICE
or DATAPANEL grid is affected and changes shape.
CYCLEATTRS=TRUE | FALSE
specifies whether the default visual attributes of markers, lines, and fills in
nested plot statements automatically change from plot to plot.
FALSE
does not cycle the default visual attributes of multiple plots.
For example, if you overlay three series plots, then each series line has the
same default visual properties.
TRUE
attempts to use the GraphData1–GraphDataN style elements to assign
different visual properties to applicable plots (scatter plots and series plots
and others).
Some plots in the layout do not participate in the cycling (for example,
reference lines and drop lines).
Default FALSE
See “Rotating Visual Attributes for Each Plot in an Overlay” on page 210
“boolean ” on page xii for other Boolean values that you can use.
WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
STANDARD
displays a filled wall.
ALL
displays a filled, outlined wall.
NONE
displays no wall and no wall outline.
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
Default STANDARD
Tips Use the WALLCOLOR= option to control the fill color of the wall.
The appearance attributes of the wall fill and outline for occupied cells
are set by the GraphWalls style element. For empty cells, the outline
color is set by the ContrastColor attribute of the GraphBorderLines
style element, the line style is solid, and the line thickness is 1 pixel.
When the wall outline is suppressed, adjacent lines such as axis lines
and cell-header borders are still displayed. To suppress the axis lines,
use the appropriate display option for the axes. The cell-header borders
cannot be suppressed.
Details
The LAYOUT PROTOTYPE statement defines a plot prototype or “rubber stamp”
that repeats automatically. It assembles the results of nested GTL statements into
a single axis area. The plots are drawn in the order in which they are specified. The
results of the last statement are placed on top.
The plot-statements determine the graphical content of the cells in the parent
layout, based on the subsetting of the specified classification variables. For an
example, see “LAYOUT DATALATTICE Statement” on page 51 or “LAYOUT
DATAPANEL Statement” on page 79.
In SAS 9.4 and later releases, a PROTOTYPE layout can also contain an inner
margin, which is a nested region at the top or bottom of the PROTOTYPE container.
One or more inner margin plots can be specified, and each is specified within an
INNERMARGIN block. Within the INNERMARGIN block, only one-dimensional plot
statements such as BLOCKPLOT and AXISTABLE can be specified. See
“INNERMARGIN Statement” on page 193.
Restrictions: A LAYOUT REGION block cannot contain more than one plot.
A LAYOUT REGION block can contain a PIECHART or MOSAICPLOTPARM plot
only.
Syntax
LAYOUT REGION </options>;
GTL-statements;
ENDLAYOUT;
Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the layout background.
style-reference
specifies a style reference in the form style-element:style-attribute.
color
specifies a color by name.
BORDER=TRUE | FALSE
specifies whether a border is drawn around the layout.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
OPAQUE=TRUE | FALSE
specifies whether the layout background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the layout border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can contain one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the layout border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the border.
(pad-options)
a space-separated list of one or more name-value-pair pad options enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
Default 0
RIGHT=dimension
specifies the amount of extra space added to the right side.
Default 0
TOP=dimension
specifies the amount of extra space added to the top.
Default 0
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Default 0
Note Sides that are not assigned padding are padded with the default
amount.
Details
The REGION layout provides a container for plots that do not use axes. Within the
LAYOUT REGION block, you can specify a single plot statement of a type that
never uses axes, such as a PIECHART or MOSAICPLOTPARM. If multiple plot
192 Chapter 4 / Layout Statements
statements are specified, then only the first one is honored. You can also specify
one or more insets, such as nested layout statements (for example, LAYOUT
GRIDDED), ENTRY statements, and legend statements (CONTINUOUSLEGEND or
DISCRETELEGEND). For example, you could specify a PIECHART statement with a
DISCRETELEGEND statement and an ENTRY statement. You can also nest one or
more layout blocks within the REGION layout. For example, you could nest a
LAYOUT GRIDDED statement that creates a small table of text.
When nested within another layout type, such as a GRIDDED or LATTICE layout,
the REGION layout defines the graphical display for one cell of the parent layout. A
separate REGION layout is specified for each cell.
Example Program
proc template;
define statgraph layoutregion;
begingraph;
entrytitle "Average Weight by Age";
layout region;
piechart category=age response=weight /
stat=mean name="p"
datalabelcontent=(response) datalabellocation=outside;
discretelegend "p" / title="Age" across=2
INNERMARGIN Statement 193
INNERMARGIN Statement
Provides a nested region in a LAYOUT OVERLAY or LAYOUT PROTOTYPE container in which a block
plot or axis table can be placed.
Restriction: This statement is valid in LAYOUT OVERLAY and LAYOUT PROTOTYPE blocks
only.
Notes: Two or more INNERMARGIN blocks that have the same alignment are stacked.
Multiple statements within an INNERMARGIN block are stacked.
For an X axis, the offsets on each end of the Y axis are increased to make room for
the inner margin plots. For a Y axis, the offsets on each end of the X axis are
increased to make room for the inner margin plots.
Syntax
INNERMARGIN < /options>;
block-plot-statement(s); | axis-table statement(s);
ENDINNERMARGIN;
Optional Arguments
ALIGN=TOP | BOTTOM | LEFT | RIGHT
specifies the alignment of the inner margin.
Default BOTTOM
194 Chapter 4 / Layout Statements
Restrictions For a block plot, only TOP and BOTTOM are valid. LEFT and RIGHT
are ignored.
For an axis table, LEFT and RIGHT can be used for a Y or Y2 axis.
BACKGROUNDCOLOR=style-reference | color
specifies the color of the inner margin background.
style-reference
specifies a style reference in the form style-element:style-attribute. Only the
style attributes named COLOR or CONTRASTCOLOR are used.
color
specifies a color by name.
Interaction For this option to have any effect, the OPAQUE= option must be set
to TRUE.
Note The inner margin background is set to the wall color even when
WALLDISPLAY= NONE.
GUTTER=dimension
specifies the gap between stacked items in the inner margin.
Default 0
Requirement The inner margin must contain two or more stacked items for this
option to have any effect.
OPAQUE=TRUE | FALSE
specifies whether the inner margin's background is opaque.
TRUE
specifies that the background is opaque.
FALSE
specifies that the background is transparent.
INNERMARGIN Statement 195
Default FALSE
Tip To prevent axis color bars and grid lines from passing through the
axis table, set OPAQUE=TRUE.
See “boolean ” on page xii for other Boolean values that you can use.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the inner-margin border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the border.
(pad-options)
a space-separated list of one or more name-value-pair pad options enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
Default 0
RIGHT=dimension
specifies the amount of extra space added to the right side.
Default 0
TOP=dimension
specifies the amount of extra space added to the top.
Default 5 px for the first inner margin adjacent to the bottom of the plot
area. Otherwise, 0.
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Default 5 px for the first inner margin adjacent to the top of the plot area.
Otherwise, 0.
Note Sides that are not assigned padding are padded with the default
amount.
SEPARATOR=TRUE | FALSE
specifies whether a separating line is drawn between the inner margin and the
rest of the layout content.
Default FALSE
“boolean ” on page xii for other Boolean values that you can use.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Details
An inner margin is a nested region in an OVERLAY container. You can specify one or
more inner margin plots. Specify each plot within an INNERMARGIN block. Within
an INNERMARGIN block, you can specify only the BLOCKPLOT and AXISTABLE
statements. See “Example: Overlay with an Inner Margin Plot” on page 197.
INNERMARGIN Statement 197
Example Overview
This example shows how to place a plot in an inner margin of an OVERLAY layout.
It creates a graph that shows monthly total sales for a specific year. A LINECHART
statement is used to draw the plot. The months are shown along the category axis,
and the total sales values are shown along the response axis. The Sashelp.Prdsale
data set is used as the data source. The tick marks on the category axis are
positioned between the midpoints to align with the beginning of each month.
Example Output
Here is the output for this example.
198 Chapter 4 / Layout Statements
Example Program
Here is the SAS code.
/* Create a format for the quarters */
proc format;
value quartername 1="Quarter 1" 2="Quarter 2"
3="Quarter 3" 4="Quarter 4";
run;
PART 4
Plot Statements
Chapter 5
Key Concepts for Using Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Chapter 6
Plot Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
200
201
5
Key Concepts for Using Plots
The following SAS program shows the basic structure needed to meet the minimum
requirements for generating a plot using GTL:
proc template;
define statgraph minimumreq;
begingraph;
layout overlay;
scatterplot x=weight y=height;
endlayout;
endgraph;
202 Chapter 5 / Key Concepts for Using Plots
end;
run;
The default image size of 640 pixels by 480 pixels (4:3 aspect ratio) for ODS
Graphics is set in the SAS Registry. You can change the image size using the
WIDTH= option, or the HEIGHT= option, or both in the ODS GRAPHICS statement.
To name the output image file, use the IMAGENAME= option.
The following ODS GRAPHICS statement sets a 320-pixel width for the graph and
names the output image file modelfit:
n The WIDTH= option sets the image width to 320 pixels. Because no HEIGHT=
option is used, SAS uses the design aspect ratio of the graph to compute the
appropriate height. (The width of 320px is half the default width, so SAS sets
the height to 240px, which is half the default height.)
n The IMAGENAME= option sets the name of the output image file to modelfit.
The RESET option ensures that each time the graph is produced, the previous
version of the image file is replaced. Otherwise, image names are incremented
(modelfit1, modelfit2, and so on) every time the graph is produced.
In general, it is good practice to specify only one sizing option without the other—
just the WIDTH= option or just the HEIGHT= option. That way SAS can maintain
the design aspect ratio of the graph, which might be important for many graphs. For
example, a graph that has multiple columns or a statistics table on the side needs a
wide aspect ratio. Specifying both width and height in such cases might produce
unpredictable results.
Note: Size settings in the ODS GRAPHICS statement affect all of the graphs that
are rendered in the SAS session, unless they are changed by another ODS
GRAPHICS statement. The size for a graph produced by an individual template can
be set with the DESIGNWIDTH= and DESIGNHEIGHT= options in the
BEGINGRAPH statement. Size settings in the ODS GRAPHICS statement override
size settings in the BEGINGRAPH statement and remain in effect unless they are
changed in another ODS GRAPHICS statement or ODS GRAPHICS are turned off.
For more information about using the ODS GRAPHICS statement in GTL, see SAS
Graph Template Language: User’s Guide. For a more complete discussion of the ODS
GRAPHICS statement, see “ODS GRAPHICS Statement” on page 1561.
Display Attributes
Overview
The display attributes for the lines, colors, marker symbols, and text used in a graph
are derived from the ODS style that is in effect when the graph is produced. These
display attributes might also be influenced by grouped data. To override default
display attributes, all GTL plot statements provide options that manage the graph’s
visual appearance. For example, a BOXPLOT statement provides an
OUTLIERATTRS= option that manages the visual appearance of outliers.
Two ways are generally available for modifying a graph’s display attributes:
n Change the ODS style that is in effect for the graph. “ODS Styles” on page 18
provides an overview of the use of styles in a graph. SAS Graph Template
Language: User’s Guide discusses the use of styles in more detail.
204 Chapter 5 / Key Concepts for Using Plots
n Override default style settings using GTL statement options. Some examples
are given in the sections that follow.
Pattern
Number Pattern Name Example
1 Solid
2 ShortDash
4 MediumDash
5 LongDash
8 MediumDashShortDash
14 DashDashDot
15 DashDotDot
20 Dash
26 LongDashShortDash
34 Dot
35 ThinDot
41 ShortDashDot
Display Attributes 205
Pattern
Number Pattern Name Example
42 MediumDashDotDot
“Available Line Patterns” on page 1607 provides the complete list of line patterns
that can be used with GTL.
Other display options can be managed the same way. For example, the
SCATTERPLOT statement provides a MARKERATTRS= option that specifies the
color, size, symbol, and weight of the plot data markers. For non-grouped data, if
you do not set a marker symbol in your template, then the default marker symbol is
obtained from the GraphDataDefault:MarkerSymbol style reference.
ArrowDown StarFilled
Asterisk Tack
Circle Tilde
CircleFilled Triangle
Diamond TriangleFilled
DiamondFilled TriangleDown
206 Chapter 5 / Key Concepts for Using Plots
GreaterThan TriangleDownFilled
Hash TriangleLeft
HomeDown TriangleLeftFilled
HomeDownFilled TriangleRight
IBeam TriangleRightFilled
LessThan Union
Plus X
Square Y
SquareFilled Z
Star
type). The defaults for these features are set by the LineStyle, Color, ContrastColor,
FillPattern, and MarkerSymbol attributes of the GraphData1–GraphDataN style
elements. The MarkerSize and LineThickness style attributes are not honored in the
case of grouped data.Table 5.1 on page 204 shows the common line patterns that
are available, and Table 5.2 on page 205 shows the marker symbols that are
available.
When missing group values are displayed, the default attributes of the missing
value are set by the GraphMissing style element unless the MISSING= system
option specifies a character other than "." or " ". In that case, missing group value
attributes are determined by the GraphData1–GraphDataN style elements.
For grouped plots, attributes such as colors, line patterns, and marker symbols are
used to distinguish the individual group values. The attributes are derived from the
GraphData1–GraphDataN style elements in the current style. Each group value is
assigned attributes from a GraphData1-GraphDataN style element sequentially (1
to N). When plotting a SAS data set, the group-value attributes are assigned in data
order. When plotting a CAS in-memory table, the group-value attributes are
assigned in ascending order of the group column character or unformatted numeric
values. For information about attribute rotation, see “Attribute Rotation Patterns”
in SAS Graph Template Language: User’s Guide.
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–GraphDataN.
In the following example, a style is defined to change the line pattern for
GraphData1 and GraphData2. In this example, the style is derived from the
DEFAULT style. 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.
data class;
merge class stats(keep=intercept slope sex);
run;
proc template;
/* Create custom style MYDEFAULT from the STYLES.DEFAULT style. */
define style MyDefault;
parent=Styles.Default;
style GraphData1 from GraphData1 /
LineStyle=6;
style GraphData2 from GraphData2 /
LineStyle=4;
end;
Similarly, for grouped data, you can set the MarkerSymbol attribute in each of the
style elements GraphData1–GraphDataN. In the following example, a style is
defined to change the MarkerSymbol attribute for GraphData1–GraphData3. This
new sequence is used as the default marker symbol sequence for any grouped plot
that uses the MyDefault style.
Note: The data that was generated in the previous example is used again in this
example.
proc template;
/* Create custom style MYDEFAULT from STYLES.DEFAULT. */
define style MyDefault;
parent=Styles.Default;
style GraphData1 from GraphData1 /
MarkerSymbol="DIAMOND";
style GraphData2 from GraphData2 /
MarkerSymbol="CROSS";
style GraphData3 from GraphData3 /
MarkerSymbol="CIRCLE";
end;
In the following example, assuming ungrouped data and the default attribute
rotation pattern, the series plots are assigned line properties based on the
GraphData1, GraphData2, and GraphData3 style elements. The reference line uses
GraphReference, not GraphData4.
layout overlay / cycleattrs=true;
seriesplot x=date y=var1;
seriesplot x=date y=var2;
seriesplot x=date y=var3;
referenceline x=cutoff / lineattrs=GraphReference;
endlayout;
If one of the plots in this example uses grouped data, then the grouped plots also
participate in the default cycles. For example, if the second plot has three groups,
Display Attributes 211
then it generates three plots, which are assigned line properties based on the
GraphData2, GraphData3, and GraphData4 style elements.
If the plot statement that uses grouped data also uses the INDEX= option to
manage the group values (see “Remapping Groups for Grouped Data” on page 211),
then the INDEX= option overrides the default behavior. In that case, the grouped
plots do not participate in the default cycling.
When one or more of the plots within the layout override the default cycling
behavior, the arrangement of the plots within the layout might affect the default
mapping of the GraphDataN elements to those statements that participate in the
default cycling.
Indexing can control the order in which colors, area fills, marker symbols, and line
styles are mapped to group values in a graph. This ordering method is needed only
for coordinating the data display of multiple graphs when the default mapping
would cause group values to be mismatched between graphs.
For example, consider two studies of three drugs, A, B, and C. If Study 1 uses all
three drugs, then the first combination of color and marker symbol is mapped to
Drug A. The second combination of color and marker symbol is mapped to Drug B,
and the third is mapped to Drug C. If Study 2 omits Drug A, then the first
combination of color and marker symbol is mapped to Drug B, and the second is
mapped to Drug C. If the two graphs are viewed together, then this default mapping
causes the group values to be mismatched. The visual attributes that represent
Drug A in the first graph represent Drug B in the second graph. Those that represent
Drug B in the first graph represent Drug C in the second group.
The GROUP= option mappings can be made consistent between the two graphs by
creating an index column for each study. For these example studies, the GROUP
and INDEX columns are the following:
Drug1 Index1
A 1
B 2
B 2
C 3
212 Chapter 5 / Key Concepts for Using Plots
Drug2 Index2
B 2
C 3
C 3
If the graph for Study 1 specifies INDEX=INDEX1 and the graph for Study 2 specifies
INDEX=INDEX2, then the second combination of color and marker symbol is
mapped to Drug B in both graphs. The third combination of color and marker
symbol is mapped to Drug C in both graphs.
The option interactions are not limited to options that simply manage visual
elements. For example, on a BOXPLOT, if the EXTREME= option extends the box
whiskers beyond the fences, then outliers are suppressed in the plot and options
that affect the outliers are ignored, if set.
The documentation for each GTL statement identifies the option interactions that
might occur on that statement.
Location and Position of Curve Labels 213
Overview
On plots that generate a curve line (a series plot or a density plot, for example), you
can specify a label for the curve line. You can also determine the label’s location in
the graph. For example, the SERIESPLOT statement provides the following options
for managing a curve label:
CURVELABEL
specifies a label for the curve line.
CURVELABELLOCATION
specifies the location of the curve line label relative to the plot area.
CURVELABELPOSITION
specifies the position of the label relative to the curve line.
Depending on the shape of the curve line, its distribution of values, and the other
plot elements that must be displayed within the plot area, GTL might have to add
an offset (see “Adjusting Axis Offsets” on page 1053) to one of the plot’s axis lines to
provide enough room for the curve label. To prevent the offset of the axis line, you
214 Chapter 5 / Key Concepts for Using Plots
can move the curve label outside of the plot area by specifying
CURVELABELLOCATION=OUTSIDE on the plot statement:
Regardless of whether the curve label is displayed inside or outside of the plot area,
you can use the CURVELABELPOSITION= option to adjust the label’s position
relative to the curve line.
The following figure shows the different combinations of label locations and
positions:
n The minimum or maximum axis tick marks can be adjusted (see “Adjusting Axis
Offsets” on page 1053) so that the label can be placed inside the plot area.
Increasing label length decreases the area available for displaying plots.
n When CURVLABELLOCATION=OUTSIDE, you can set the
CURVELABELPOSITION to MIN or MAX, but the label might collide with the
axis ticks and tick values, unless you are aware of where the axes are
positioned.
216 Chapter 5 / Key Concepts for Using Plots
217
6
Plot Statements
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
AXISTABLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
BANDPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
BARCHART Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
BARCHARTPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
BIHISTOGRAM3DPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
BLOCKPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
BOXPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
BOXPLOTPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
BUBBLEPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
CONTOURPLOTPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463
DENDROGRAM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
DENSITYPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
DROPLINE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 496
ELLIPSE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
ELLIPSEPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
FRINGEPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526
HEATMAP Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
HEATMAPPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
HIGHLOWPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
HISTOGRAM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 588
HISTOGRAMPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605
LINECHART Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 622
LINEPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646
LOESSPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659
MODELBAND Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673
MOSAICPLOTPARM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685
NEEDLEPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
PBSPLINEPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717
PIECHART Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
POLYGONPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748
REFERENCELINE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 778
REGRESSIONPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 793
SCATTERPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806
SCATTERPLOTMATRIX Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 850
SERIESPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 878
STEPPLOT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 925
218 Chapter 6 / Plot Statements
Dictionary
AXISTABLE Statement
Creates an event plot of input data along an axis of an X-Y plot.
Syntax
AXISTABLE X=column | expression VALUE=column </options>;
INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether missing class values are represented in the table.
INDENT=dimension
specifies a value to be used with the INDENTWEIGHT= option to
determine the indention for each text value in a Y-axis table.
INDENTWEIGHT=numeric-column | expression
specifies the indention weight (multiplier) for each observation in a Y-
axis table.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the table border.
POSITION=number
positions the plot along the axis orthogonal to the axis used for the
values.
SHOWMISSING=TRUE | FALSE
specifies whether missing values are represented in the table.
TEXTGROUP=discrete-attr-var
specifies the discrete attribute variable for a discrete attribute map that
maps text attributes to values for each observation.
VALUEATTRS=style-element | style-element(text-options) | (text-options)
specifies the color and font attributes of the text values.
VALUEFORMAT=format
specifies a SAS format or a user-defined format for the table values.
VALUEHALIGN=AUTO | LEFT | CENTER | RIGHT
in a Y-axis table, specifies the horizontal alignment of the column values
relative to the axis-table width.
VALUEJUSTIFY=AUTO | LEFT | CENTER | RIGHT
specifies the justification of the values in the axis table relative to the
axis-table width.
Axes options
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Header options
HEADERLABEL="string"
specifies the text for the table header.
HEADERLABELATTRS=style-element | style-element(text-options) | (text-
options)
specifies the color and font attributes of the table header.
Label options
LABEL="string"
specifies the text for the table label.
LABELATTRS=style-element | style-element(text-options) | (text-options)
specifies the color and font attributes of the column label.
220 Chapter 6 / Plot Statements
Midpoint options
CLASSDISPLAY=STACK | CLUSTER
specifies how the class values are displayed.
Statistics options
STAT=AUTO | SUM | MEAN
specifies the statistic that is to be computed for the VALUE= column
when the column is numeric.
Title options
TITLE="string"
specifies the text for the table title.
TITLEATTRS=style-element | style-element(text-options) | (text-options)
specifies the color and font attributes of the table title.
TITLEHALIGN=AUTO | CENTER | LEFT | RIGHT
specifies the horizontal alignment of the title bounding box of the axis
table, relative to the axis table width.
TITLEJUSTIFY=LEFT | CENTER | RIGHT
specifies the justification of the lines of a multiline title in the title
bounding box. The justification is relative to the axis table width.
Required Arguments
Either the X= or the Y= argument must be specified in the AXISTABLE statement.
Specifying X= places an axis table along the X axis of a plot. Specifying Y= places an axis
table along the Y axis of a plot.
X=column | expression
specifies the column for the X axis.
Y=column | expression
specifies the column for the Y axis.
VALUE=column
specifies the column that contains the axis table values.
AXISTABLE Statement 221
Optional Arguments
CLASS=column | expression
creates a separate row or column for each unique class value. Each row or
column is labeled by the class value.
Interaction The DISPLAY= option that is in effect must include LABEL for any
labels to appear.
Note If you specify a column in a SAS data set, the visual attributes for
each class value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each class value
are assigned in ascending order of the class column character values
or of unformatted numeric values.
Tip Use the LABELATTRS= option to modify the label text attributes.
CLASSDISPLAY=STACK | CLUSTER
specifies how the class values are displayed.
STACK
displays the class values vertically at each midpoint value on the X axis or
horizontally on the Y axis.
CLUSTER
displays the class values horizontally at each midpoint value on the X axis or
vertically on the Y axis.
Restriction CLUSTER applies only when the axis table is on a discrete axis.
Default STACK
Interaction The CLASS= option must be specified for this option to have any
effect.
Note When you plot a SAS data set, the items for each group value are
drawn in data order. When you plot a CAS in-memory table, they are
drawn in ascending order of the group column character values or
unformatted numeric values.
DATA
displays the class values in the order in which they occur in the data.
222 Chapter 6 / Plot Statements
REVERSEDATA
displays the class values in the reverse order from which they occur in the
data.
ASCENDING
DESCENDING
displays the class values in ascending or descending order.
Interaction The CLASS= option must be specified for this option to have any
effect.
Note In SAS 9.4M6 and earlier releases, when data stored in a CAS in-
memory table is used and DATA or REVERSEDATA is specified,
unpredictable results might occur. To generate consistent graphs in
that case, specify ASCENDING or DESCENDING. Starting with SAS
Viya 3.5 and SAS Studio 5.2, when data stored in a CAS in-memory
table is used and DATA or REVERSEDATA is specified, it is ignored,
and ASCENDING is used instead.
CLUSTERWIDTH=number
specifies the width of the group clusters as a fraction of the midpoint spacing or
bin width.
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
Requirement For this option to take effect, the CLASS= option must also be
specified, and the CLASSDISPLAY= option must be set to
CLUSTER.
discrete-attr-var
specifies a discrete attribute map variable.
Each unique value of this column is mapped to the Color attribute of the
GraphData1–GraphDataN style elements that are in effect. If a discrete attribute
variable is specified, the color mapping from its associated
DISCRETEATTRMAP statement is used.
Note If you specify a column in a SAS data set, colors are mapped to
group values in data order. If you specify a column in a CAS in-
memory table, colors are mapped to group values in ascending order
of the group column character values or unformatted numeric
values.
DATATRANSPARENCY=number
specifies the degree of the transparency of the header, label, and values.
Default 0
STANDARD
displays the table values and, if provided, the table label.
ALL
displays the same features as STANDARD.
(display-options)
specifies a space-separated list of display options, enclosed in parentheses.
LABEL
displays the table label.
The label can be the VALUE= column label or name, the LABEL= value, or
the CLASS= value for the table, depending on the options that you
specify.
VALUES
displays the column values.
Default STANDARD
224 Chapter 6 / Plot Statements
DROPONMISSING=TRUE | FALSE
specifies whether the entire axis table is dropped when all of the VALUE=
column values are missing.
Default FALSE
“boolean ” on page xii for other Boolean values that you can use.
GUTTER=dimension
specifies the gap between rows when a class variable is used.
X-axis table: 0 px
Interaction The CLASS= option must be specified for this option to have any
effect.
HEADERLABEL="string"
specifies the text for the table header.
Note: Starting with SAS 9.4M2, the HEADERLABEL= option is deprecated and
is replaced with the TITLE= option. The syntax and functionality are the same.
The HEADERLABEL= option is still honored, but the TITLE= option is preferred.
INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether missing class values are represented in the table.
Missing class values are included by default. When the data contains missing
class values, the label for those values is either blank for missing character
values or a dot for missing numeric values.
The following figure shows block plots for classes Class 1, Class 2, and any
missing class values.
The following figure shows an X-axis axis table that displays values for classes
Class 1, Class 2, and any missing class values.
Notice that the label for the missing class values is blank. You can use the
INCLUDEMISSINGCLASS=FALSE option to exclude the missing class values. If
you want to keep the missing class values, then you can create a format that
specifies a more meaningful label for the missing class. For example, here is a
format that specifies a label for missing character and numeric class values.
proc format;
value $missingClass " " = "(Missing)";
value missingClass . = "(Missing)";
run;
The following figure shows the previous example when format $missingClass is
applied to the class variable.
226 Chapter 6 / Plot Statements
Note: In SAS 9.4M2 and in earlier releases, ODS Graphics does not support
Unicode values in user-defined formats. Starting with SAS 9.4M3, ODS Graphics
supports Unicode values in user-defined formats only if they are preceded by
the (*ESC*) escape sequence. Example: "(*ESC*){unicode beta}". ODS
Graphics does not support an escape character that is defined in an ODS
ESCAPECHAR statement in user-defined formats.
Default TRUE
Interaction The CLASS= option must be specified for this option to have any
effect.
See “boolean ” on page xii for other Boolean values that you can use.
INDENT=dimension
specifies a value to be used with the INDENTWEIGHT= option to determine the
indention for each text value in a Y-axis table.
INDENTWEIGHT=numeric-column | expression
specifies the indention weight (multiplier) for each observation in a Y-axis table.
Interaction For each observation, the INDENT= option value is multiplied by the
value of the column specified by this option to determine the
indention for that observation’s value.
LABEL="string"
specifies the text for the table label.
AXISTABLE Statement 227
Default The class values are used when the CLASS= option is set and
CLASSDISPLAY=STACK is in effect. Otherwise, the VALUE= column
label or name is used.
Note If the length of the label exceeds the available space, the label is
split on blank space as needed to make it fit.
For grouped data, the label color changes to match the group color
derived from the ContrastColor attribute of the GraphData1–
GraphDataN style elements.
Restriction Group behavior occurs only when the CLASS= and COLORGROUP=
option values are the same.
Interaction If one or more text options are specified and they do not include all
the font properties such as color, family, size, weight, and style, then
the properties that are not specified are derived from the
GraphValueText style element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
The alignment is relative to the axis-table width. The axis table width is set by
the system to accommodate the maximum width of the values and, when
displayed, the label.
AUTO
uses the effective value of the LABELJUSTIFY= option.
LEFT
CENTER
RIGHT
horizontally justifies the label left, center, or right.
The following figure shows these positions for the axis-table label Size.
228 Chapter 6 / Plot Statements
Default AUTO
Interaction The DISPLAY= option must include LABEL for this option to have
any effect.
The justification is relative to the axis-table width. The axis table width is set by
the system to accommodate the maximum width of the values and, when
displayed, the label. The following figure shows the justifications LEFT,
CENTER, and RIGHT for axis-table label Nominal Size.
Default CENTER
Interaction The DISPLAY= option must include LABEL for this option to have
any effect.
LABELPOSITION=MIN | MAX
specifies the end of the axis on which the label is displayed. The label is aligned
with the tick values on the axis. The following figure shows the MIN and MAX
positions for Y axis and X-axis tables.
AXISTABLE Statement 229
Default MIN
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
PAD=dimension | (pad-options)
specifies the amount of extra space that is added inside the table border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the table border.
(pad-options)
specifies a space-separated list of one or more name-value-pair pad options,
enclosed in parentheses.
The list can contain one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
Default 4 px
RIGHT=dimension
specifies the amount of extra space added to the right side.
Default 4 px
230 Chapter 6 / Plot Statements
TOP=dimension
specifies the amount of extra space added to the top.
Default 0 px
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Default 0 px
Note Sides that are not assigned padding are padded with the default
amount of space.
POSITION=number
positions the plot along the axis orthogonal to the axis used for the values. This
option enables you to position the plot when the AXISTABLE statement is not
placed in an INNERMARGIN block.
number
specifies the position on the orthogonal axis as a fraction of the axis range.
When using the VALUEHALIGN option to align the values, in some cases, the
axis-table values might not align properly within the space allocated for the axis
table. For example, right-justifying the values might cause the values to overlap
other graphical elements. In that case, rather than allocating more space for the
axis table, you can use the POSITION= option to move the axis table to the left
along the X axis as shown in the following figure.
Tip To reserve space for the plot at either end of the orthogonal axis,
specify the OFFSETMIN= or OFFSETMAX= option for the
orthogonal axis.
SHOWMISSING=TRUE | FALSE
specifies whether missing values are represented in the table.
The values are evaluated before the column format is applied. When this option
is set to FALSE, missing numeric and character values are hidden.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
computes the SUM statistic when the VALUE= column is numeric.
When the column is character, it uses the first column value as the statistic
value.
SUM
MEAN
computes the SUM or MEAN statistic when the VALUE= column is numeric.
When the column is character, it uses the first column value as the statistic
value.
Default AUTO
Interaction When the VALUE= column is character, the STAT= option always
uses the first column value as the statistic value. In that case, SUM
and MEAN are ignored.
TEXTGROUP=discrete-attr-var
specifies the discrete attribute variable for a discrete attribute map that maps
text attributes to values for each observation. The discrete attribute variable is
defined in a DISCRETEATTRVAR statement.
TITLE="string"
specifies the text for the table title.
Tip Use the TITLEATTRS= option to control the appearance of the table
title.
Interaction If one or more text options are specified and they do not include all
the font properties such as color, family, size, weight, and style, then
the properties that are not specified are derived from the
GraphLabelText style element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element.
AUTO
aligns the title bounding box based on the table type:
n For a Y-axis table, aligns the title bounding box according to the effective
TITLEJUSTIFY= option value.
n For an X-axis table, aligns the title bounding box LEFT.
AXISTABLE Statement 233
CENTER
LEFT
RIGHT
horizontally aligns the table title bounding box center, left, or right.
Default AUTO
Restriction In SAS 9.4M2, this option applies only to Y-axis tables. Starting with
SAS 9.4M3, this option applies to Y-axis tables and to X-axis tables.
Interaction The TITLE= option must be specified for this option to have any
effect.
Default LEFT
The title must wrap to multiple lines for this option to have any
effect.
Interaction The TITLE= option must be specified for this option to have any
effect.
Interaction If one or more text options are specified and they do not include all
the font properties such as color, family, size, weight, and style, then
the properties that are not specified are derived from the
GraphLabelText style element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
VALUEFORMAT=format
specifies a SAS format or a user-defined format for the table values.
Default The format that is in effect for the column specified in the VALUE=
option. If no format is in effect, BEST6 is used for numeric columns.
Note Not all of the SAS formats are supported. See Appendix 4, “Format
Support in ODS Graphics,” on page 1621.
AUTO
uses the effective value of the VALUEJUSTIFY= option.
LEFT
CENTER
RIGHT
aligns the values left, center, or right relative to the axis-table width.
Default AUTO
Tip If the values do not align properly within the space allocated for the
axis table, use the POSITION= on page 230 option to move the axis
table along the X axis as needed.
AUTO
uses LEFT for text values or RIGHT for numeric values.
AXISTABLE Statement 235
CENTER
LEFT
RIGHT
horizontally aligns the table values center, left, or right, relative to the axis-
table width.
Default AUTO
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
The AXISTABLE statement enables you to place text values along the X or Y axis at
specific values on the axis. It offers more flexibility than the BLOCKPLOT
statement, which is used to denote changes in block values along the axis. The X
and Y data does not need to be sorted.
236 Chapter 6 / Plot Statements
An inner margin is created at the bottom of the layout container to reserve space
for the table. An AXISTABLE statement is used in the INNERMARGIN block to
show the average sales by division for each product. Here is the SAS code for this
example.
proc template;
define statgraph axistable;
begingraph;
entrytitle "Average Product Sales By Division and Country";
layout overlay / cycleattrs=true
yaxisopts=(offsetmax=0.15 label="Sales By Country");
innermargin / align=bottom opaque=true
backgroundcolor=cxf5f5f5;
axistable x=product value=actual /
name="division" stat=mean display=(label)
headerlabel="Sales By Division"
headerlabelattrs=GraphLabelText
valueattrs=(size=9pt weight=bold)
colorgroup=division class=division;
endinnermargin;
barchart category=product y=actual / name="country"
barlabel=true barlabelformat=dollar5.0
stat=mean group=country groupdisplay=cluster;
discretelegend "country" / title="Country:" location=inside
valign=top;
endlayout;
BANDPLOT Statement 237
endgraph;
end;
run;
See Also
“Creating an Axis-Aligned Inset with an Axis Table” in SAS Graph Template
Language: User’s Guide
BANDPLOT Statement
Creates a band plot that typically shows confidence or prediction limits.
Requirements: You must specify either an X= argument or a Y= argument. You cannot specify both.
When you specify the X argument, you must also specify LIMITLOWER and
LIMITUPPER arguments for Y values.
When you specify the Y argument, you must also specify LIMITLOWER and
LIMITUPPER arguments for X values.
The plot data should be sorted by the X or Y variable that is used in the BANDPLOT
statement. Otherwise, specify CONNECTORDER= AXIS in the BANDPLOT
statement.
Syntax
BANDPLOT X=column | expression
LIMITLOWER=number | numeric-column | expression
LIMITUPPER=number | numeric-column | expression < /options >;
Axes options
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the band labels relative to the plot area.
BANDPLOT Statement 239
CURVELABELLOWER="string" | column
specifies a label for the lower band limit.
CURVELABELPOSITION=AUTO | MAX | MIN | START | END
specifies the position of the band labels relative to the curve line.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the band labels at the specified split
characters.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the band labels can be split if
needed.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the band label text.
CURVELABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the band label
blocks.
CURVELABELUPPER="string" | column
specifies a label for the upper band limit.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a separate band plot for each unique group value of the specified
column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Required Arguments
You must specify either an X= or Y= argument. You cannot specify both. In addition, the
LIMITLOWER= and LIMITUPPER= arguments must be used to specify the lower and
upper lines for the band.
X=column | expression
specifies X values. Numeric or character values can be used.
Requirement You must also specify the LIMITLOWER= and the LIMITUPPER=
arguments for the Y values.
Y=column | expression
specifies Y values. Numeric or character values can be used.
240 Chapter 6 / Plot Statements
Requirement You must also specify the LIMITLOWER= and the LIMITUPPER=
arguments for the X values.
Interactions When this option is used with the X= option, it specifies the Y value
or values.
Interactions When this option is used with the X= option, it specifies the Y value
or values.
Optional Arguments
ANTIALIAS=AUTO | OFF
specifies whether anti-aliasing is turned off for this plot.
AUTO
specifies that anti-aliasing is controlled by the ANTIALIAS= option in the
ODS GRAPHICS statement.
OFF
specifies that anti-aliasing is always disabled for this plot.
Default AUTO
Interaction This option overrides the ANTIALIAS= option in the ODS GRAPHICS
statement.
CONNECTORDER=VALUES | AXIS
specifies how to connect the data points to form the band lines.
VALUES
connects data points in the order read from the X column (or Y column).
Note In SAS 9.4M6 and earlier releases, unexpected results might occur
when VALUES is specified and data stored in a CAS in-memory table
is used. In that case, use AXIS instead. Starting with SAS Viya 3.5 and
BANDPLOT Statement 241
SAS Studio 5.2, VALUES is ignored when data stored in a CAS in-
memory table is used.
AXIS
connects data points as they occur left-to-right along the X axis (or bottom-
to-top along the Y axis).
Tip You can use this value to ensure the expected connect order for certain
types of series lines (for example, time series) when the input data
might not be sorted by the X column (or Y column).
Note When you specify style-element, only the style attributes COLOR,
FONTFAMILY, FONTSIZE, FONTSTYLE, and FONTWEIGHT are used.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
CURVELABELLOWER="string" | column
specifies a label for the lower band limit.
For grouped data, use a column to define the lower band labels
for each group value. All of the labels for a specific group value
must be the same. Otherwise, the results are unpredictable.
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
CURVELABELUPPER="string" | column
specifies a label for the upper band limit.
For grouped data, use a column to define the upper band labels
for each group value. All of the labels for a specific group value
must be the same. Otherwise, the results are unpredictable.
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the band labels relative to the plot area.
INSIDE
locates the labels inside the plot area
OUTSIDE
locates the labels outside the plot area
Default INSIDE
AUTO
positions the band labels automatically near the band boundary along
unused axes whenever possible (typically Y2 and X2).
MAX
forces the band labels to appear near maximum band values (maximum X-
values for horizontal curves, and maximum Y-values for vertical curves).
MIN
forces the band label to appear near minimum band values (minimum X-
values for horizontal curves, and minimum Y-values for vertical curves)
START
forces band labels to appear near the beginning of the curve.
Tip This option is particularly useful when the curve line has a spiral
shape.
BANDPLOT Statement 243
END
forces band labels to appear near the end of the curve.
Tip This option is particularly useful when the curve line has a spiral
shape.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the band labels at the specified split characters.
When a band label is split, the label is split on each occurrence of the specified
split characters.
See “boolean ” on page xii for other Boolean values that you can use.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the band labels can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the band label. In that case, all of the specified split characters
together are treated as a single split character.
244 Chapter 6 / Plot Statements
"character-list"
one or more characters with no delimiter between each character and
enclosed in quotation marks.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the band label text.
TRUE
drops the split characters from the band label text.
FALSE
includes the split characters in the band label text.
The following figure shows an example of a band label with the following
specifications:
n CURVELABELPOSITION=MAX
n CURVELABEL="Product*Group*A"
n CURVELABELSPLIT=TRUE
BANDPLOT Statement 245
n CURVELABELSPLITCHARDROP=TRUE | FALSE
n CURVELABELSPLITCHAR="*"
Note: The horizontal line to the left of the label represents the maximum end of
the band for reference.
Default TRUE. The split characters are dropped from the band labels.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the CURVELABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The horizontal line to the left of each label represents the maximum end
of the band for reference.
246 Chapter 6 / Plot Statements
Default AUTO
DATATRANSPARENCY=number
specifies the degree of the transparency of the band fill and band outline.
Default 0
Note This option does not affect the band curve labels.
Tip The FILLATTRS= option can be used to set transparency for just the
band area. You can combine this option with FILLATTRS= to set one
transparency for the band outline but a different transparency for the
band fill. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
FILL
displays the band fill color
FILLPATTERN
displays the band fill pattern
Tip For this option to have any effect, the active ODS style must
specify a fill pattern or a fill pattern must be specified with the
FILLPATTERNATTRS= option.
OUTLINE
displays the band outline
STANDARD
specifies FILL only
BANDPLOT Statement 247
ALL
specifies all features: FILL, FILLPATTERN, and OUTLINE
EXTEND=TRUE | FALSE
specifies whether the constant or "step" band is to be drawn to the area
bounded by the axes.
Default FALSE
Requirement When this option is used for a constant band, constants must be
specified for the upper and lower band limits. This requirement
does not apply to "step" bands.
Interactions This option is ignored when band labels are placed inside the plot
area (CURVELABELLOCATION=INSIDE). To extend the bands in
that case, use the CURVELABELLOCATION=OUTSIDE option.
Tip If this option is not specified, then there can be a small gap
between the line and the axis. The gap is controlled by the axis
offset. If the axis offset is set to 0, then there is no gap.
See “boolean ” on page xii for other Boolean values that you can use.
Interaction For this option to have any effect, the fill must be enabled by the
ODS style or by the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
Interaction For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS styles
such as HTMLBlue that use color-priority attribute rotation, specify
ATTRPRIORITY=NONE in an ODS GRAPHICS statement or in the
BEGINGRAPH statement in your graph template. For more
information, see “Attribute Rotation Patterns” in SAS Graph
Template Language: User’s Guide.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
discrete-attr-var
specifies a discrete attribute map variable.
A distinct band is created for each group value by varying the visual attributes
of the band display features. The display features are controlled by the current
ODS style or by the DISPLAY= option. The default group appearance for each
display feature is shown in the following table.
Display
Feature1 Style Attributes That Control Default Group Appearance
Display
Feature1 Style Attributes That Control Default Group Appearance
1 The default display features are determined by the DisplayOpts attribute of the GraphBand
style element.
2 Fill patterns are valid for band plots starting with SAS 9.4M5.
Restrictions This option can be used only when a numeric column is specified
for the upper limit or the lower limit of the band plot. The other
limit could be a constant, if desired.
The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of colors and
line patterns.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
Tips The representations that are used to identify the groups can be
overridden individually. For example, each distinct group value is
represented by a different line pattern for the band lines, but the
PATTERN= suboption of the OUTLINEATTRS= option could be
used to assign the same line pattern to all band outlines.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping band attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
Default LEFT
Requirement TYPE= STEP must also be specified for this option to have any
effect.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
MODELNAME="plot-name"
specifies the name of the plot from which to derive the interpolation for the
band. When this option is used, the band plot forms prediction or confidence
limits for the plot that supplies the fitted model.
Requirement plot-name must be the name that has been assigned on the
associated plot’s NAME= option.
Tip If this option is not specified, then the interpolation is set by the
TYPE= option.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
Restriction Starting with SAS 9.4M5, the number of vertices for a patterned line
cannot exceed the maximum specified by the ODS GRAPHICS
statement option LINEPATTERNOBSMAX=. The default is 10,000. If
the limit is exceeded, the plot is not drawn and a note is written to
the SAS log stating that the limit has been exceeded. In that case,
increase LINEPATTERNOBSMAX= to the value suggested in the
note or change the line pattern to SOLID.
Interaction For this option to have any effect, the outline must be enabled by
the ODS style or by the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles X, Y, LIMITUPPER, LIMITLOWER, GROUP,
CURVELABELUPPER, and CURVELABELLOWER.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over the band
plot. If this option is used, then it replaces all of the information that is
displayed by default. Roles for columns that do not contribute to the band plot
can be specified along with roles that do.
(role-list)
an ordered, space-separated list of unique BANDPLOT and user-defined
roles. BANDPLOT roles include X , Y , LIMITUPPER , LIMITLOWER , GROUP ,
INDEX , CURVELABELUPPER , and CURVELABELLOWER .
Example This example displays data tips for the columns assigned to the
roles X, LIMITUPPER, and LIMITLOWER as well as the column
Obs, which is not assigned to any pre-defined BANDPLOT role. The
Obs column must first be assigned a role.
ROLENAME=(TIP1=OBS)
TIP=(TIP1 X LIMITUPPER LIMITLOWER)
NONE
suppresses data tips from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
254 Chapter 6 / Plot Statements
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TYPE=SERIES | STEP
specifies how the data points for lower and upper band boundaries are
interpolated.
SERIES
connects the data points using line segments (as in a SeriesPlot).
STEP
connects the data points (as in a StepPlot).
Default SERIES
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
BANDPLOT Statement 255
Details
A band plot can specify an X column with Y upper and lower limits, or a Y column
with X upper and lower limits. If you specify the X argument, then you must specify
LIMITLOWER and LIMITUPPER arguments for the Y values to apply the limits to
the Y axis. If you specify the Y argument, then you must specify LIMITLOWER and
LIMITUPPER arguments for the X values to apply the limits to the X axis.
You can use the BANDPLOT statement in displays that are independent of other
plots. For example, a band plot can be used to define yellow and green areas in an
OVERLAY LAYOUT statement that also contains a scatter plot. This use implies
concern for any of the scatter plot values that fall in the yellow area and comfort
for any values that fall in the green area. For this use, the upper and lower limits
would be specified by a constant.
Example Program
Here is the code for this example.
proc template;
define statgraph bandplot;
begingraph;
entrytitle "Fit Plot for Weight";
layout overlay;
bandplot x=height limitupper=uppermean
limitlower=lowermean /
name="band" modelname="fit"
legendlabel="95% Confidence Limits";
scatterplot x=height y=weight / primary=true;
seriesplot x=height y=predict / name="fit"
legendlabel="Fit Line";
discretelegend "fit" "band";
endlayout;
endgraph;
end;
run;
BARCHART Statement
Creates a bar chart computed from input data.
Tips: For charts that have a large number of bars that are very close together, slight
variations in spacing that normally occur due to integer rounding can become more
obvious. Subpixel rendering provides more precise bar spacing in that case. In SAS
9.4M2 and in earlier releases, specify SUBPIXEL=ON in the BEGINGRAPH
statement to enable subpixel rendering. See SUBPIXEL= on page 39. Starting with
SAS 9.4M3, subpixel rendering is enabled by default.
To disable subpixel rendering in SAS 9.4M3 and in later releases, specify
SUBPIXEL=OFF in the BEGINGRAPH statement or in an ODS GRAPHICS
statement. For information about the BEGINGRAPH statement SUBPIXEL= option,
see SUBPIXEL= on page 39. For information about the ODS GRAPHICS statement
SUBPIXEL= option, see “ODS GRAPHICS Statement” on page 1561.
Syntax
BARCHART CATEGORY=column | expression </option(s)>;
Axes options
BASELINEINTERCEPT=number
specifies the response axis intercept for the baseline.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
BARCHART Statement 259
Label options
BARLABEL=TRUE | FALSE
specifies whether the bar statistic value is displayed at the end of the
bar.
BARLABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the text properties of the bar label text.
BARLABELFITPOLICY=AUTO | NONE | INSIDEPREFERRED
specifies a policy for avoiding collisions among the bar labels when labels
are displayed.
BARLABELFORMAT=format
specifies the text format used to display the bar label.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
SEGMENTLABEL=TRUE | FALSE
specifies whether a label is displayed inside each bar segment.
SEGMENTLABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the text properties of the text for the bar segment label.
SEGMENTLABELFITPOLICY=NONE | NOCLIP | THIN
specifies a policy for fitting the bar segment labels within the bar
segments.
SEGMENTLABELFORMAT=format
specifies the text format for the bar segment labels.
Midpoint options
DISCRETEOFFSET=number
specifies an amount to offset all bars from the category midpoints.
GROUP=column | discrete-attr-var | expression
creates a separate bar segment or bar for each unique group value in the
specified column.
GROUP100=NONE | MAGNITUDE | POSITIVE
displays the computed response values (FREQ, SUM, or MEAN),
normalized to 100%.
GROUPDISPLAY=STACK | CLUSTER
specifies how to display grouped bars.
GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
specifies the ordering of the groups within a category.
INCLUDEMISSINGGROUP=TRUE | FALSE
260 Chapter 6 / Plot Statements
specifies whether missing values of the group variable are included in the
plot.
ODS options
URL=string-column
specifies an HTML page to display when the bar is selected.
Statistics options
COLORSTAT=FREQ | PCT | SUM | MEAN | PROPORTION
specifies the statistic to be calculated for the data range of the bar-color
gradient.
STAT=FREQ | PCT | SUM | MEAN | PROPORTION
specifies the statistic to be computed for the Y axis.
Required Arguments
Specifying only CATEGORY= creates a bar chart with bars that, by default, represent
frequency counts or percents of CATEGORY. Specifying both CATEGORY= and
RESPONSE= creates a bar chart with bars representing summarized values of RESPONSE
categorized by CATEGORY.
CATEGORY=column | expression
specifies the column or expression for the category values.
Notes You can use X= as an alternative to CATEGORY=. If you use X=, then be
aware that the TIP=, TIPFORMAT=, and TIPLABEL= options recognize X
as the category role and not as CATEGORY.
RESPONSE=numeric-column | expression
specifies the numeric column or expression for the response values.
Notes You can use Y= as an alternative to RESPONSE=. If you use Y=, then be
aware that the TIP=, TIPFORMAT=, and TIPLABEL= options will
recognize Y as the response role and not RESPONSE in that case.
Optional Arguments
BARLABEL=TRUE | FALSE
specifies whether the bar statistic value is displayed at the end of the bar. For
grouped clustered bars, each bar is labeled with the summarized value of the
BARCHART Statement 261
bar. For grouped stacked bars, the segmented bar is labeled with the
accumulated, summarized value of all the bar segments.
Default FALSE
Note By default, the bar-label format is derived from the format that is
assigned to the response column or from BEST6 if no format is
assigned. The derived format retains the precision of the response-
column format and, if necessary, increases the format width to
accommodate the summarized value on the response axis.
Tip The font and color attributes for the label are specified by the
BARLABELATTRS= option. The text format is specified by the
BARLABELFORMAT= option.
See “boolean ” on page xii for other Boolean values that you can use.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO
for a vertical bar chart, rotates the bar labels if the labels exceed the
midpoint spacing.
For a horizontal bar chart, always draws the labels horizontally. The
following figure shows an example.
262 Chapter 6 / Plot Statements
See the BARWIDTH= option for more information about the bar spacing.
NONE
does not rotate the bar labels.
INSIDEPREFERRED
attempts to place the bar labels in a horizontal bar chart inside the bars.
Note If any bar label cannot fit inside the length of its bar, that label
is placed outside of its bar and is fit using the AUTO fit policy.
Labels can collide along their length and along their height. In some cases, if one
or more labels collide when the specified fit policy is used, then all of the labels
are dropped from the display. When that occurs, the following warning message
is written to the SAS log:
WARNING: The bar labels are suppressed. Use BARLABELFITPOLICY=NONE to
force the labels to be displayed.
TIP If the labels collide along their height, then using the
BARLABELATTRS= option to reduce the label font size might eliminate
the collision.
Default AUTO
BARLABELFORMAT=format
specifies the text format used to display the bar label.
Default The bar-label format is derived from the format that is applied to
the response column or from BEST6 if no format is assigned. The
derived format retains the precision of the response-column
format and, if necessary, increases the format width to
accommodate the summarized value on the response axis.
Note When a bar-label format is specified with this option, the bar
labels are formatted as specified by format. The specified format is
not automatically expanded to accommodate values that are too
wide.
BARWIDTH=number
specifies the width of a bar as a ratio of the maximum possible width.
Default 0.85
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
BASELINEATTRS=style-element | (line-options)
specifies the appearance of the baseline.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
BASELINEINTERCEPT=number
specifies the response axis intercept for the baseline. Prior to SAS 9.4M5, the
baseline is always displayed in the chart, whether for a specified value or for the
default value. Starting with SAS 9.4M5, the baseline display is controlled by the
DISPLAYBASELINE= option, which is ON by default. When the
BASELINEINTERCEPT= option is used, the axis range is adjusted to include the
baseline, and the baseline is placed at the specified value on the response axis.
BARCHART Statement 265
Default 0
The baseline does not add a tick or a tick value to the axis. To label
the baseline, use a REFERENCELINE statement to overlay a line
with the same X or Y value and include the CURVELABEL= option
to specify the label text.
CLUSTERWIDTH=number
specifies the width of the group clusters as a fraction of the midpoint spacing or
bin width.
Default 0.85
266 Chapter 6 / Plot Statements
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
Requirement For this option to take effect, the GROUP= option must also be
specified, and the GROUPDISPLAY= option must be set to
CLUSTER.
COLORBYFREQ=TRUE | FALSE
specifies whether the bar colors are based on statistical values when the
COLORRESPONSE= option is not specified. Setting this option to TRUE enables
you to color the bars based on frequency counts, percentages, or proportions.
Default FALSE
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option or the
COLORBYFREQ= option.
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option or the
COLORBYFREQ=TRUE option must also be specified.
Tip Use the DISPLAY= option to specify whether outlines and fills are
displayed.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
When fill, fill pattern, or both are displayed, this option overrides
suboption COLOR= in the FILLATTRS= option and in the
FILLPATTERNATTRS= option and varies the color according to the
color gradient or the attribute map.
SUM
MEAN
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
CONNECTBREAK=TRUE | FALSE
specifies whether the connect line is broken for values that have no
observations.
Default FALSE
Requirement DISPLAY= must include CONNECT for this option to have any
effect.
Requirement For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
When a data skin is applied, all bar outlines are set by the skin, and
the OUTLINEATTRS= option is ignored.
DATATRANSPARENCY=number
specifies the degree of the transparency of the bar fill, bar outline, connect line,
and bar labels, if displayed.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
filled bar area. You can combine this option with FILLATTRS= to set
one transparency for the bar outlines and connect lines but a different
transparency for the bar fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
BARCHART Statement 271
DISCRETEOFFSET=number
specifies an amount to offset all bars from the category midpoints.
Default 0 (no offset, all bars are centered on the category midpoints)
Range -0.5 to +0.5, where 0.5 represents half the distance between category
ticks. Normally, a positive offset is to the right when
ORIENT=VERTICAL, and up when ORIENT=HORIZONTAL. (If the
layout's axis options set REVERSE=TRUE, then the offset direction is
also reversed.)
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete offset
can cause clipping at each end of the axis. In those cases, use the
OFFSETMIN= and OFFSETMAX= axis options to increase the axis
minimum and maximum offsets to accommodate the discrete offset.
ORIENT=
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
CONNECT
displays the connect lines, which are line segments that connect adjacent
midpoints at the end of each bar.
FILL
displays the bar fill color
FILLPATTERN
displays the bar fill pattern
Tip For this option to have any effect, the active ODS style must specify
a fill pattern or a fill pattern must be specified with the
FILLPATTERNATTRS= option.
OUTLINE
displays the bar outline
STANDARD
specifies FILL and OUTLINE
ALL
specifies all features: CONNECT, FILL, FILLPATTERN, and OUTLINE
Interaction Connect lines are not drawn when the GROUP= option is in effect.
Note The connect lines are drawn in axis order starting with SAS 9.4M3.
They are drawn in data order in prior releases.
You can specify both FILL and FILLPATTERN to combine solid fills
and pattern fills in the bars.
ON
always displays the baseline.
OFF
does not display the baseline.
AUTO
displays the baseline if the baseline intercept is within the response-axis
range, excluding the minimum and maximum axis values.
This is the typical case when the bar chart includes both positive and
negative bars, and the default baseline intercept of 0 is used. If the baseline
intercept is equal to the minimum or maximum value of the response-axis
range, the baseline is not displayed.
Default ON
DISPLAYZEROLENGTHBAR=TRUE | FALSE
specifies whether zero-length bars are drawn.
A zero-length bar is displayed as a line spanning the normal bar width at the
bar-chart baseline on the response axis. When this option is set to TRUE, zero-
length bars are displayed. Otherwise, they are suppressed. The following figure
shows a simple example of each outcome. In the figure, the plot wall outline,
category axis line, and bar-chart baseline are suppressed for clarity.
BARCHART Statement 273
Default TRUE
Note When this option is set to FALSE, the bar is not drawn, but other
elements associated with the bar such as the target bar, the error
bar, the bar label, and the data label, are drawn.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLENDCOLOR=color
specifies the end color of the color gradient for the bar fill.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
Restriction In SAS 9.4M4 and in earlier releases, the only styles that are
delivered by SAS that support fill patterns are JOURNAL2,
JOURNAL3, and MONOCHROMEPRINTER. If style-element is
specified and the active ODS style does not support fill patterns,
this option is ignored.
Interactions For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS
styles such as HTMLBlue that use color-priority attribute rotation,
specify ATTRPRIORITY=NONE in an ODS GRAPHICS statement or
in the BEGINGRAPH statement in your graph template. For more
information, see “Attribute Rotation Patterns” in SAS Graph
Template Language: User’s Guide.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
SOLID
fills each bar with the color that is assigned to that bar.
ALPHAGRADIENT
fills each bar with a color and a transparency gradient that starts at the bar
top with the initial transparency that is assigned to that bar, and ends with
full transparency at the bar baseline.
COLORGRADIENT
fills each bar with a color gradient that starts with the fill color that is
assigned to that bar and ends with the color that is specified in the
FILLENDCOLOR= option.
Alias GRADIENT
GRADIENT
fills each bar with a color and a transparency gradient that starts at the bar
top with the initial transparency that is assigned to that bar, and ends with
full transparency at the bar baseline.
Note: This option applies to SAS 9.4M2 through SAS 9.4M4. Starting with
SAS 9.4M5, ALPHAGRADIENT replaces GRADIENT, and GRADIENT is
changed to an alias of COLORGRADIENT.
Default SOLID
Interaction The DISPLAY= option must include FILL for this option to have any
effect.
Note The output for SAS programs written prior to SAS 9.4M5 that
specify FILLTYPE=GRADIENT might change starting with SAS
9.4M5. To restore the original appearance, specify
FILLTYPE=ALPHAGRADIENT.
discrete-attr-var
specifies a discrete attribute map variable.
The bar display depends on the setting for the GROUPDISPLAY= option. For
example, for a vertical bar chart with GROUPDISPLAY=STACK, bar segments
are stacked to form the bar. The height of each segment represents the
corresponding group value’s proportional contribution to the response value.
A distinct bar or bar segment is created for each group value by varying the
visual attributes of the bar display features. The display features are controlled
by the current ODS style or by the DISPLAY= option. The default group
appearance for each display feature is shown in the following table.
Display
Feature 1 Style Attributes That Control Default Group Appearance
Display
Feature 1 Style Attributes That Control Default Group Appearance
1 The default display features are determined by the DisplayOpts attribute of the GraphBar style
element.
By default, the group values are mapped in the order of the data.
Use the GROUPORDER= option to control the sorting order of the
grouped bar segments. Use the INDEX= option to alter the default
sequence of colors and line patterns.
Notes The bar display depends on the setting for the GROUPDISPLAY=
option.
If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
Tips The representations that are used to identify the groups can be
overridden individually. For example, each distinct group value is
represented by a different line pattern for the bar outlines, but you
can use the PATTERN= setting on the OUTLINEATTRS= option to
assign the same line pattern to all bar outlines and connect lines.
NONE
displays the summarized data.
MAGNITUDE
normalizes both the negative and positive values by magnitude to 100% of
the midpoint value, and displays the group values, preserving the sign.
The positive values are displayed above the bars for a vertical bar chart and
on the right end for a horizontal bar chart. The negative values are displayed
enclosed in parentheses below the bars for a vertical bar chart and on the
left end for a horizontal bar chart.
Notice that the group values for each midpoint value add up to 100%.
POSITIVE
drops the negative values and normalizes only the positive values to 100% of
the midpoint value.
Notice that the negative values are dropped from the chart and the group
values for each midpoint value add up to 100%.
Default NONE
Requirement The GROUP= option must be specified for this option to have any
effect.
Note You can use this option with any value for the GROUPDISPLAY=
option.
GROUPDISPLAY=STACK | CLUSTER
specifies how to display grouped bars.
STACK
displays group values as stacked segments within the category bar.
280 Chapter 6 / Plot Statements
CLUSTER
displays group values as separate adjacent bars that replace the single
category bar.
Each cluster of group values is centered at the category midpoint on the axis.
This example illustrates the clusters and also how groups are displayed
when they have an unequal number of unique values.
Default STACK
Interaction When you use the BARLABEL= option and the GROUP= option, the
BARLABEL values are displayed for each bar when
GROUPDISPLAY=CLUSTER. When GROUPDISPLAY=STACK, the
whole bar is labeled at the top.
Note When you plot a SAS data set, the items for each group value are
drawn in data order. When you plot a CAS in-memory table, they are
drawn in ascending order of the group column character values or
unformatted numeric values.
Tip For a linear response axis, when STAT=MEAN or STAT=PCT, the axis
tick values might be displayed as integer values when
GROUPDISPLAY=STACK. Changing GROUPDISPLAY= to CLUSTER
in that case might cause the axis values to change to decimal values.
BARCHART Statement 281
To keep the integer axis values in both cases, you can specify the
INTEGER=TRUE option for the response axis. See INTEGER= on
page 1085.
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Tip This option is useful when you want to reverse the category axis.
ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.
Interactions This option is ignored if the GROUP= option is not also specified.
By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.
Notes When plotting a SAS data set, attributes such as color, symbol, and
pattern are assigned to each group in DATA order by default. When
plotting a CAS in-memory table, attributes are assigned in
ascending order of the group column character values or
unformatted numeric values by default.
In SAS 9.4M6 and earlier releases, when data stored in a CAS in-
memory table is used and DATA or REVERSEDATA is specified,
unpredictable results might occur. To generate consistent graphs in
that case, specify ASCENDING or DESCENDING. Starting with SAS
Viya 3.5 and SAS Studio 5.2, when data stored in a CAS in-memory
table is used and DATA or REVERSEDATA is specified, it is ignored,
and ASCENDING is used instead.
282 Chapter 6 / Plot Statements
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping bar attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
INTERVALBARWIDTH=dimension
specifies the width of the bars in an interval bar chart as a ratio of the interval
width.
Restriction This option applies only to an interval category axis. When the
category axis is discrete, this option is ignored.
Interaction When the category data is interval, this option overrides the
BARWIDTH= option.
The bar width that you specify with this option is honored even if
the bars overlap. If the bars overlap, reduce the interval bar width or
use the BARWIDTH= option instead.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and the bars.
Default VERTICAL
Notes When this option is set to HORIZONTAL, the category variable appears
on the Y (or Y2) axis and the response variable appears on the X (or
X2) axis. To set the axis properties for this chart, you should use the
appropriate axis options of the layout container.
284 Chapter 6 / Plot Statements
If you change the orientation of the bar chart, then you should adjust
the layout container’s axis options appropriately.
For grouped data and filled bars, the ContrastColor attribute of the
GraphData1–GraphDataN style elements, and the LineThickness
and LineStyle attributes of the GraphOutlines style element.
For grouped data and unfilled bars, the ContrastColor and LineStyle
attributes of the GraphData1–GraphDataN style elements, and the
LineThickness attribute of the GraphOutlines style element.
Interactions For this option to have any effect, outlines must be enabled by the
ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
SEGMENTLABEL=TRUE | FALSE
specifies whether a label is displayed inside each bar segment.
When this value is set to FALSE, no labels are displayed inside the bars.
Default FALSE
Note By default, the segment-label format is derived from the format that is
assigned to the response column or from BEST6 if no format is
assigned. The derived format retains the precision of the response-
column format and, if necessary, increases the format width to
accommodate the summarized value on the response axis.
See “boolean ” on page xii for other Boolean values that you can use.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element.
NONE
no attempt is made to fit each segment label within its bar. Long bar
segment labels might overlap other graphical elements.
The segment labels are not considered when the axis ranges are computed.
As a result, segment labels that extend beyond the plot area are clipped.
NOCLIP
does not clip bar segment labels that extend beyond the plot area.
Labels that do not fit within the plot area extend into the graph axis area and
might overlap axis elements.
THIN
drops any bar segment label that does not fit within its segment.
For a vertical bar chart, the label width must not exceed the bar width, and
the text height must not exceed the segment height. For a horizontal bar
chart, the label text height must not exceed the bar width, and the label
length must not exceed the segment length.
Default THIN
SEGMENTLABELFORMAT=format
specifies the text format for the bar segment labels.
BARCHART Statement 287
Note: Prior to SAS 9.4, PCT displayed proportions between 0 and 1. To restore
the original PCT results in SAS 9.4 and later releases, specify PROPORTION
instead.
SUM
MEAN
Defaults For bar charts with no RESPONSE= column, the default is FREQ.
Note When this option is used with the GROUP=group option, the
specified statistic is computed for each subgroup value of each
group value. See “Example 2: Grouped Vertical Bar Chart” on page
295.
288 Chapter 6 / Plot Statements
TARGET=numeric-column | expression
specifies the target value for each bar. The visual representation is a triangle
with a line at the target value.
layout overlay;
barchart category=type response=mpg_highway / barwidth=.8
target=mpg_city group=origin groupdisplay=cluster
name='bar';
discretelegend 'bar';
endlayout;
layout overlay;
barchartparm category=type response=mpg_highway / barwidth=.8
target=mpg_city group=origin groupdisplay=cluster
name='bar';
discretelegend 'bar';
endlayout;
Interactions For this option to take effect, the RESPONSE= argument must also
be used.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a bar. If
this option is used, then the information specified replaces all of the information
that is displayed by default.
(role-list)
an ordered, space-separated list of unique BARCHART roles. BARCHART
roles include CATEGORY or X, RESPONSE or Y, COLORRESPONSE, INDEX,
GROUP, and TARGET.
Notes For the category and response roles, the TIP= option recognizes
only the category and response arguments that you use in the
BARCHART statement. If you use the CATEGORY= and
RESPONSE= arguments, then you must specify roles CATEGORY
and RESPONSE. Conversely, if you use the X= and Y= arguments,
then you must specify roles X and Y.
Example The following example displays data tips for the columns assigned
only to the roles CATEGORY and RESPONSE:
TIP=(CATEGORY RESPONSE)
NONE
suppresses data tips and URLs (if requested) from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement with the IMAGEMAP option specified,
and you must write the output to the ODS HTML destination.
Tip You can control the labels and formats for the TIP roles with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
290 Chapter 6 / Plot Statements
Example TIP=(RESPONSE)
TIPFORMAT=(RESPONSE=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example TIP=(RESPONSE)
TIPLABEL=(RESPONSE="Average Sales")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
URL=string-column
specifies an HTML page to display when the bar is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each bar that is to have an active link.
Example http://www.sas.com
Notes For non-grouped data, the values of the column are expected to be
same for each unique category value. If they are not, then the
results might be unpredictable.
For grouped data, the values of the column are expected to be the
same for each unique category and GROUP combination.
BARCHART Statement 291
Tips The URL value can be blank for some category values, meaning
that no action is taken when the bars for those category values are
selected.
The URL value can be the same for different category values,
meaning that the same action is taken when the bars for those
category values are selected.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
Statement Description
The BARCHART statement creates a bar chart with bars that represent
summarized response values. The response values are categorized by the unique
category values or, starting with SAS 9.4M3, by the bins in binned category data.
The BARCHART statement takes nonsummarized data as input and calculates the
appropriate summarization statistics (sum, mean, and so on) for each unique
category value or category bin. Prior to SAS 9.4M3, the category axis for a bar chart
must be discrete. Starting with SAS 9.4M3, the category axis can be discrete, linear,
or time. The response axis in all cases is interval.
When the chart is oriented vertically, the X (or X2) axis is used for CATEGORY and
the Y (or Y2) axis is used for RESPONSE. When it is oriented horizontally, the X (or
292 Chapter 6 / Plot Statements
X2) axis is used for RESPONSE and the Y (or Y2) axis is used for CATEGORY. (See
ORIENT= on page 283.)
By default, if the category column is character, then the bars in the chart appear in
the order in which the category values are present in the input data. If the category
column is numeric, then the values are presented in ascending order. For non-
grouped data, duplicated category values are summarized into a unique value. For
grouped data, the category values are summarized as needed. (See the GROUP=
option.)
Starting with SAS 9.4M3, for numeric category values, an interval bar chart is
generated only when the category axis type is linear or time. To specify a category
axis type of linear or time, include the TYPE= option in the category axis options, or
assign the role of primary plot to a plot that sets the category axis type to linear or
time automatically. By default, a bar is drawn for each unique category value, which
can result in a large number of bars for numeric category data.
When binning is used, for each bin, a summarization statistic is computed, and a bar
is drawn that represents that statistic. The width of each bar spans the width of the
bin that it represents. The left-most edge of the bar represents the start of the bin,
and the right-most edge represents the end. See “Example 1: Horizontal Bar Chart”
on page 294.
TIP Prior to SAS 9.4M3, use the HISTOGRAM statement to create a bar
chart that represents response values along an interval axis.
To place the different response values side by side, you can assign a different offset
to each BARCHART statement. The BARWIDTH= option can be used with
DISCRETEOFFSET= to create narrower bars that require less width within the plot
area:
layout overlay / cycleattrs=true
xaxisopts=(display=(tickvalues))
yaxisopts=(label="Revenue" offsetmax=0.2);
Examples
Example Program
proc template;
define statgraph barchart;
begingraph;
entrytitle "Average Mileage by Vehicle Type";
layout overlay;
barchart category=type response=mpg_highway /
stat=mean orient=horizontal;
endlayout;
endgraph;
end;
Example Program
proc template;
define statgraph barchart;
begingraph / attrpriority=none;
entrytitle "Percentage of Total Models by Type and Origin";
layout overlay;
barchart x=type / name="carmodels"
stat=pct display=all
group=origin groupdisplay=cluster group100=positive
barlabel=true;
discretelegend "carmodels";
endlayout;
endgraph;
end;
run;
Details
In the BARCHART statement, the STAT= option specifies the PCT statistic. The
GROUP= specifies grouping by variable Origin. The GROUP100= option specifies
normalization of the frequency statistic to 100% of the midpoint value. For each
midpoint, the sum of the percentages is 100%. The BARLABEL=TRUE option
enables the display of bar labels.
BARCHART Statement 297
Example Program
Here is the SAS code.
proc template;
define statgraph cylinders;
begingraph;
entrytitle "Interval Bar Chart of Vehicle Engine Cylinders";
layout overlay /
xaxisopts=(label="Engine Cylinders" type=linear
linearopts=(tickvaluelist=(3 4 5 6 8 10 12)))
yaxisopts=(label="Percentage of Vehicles Manufactured"
griddisplay=on linearopts=(tickvalueformat=percent7.1));
barchart category=cylinders / stat=proportion
barlabel=true barlabelformat=percent7.1;
endlayout;
endgraph;
end;
run;
Details
An interval bar chart can be generated only when the category axis type is LINEAR
or TIME. In this example, the TYPE=LINEAR option is included in the XAXISOPTS=
options. With numeric category data, a bar is drawn for each unique category value.
In some cases, that can generate too many bars in the resulting chart. In this
example, there are only seven unique values. The TICKVALUELIST= option is used
in the XAXISOPTS= option to display all of the values on the category axis.
Example Program
proc template;
define statgraph barchart;
begingraph;
entrytitle "Average Mileage by Vehicle Type";
layout overlay;
barchart category=type response=mpg_highway / name="bar"
stat=mean orient=horizontal
BARCHART Statement 299
colorbyfreq=true colorstat=pct;
continuouslegend "bar" /
title="Percent of Total Models Manufactured";
endlayout;
endgraph;
end;
run;
Example Program
proc template;
define statgraph barline;
begingraph;
entrytitle "Volume and Closing Price in 1H2001";
layout overlay /
xaxisopts=(label="Month"
timeopts=(tickvalueformat=monname3.))
yaxisopts=(label="Volume (Millions)" offsetmin=0
linearopts=(tickvaluesequence=(start=0 end=120
increment=20)
tickvaluepriority=true))
y2axisopts=(label="Close" offsetmin=0
300 Chapter 6 / Plot Statements
linearopts=(viewmin=50 viewmax=75));
barchart category=date response=eval(volume/1000000) /
name="bar"
legendlabel="Volume" datatransparency=0.6;
linechart category=date response=close /
legendlabel="Closing Price" vertexlabel=true
vertexlabelattrs=(color=darkblue weight=bold)
name="line" stat=sum yaxis=y2 display=(line markers)
markerattrs=(symbol=circlefilled color=darkblue)
lineattrs=(color=darkblue);
discretelegend "bar" "line";
endlayout;
endgraph;
end;
run;
BARCHARTPARM Statement
Creates a bar chart specified by pre-summarized data.
Requirement: The input data must be pre-summarized, with appropriate summarization statistics
(sum, mean, and so on) computed for the RESPONSE column.
Tips: For charts that have a large number of bars that are very close together, slight
variations in spacing that normally occur due to integer rounding can become more
obvious. Subpixel rendering provides more precise bar spacing in that case. In SAS
9.4M2 and in earlier releases, specify SUBPIXEL=ON in the BEGINGRAPH
statement to enable subpixel rendering. See SUBPIXEL= on page 39. Starting with
SAS 9.4M3, subpixel rendering is enabled by default.
To disable subpixel rendering in SAS 9.4M3 and in later releases, specify
SUBPIXEL=OFF in the BEGINGRAPH statement or in an ODS GRAPHICS
statement. For information about the BEGINGRAPH statement SUBPIXEL= option,
see SUBPIXEL= on page 39. For information about the ODS GRAPHICS statement
SUBPIXEL= option, see “ODS GRAPHICS Statement” on page 1561.
Syntax
BARCHARTPARM CATEGORY=column | expression
RESPONSE=numeric-column | expression </options>;
BARCHARTPARM Statement 301
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
FILLTYPE=SOLID | ALPHAGRADIENT | COLORGRADIENT | GRADIENT
specifies the bar fill type.
INDEX=positive-integer-column | expression
specifies indices for mapping bar attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.
INTERVALBARWIDTH=dimension
specifies the width of the bars in an interval bar chart as a ratio of the
interval width.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and the bars.
OUTLINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of the bar outlines.
TARGET=numeric-column | expression
specifies the target value for each bar.
Axes options
BASELINEINTERCEPT=number
specifies the response axis intercept for the baseline.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
DATALABEL=column | expression
specifies the label that appears at the end of each bar.
DATALABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the labels that are specified in
the DATALABEL= option.
BARCHARTPARM Statement 303
Midpoint options
DISCRETEOFFSET=number
specifies an amount to offset all bars from the category midpoints.
GROUP=column | discrete-attr-var | expression
creates a separate bar segment or bar for each unique group value in the
specified column.
GROUP100=NONE | MAGNITUDE | POSITIVE
displays the response values, normalized to 100%.
GROUPDISPLAY=STACK | CLUSTER
specifies how to display grouped bars.
GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
specifies the ordering of the groups within a category.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
ODS options
URL=string-column
specifies an HTML page to display when the bar is selected.
Required Arguments
CATEGORY=column | expression
specifies the column for the unique category values. All values are treated as
discrete.
Note You can use X= as an alternative to CATEGORY=. If you use X=, then be
aware that the TIP=, TIPFORMAT=, and TIPLABEL= options will
recognize X as the category role and not CATEGORY in that case.
RESPONSE=numeric-column | expression
specifies the column for the response values.
Note You can use Y= as an alternative to RESPONSE=. If you use Y=, then be
aware that the TIP=, TIPFORMAT=, and TIPLABEL= options will
recognize Y as the response role and not RESPONSE in that case.
Optional Arguments
BARWIDTH=number
specifies the width of a bar as a ratio of the maximum possible width.
Default 0.85
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
BASELINEATTRS=style-element | (line-options)
specifies the appearance of the baseline.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
BASELINEINTERCEPT=number
specifies the response axis intercept for the baseline. Prior to SAS 9.4M5, the
baseline is always displayed in the chart, whether for a specified value or for the
default value. Starting with SAS 9.4M5, the baseline display is controlled by the
DISPLAYBASELINE= option, which is ON by default. When the
BASELINEINTERCEPT= option is used, the axis range is adjusted to include the
baseline, and the baseline is placed at the specified value on the response axis.
Default 0
The baseline does not add a tick or a tick value to the axis. To label
the baseline, use a REFERENCELINE statement to overlay a line
with the same X or Y value and include the CURVELABEL= option
to specify the label text.
CLUSTERWIDTH=number
specifies the width of the group clusters as a fraction of the midpoint spacing or
bin width.
306 Chapter 6 / Plot Statements
Default 0.85
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
Requirement For this option to take effect, the GROUP= option must also be
specified, and the GROUPDISPLAY= option must be set to
CLUSTER.
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.
Tip Use the DISPLAY= option to specify whether outlines and fills are
displayed.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
When fill, fill pattern, or both are displayed, this option overrides
suboption COLOR= in the FILLATTRS= option and in the
FILLPATTERNATTRS= option and varies the color according to the
color gradient or the attribute map.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
CONNECTBREAK=TRUE | FALSE
specifies whether the connect line is broken for values that have no
observations.
Default FALSE
Requirement DISPLAY= must include CONNECT for this option to have any
effect.
DATALABEL=column | expression
specifies the label that appears at the end of each bar.
Restriction This option is ignored when one or both of the ERRORLOWER= and
ERRORUPPER= options are in effect.
When the GROUP= option is in effect, the data label values are
displayed only when GROUPDISPLAY=CLUSTER.
Interaction For this option to take effect, the DATALABEL= option must also be
used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO
selects a collision avoidance policy based on the chart orientation and data
type.
Tip If character labels do not fit after splitting, then try using ROTATE
instead of AUTO.
NONE
does not attempt to fit bar labels that collide.
ROTATE
rotates the bar labels for vertical bars if the labels collide in the available
width.
SPLIT
splits the label for vertical bars at a split character only if a split is needed at
that character in order to make the label fit the available space.
No split occurs at split characters that occur where a split is not needed. If
the label does not contain any of the specified split characters, then a split
does not occur. In that case, if the label does not fit the available space, then
it might collide with the adjoining labels.
SPLITALWAYS
splits the label for vertical bars at every occurrence of a split character.
If the label does not contain any of the specified split characters, then a split
does not occur.
INSIDEPREFERRED
attempts to place the data labels in a horizontal bar chart inside the bars.
Notes If any bar label does not fit inside its bar because the font
height is too high, all of the bar labels are placed outside.
If any bar label cannot fit inside the length of its bar, that label
is placed outside of its bar and is fit using the AUTO fit policy.
In some cases, if one or more labels collide when the specified fit policy is used,
then all of the labels are dropped from the display. When that occurs, the
following warning message is written to the SAS log:
WARNING: The bar labels are suppressed. Use DATALABELFITPOLICY=NONE to
force the labels to be displayed.
Default AUTO
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split. When
multiple split characters are specified, each character in the list is treated as a
separate split character unless the specified characters appear consecutively in
the data label. In that case, all of the specified split characters together are
treated as a single split character.
"character-list"
specifies one or more characters with no space between each character and
enclosed in quotation marks.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the displayed data labels.
TRUE
drops a split character from the display when a split occurs at that character.
Split characters at which a split does not occur are left in place. The
DATALABELFITPOLICY= option determines where the labels are split. When
BARCHARTPARM Statement 313
The following figure shows how label Product*Group*1 is split when the
DATALABELSPLITCHARDROP=TRUE and DATALABELSPLITCHAR="*"
options are specified with the SPLIT and SPLITALWAYS fit policies.
FALSE
includes the split characters in the data label display.
The following figure shows how label Product*Group*1 is split when the
DATALABELSPLITCHARDROP=FALSE and DATALABELSPLITCHAR="*"
options are specified with the SPLIT and SPLITALWAYS fit policies.
314 Chapter 6 / Plot Statements
See “boolean ” on page xii for other Boolean values that you can use.
DATALABELTYPE=AUTO | COLUMN
specifies whether the data labels display the RESPONSE values or the values of
the column that is specified by the DATALABEL= option.
AUTO
the system determines how the labels are displayed.
COLUMN
the data labels display the DATALABEL= column values.
BARCHARTPARM Statement 315
Default COLUMN
Requirement For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
When a data skin is applied, all bar outlines are set by the skin, and
the OUTLINEATTRS= option is ignored.
316 Chapter 6 / Plot Statements
DATATRANSPARENCY=number
specifies the degree of the transparency of the bar fill, bar outline, error bars,
connect line, and data labels, if displayed.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
bar fills. You can combine this option with FILLATTRS= to set one
transparency for the bar outlines, error bars, and connect lines but a
different transparency for the bar fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
DISCRETEOFFSET=number
specifies an amount to offset all bars from the category midpoints.
Default 0 (no offset, all bars are centered on the category midpoints)
Range -0.5 to +0.5, where 0.5 represents half the distance between category
ticks. Normally, a positive offset is to the right when
ORIENT=VERTICAL, and up when ORIENT=HORIZONTAL. (If the
layout's axis options set REVERSE=TRUE, then the offset direction is
also reversed.)
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete offset
can cause clipping at each end of the axis. In those cases, use the
OFFSETMIN= and OFFSETMAX= axis options to increase the axis
minimum and maximum offsets to accommodate the discrete offset.
ORIENT=
(display-options)
a space-separated list of one or more of the following options enclosed in
parentheses:
CONNECT
displays the connect lines, which are line segments that connect adjacent
midpoints at the end of each bar
FILL
displays the bar fill color
BARCHARTPARM Statement 317
FILLPATTERN
displays the bar fill pattern
Tip For this option to have any effect, the active ODS style must specify
a fill pattern or a fill pattern must be specified with the
FILLPATTERNATTRS= on page 321 option.
OUTLINE
displays the bar outline
STANDARD
specifies FILL and OUTLINE
ALL
specifies all features: CONNECT, FILL, FILLPATTERN, and OUTLINE
Interaction Connect lines are not drawn when the GROUP= option is in effect.
ON
always displays the baseline.
OFF
does not display the baseline.
AUTO
displays the baseline if the baseline intercept is within the response-axis
range, excluding the minimum and maximum axis values.
This is the typical case when the bar chart includes both positive and
negative bars, and the default baseline intercept of 0 is used. If the baseline
intercept is equal to the minimum or maximum value of the response-axis
range, the baseline is not displayed.
Default ON
DISPLAYZEROLENGTHBAR=TRUE | FALSE
specifies whether zero-length bars are drawn.
A zero-length bar is displayed as a line spanning the normal bar width at the
bar-chart baseline on the response axis. When this option is set to TRUE, zero-
length bars are displayed. Otherwise, they are suppressed. The following figure
shows a simple example of each outcome. In the figure, the plot wall outline,
category axis line, and bar-chart baseline are suppressed for clarity.
Default TRUE
Note When this option is set to FALSE, the bar is not drawn, but other
elements associated with the bar such as the target bar, the error
bar, the bar label, and the data label, are drawn.
Interaction For this option to take effect, error bars must be displayed by the
ERRORLOWER= , ERRORUPPER= options.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
ERRORBARCAPSCALE=positive-number
specifies a positive number to use as a multiplier for determining the default
width of the error-bar caps.
Default 1
ERRORBARCAPSHAPE=SERIF | NONE
specifies whether the error bars have a serif cap.
ERRORLOWER=numeric-column | expression
specifies the values of the lower endpoints on the Y error bars.
Requirement The error bar values must be absolute data values, not data values
relative to the value of the bar.
ERRORUPPER=numeric-column | expression
specifies the values of the upper endpoints on the Y error bars.
Requirement The error bar values must be absolute data values, not data values
relative to the value of the bar.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element .
FILLENDCOLOR=color
specifies the end color of the color gradient for the bar fill.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
Restriction In SAS 9.4M4 and in earlier releases, the only styles that are
delivered by SAS that support fill patterns are JOURNAL2,
JOURNAL3, and MONOCHROMEPRINTER. If style-element is
specified and the active ODS style does not support fill patterns,
this option is ignored.
Interactions For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS
styles such as HTMLBlue that use color-priority attribute rotation,
specify ATTRPRIORITY=NONE in an ODS GRAPHICS statement or
in the BEGINGRAPH statement in your graph template. For more
information, see “Attribute Rotation Patterns” in SAS Graph
Template Language: User’s Guide.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
SOLID
fills each bar with the color that is assigned to that bar.
ALPHAGRADIENT
fills each bar with a color and a transparency gradient that starts at the bar
top with the initial transparency that is assigned to that bar, and ends with
full transparency at the bar baseline.
COLORGRADIENT
fills each bar with a color gradient that starts with the fill color that is
assigned to that bar and ends with the color that is specified in the
FILLENDCOLOR= option.
Alias GRADIENT
GRADIENT
fills each bar with a color and a transparency gradient that starts at the bar
top with the initial transparency that is assigned to that bar, and ends with
full transparency at the bar baseline.
Note: This option applies to SAS 9.4M2 through SAS 9.4M4. Starting with
SAS 9.4M5, ALPHAGRADIENT replaces GRADIENT, and GRADIENT is
changed to an alias of COLORGRADIENT.
Default SOLID
Interaction The DISPLAY= option must include FILL for this option to have any
effect.
Note The output for SAS programs written prior to SAS 9.4M5 that
specify FILLTYPE=GRADIENT might change starting with SAS
9.4M5. To restore the original appearance, specify
FILLTYPE=ALPHAGRADIENT.
discrete-attr-var
specifies a discrete attribute map variable.
The bar display depends on the setting for the GROUPDISPLAY= option. For
example, for a vertical bar chart with GROUPDISPLAY=STACK, bar segments
are stacked to form the bar. The height of each segment represents the
corresponding group value’s proportional contribution to the response value.
A distinct bar or bar segment is created for each group value by varying the
visual attributes of the bar display features. The display features are controlled
by the current ODS style or by the DISPLAY= option. The default group
appearance for each display feature is shown in the following table.
Display
Feature1 Style Attributes That Control Default Group Appearance
Display
Feature1 Style Attributes That Control Default Group Appearance
ContrastColor attribute of a
GraphData1–GraphDataN style
element or the GraphMissing style
element with a solid line style
n if the outline is the only display
feature enabled, ContrastColor and
LineStyle attributes of a
GraphData1–GraphDataN style
element or the GraphMissing style
element
1 The default display features are determined by the DisplayOpts attribute of the GraphBar style
element.
By default, the group values are mapped in the order of the data.
Use the GROUPORDER= option to control the sorting order of the
group values.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
Tips The representations that are used to identify the groups can be
overridden individually. For example, each distinct group value is
represented by a different line pattern for the bar outlines, but you
could use the PATTERN= setting on the OUTLINEATTRS= option to
assign the same line pattern to all bar outlines and connect lines.
Use the INDEX= option to alter the default sequence of colors, fill
patterns, and line patterns.
NONE
displays the data as received.
MAGNITUDE
normalizes both the negative and positive values by magnitude to 100% of
the midpoint value, and displays the group values, preserving the sign.
The positive values are displayed above the bars for a vertical bar chart and
on the right end for a horizontal bar chart. The negative values are displayed
enclosed in parentheses below the bars for a vertical bar chart and on the
left end for a horizontal bar chart.
Notice that the group values for each midpoint value add up to 100%.
POSITIVE
drops the negative values and normalizes only the positive values to 100% of
the midpoint value.
Notice that the negative values are dropped from the chart and the group
values for each midpoint value add up to 100%.
Default NONE
Requirement The GROUP= option must be specified for this option to have any
effect.
Note You can use this option with any value for the GROUPDISPLAY=
option.
GROUPDISPLAY=STACK | CLUSTER
specifies how to display grouped bars.
STACK
displays group values as stacked segments within the category bar.
BARCHARTPARM Statement 327
CLUSTER
displays group values as separate adjacent bars that replace the single
category bar.
Each cluster of group values is centered at the category midpoint on the axis.
This example illustrates the clusters and also how groups are displayed
when they have an unequal number of unique values.
Default STACK
Interactions When you use the DATALABEL= option and the GROUP= option,
the DATALABEL values are displayed for each bar when
GROUPDISPLAY=CLUSTER. When GROUPDISPLAY=STACK, the
whole bar is labeled at the top.
When the TARGET= and GROUP= options are in effect, the target
values are not displayed when GROUPDISPLAY=STACK. In that
case, you must specify GROUPDISPLAY=CLUSTER to display the
target values.
Note When you plot a SAS data set, the items for each group value are
drawn in data order. When you plot a CAS in-memory table, they
328 Chapter 6 / Plot Statements
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Tip This option is useful when you want to reverse the category axis.
ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.
Interactions This option is ignored if the GROUP= option is not also specified.
By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.
Notes When plotting a SAS data set, attributes such as color, symbol, and
pattern are assigned to each group in DATA order by default. When
plotting a CAS in-memory table, attributes are assigned in
ascending order of the group column character values or
unformatted numeric values by default.
In SAS 9.4M6 and earlier releases, when data stored in a CAS in-
memory table is used and DATA or REVERSEDATA is specified,
unpredictable results might occur. To generate consistent graphs in
that case, specify ASCENDING or DESCENDING. Starting with SAS
Viya 3.5 and SAS Studio 5.2, when data stored in a CAS in-memory
table is used and DATA or REVERSEDATA is specified, it is ignored,
and ASCENDING is used instead.
BARCHARTPARM Statement 329
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping bar attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
INTERVALBARWIDTH=dimension
specifies the width of the bars in an interval bar chart as a ratio of the interval
width.
Restriction This option applies only to an interval category axis. When the
category axis is discrete, this option is ignored.
Interaction When the category data is interval, this option overrides the
BARWIDTH= option.
The bar width that you specify with this option is honored even if
the bars overlap. If the bars overlap, reduce the interval bar width or
use the BARWIDTH= option instead.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and the bars.
Default VERTICAL
Notes When this option is set to VERTICAL, the category variable appears on
the X (or X2) axis and the response variable appears on the Y (or Y2)
axis. To set the axis properties for this chart, you should use the
appropriate axis options of the layout container.
BARCHARTPARM Statement 331
If you change the orientation of the bar chart, then you should adjust
the layout container’s axis options appropriately.
For grouped data and filled bars, the ContrastColor attribute of the
GraphData1–GraphDataN style elements, and the LineThickness
and LineStyle attributes of the GraphOutlines style element.
For grouped data and unfilled bars, the ContrastColor and LineStyle
attributes of the GraphData1–GraphDataN style elements, and the
LineThickness attribute of the GraphOutlines style element.
Interactions For this option to have any effect, outlines must be enabled by the
ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles CATEGORY or X, RESPONSE or Y,
ERRORLOWER, ERRORUPPER, GROUP, and INDEX.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element.
NONE
no attempt is made to fit each segment label within its bar. Long bar
segment labels might overlap other graphical elements.
The segment labels are not considered when the axis ranges are computed.
As a result, segment labels that extend beyond the plot area are clipped.
NOCLIP
does not clip bar segment labels that extend beyond the plot area.
BARCHARTPARM Statement 333
Labels that do not fit within the plot area extend into the graph axis area and
might overlap axis elements.
THIN
drops any bar segment label that does not fit within its segment.
For a vertical bar chart, the label width must not exceed the bar width, and
the text height must not exceed the segment height. For a horizontal bar
chart, the label text height must not exceed the bar width, and the label
length must not exceed the segment length.
Default THIN
SEGMENTLABELFORMAT=format
specifies the text format for the bar segment labels.
SEGMENTLABELTYPE=NONE | AUTO
specifies whether a label is displayed inside each bar segment.
When this value is set to NONE, no labels are displayed inside the bars.
Default NONE
Note By default, the segment-label format is derived from the format that
is assigned to the response column or from BEST6 if no format is
assigned. The derived format retains the precision of the response
column format and, if necessary, increases the format width to
accommodate the column values.
See “boolean ” on page xii for other Boolean values that you can use.
TARGET=numeric-column | expression
specifies the target value for each bar.
layout overlay;
barchart category=type response=mpg_highway / barwidth=.8
target=mpg_city group=origin groupdisplay=cluster
name='bar';
discretelegend 'bar';
endlayout;
name='bar';
discretelegend 'bar';
endlayout;
Interactions For this option to take effect, the RESPONSE= argument must also
be used.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a bar. If
this option is used, then the information specified replaces all of the information
that is displayed by default. You can specify roles for columns that do not
contribute to the bar chart along with roles that do.
(role-list)
an ordered, space-separated list of unique BARCHARTPARM roles and user-
defined roles.
Notes For the category and response roles, the TIP= option recognizes only
the category and response arguments that you use in the
BARCHARTPARM statement. If you use the CATEGORY= and
RESPONSE= arguments, then you must specify roles CATEGORY and
RESPONSE. Conversely, if you use the X= and Y= arguments, then
you must specify roles X and Y.
NONE
suppresses data tips and URLs (if requested) from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement with the IMAGEMAP option specified,
and you must write the output to the ODS HTML destination.
Tip You can control the labels and formats for the TIP roles with the
TIPLABEL= and TIPFORMAT= options.
Example The following example displays data tips for the columns assigned
to the roles CATEGORY and RESPONSE as well as for the column
Pct. The Pct column is not assigned to any pre-defined bar chart
role, so it must first be assigned a role.
ROLENAME=(TIP1=PCT)
TIP=(TIP1 CATEGORY RESPONSE)
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
BARCHARTPARM Statement 337
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
URL=string-column
specifies an HTML page to display when the bar is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each bar that is to have an active link.
Example http://www.sas.com
For grouped data, the values of the column are expected to be the
same for each unique category and GROUP combination.
Tips The URL value can be blank for some category values, meaning
that no action is taken when the bars for those category values
are selected.
The URL value can be the same for different category values,
meaning that the same action is taken when the bars for those
category values are selected.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
338 Chapter 6 / Plot Statements
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
Statement Description
The input data for the BARCHARTPARM statement is expected to be pre-
summarized, with appropriate summarization statistics (sum, mean, and so on)
computed for the response column. When the category values are not unique, the
display is not meaningful. Prior to SAS 9.4M3, the category axis must be discrete.
Starting with SAS 9.4M3, the category axis can be discrete, linear, or time. The
response axis in all cases is interval.
When the chart is oriented vertically, the X (or X2) axis is used for category and the
Y (or Y2) axis is used for response. When the chart is oriented horizontally, the X
(or X2) axis is used for response and the Y (or Y2) axis is used for category. (See
ORIENT= on page 330.) If the chart is the primary chart, then any charts or plots
that are overlaid with it must have similar axis types.
By default, if the CATEGORY= column is character, then the bars in the chart
appear in the order in which the category values are present in the input data. If the
CATEGORY= column is numeric, then the values are presented in ascending order.
legendlabel="A" barwidth=0.8 ;
barchartparm category=year response=B_revenue / name="B"
legendlabel="B" barwidth=0.6 ;
barchartparm category=year response=C_revenue / name="C"
legendlabel="C" barwidth=0.4 ;
To place the different response values side by side, you can assign a different offset
to each BARCHARTPARM statement. The BARWIDTH= option can be used with
DISCRETEOFFSET= to create narrower bars that require less width within the plot
area:
layout overlay / cycleattrs=true
xaxisopts=(display=(tickvalues))
yaxisopts=(label="Revenue" offsetmax=0.2);
Example Program
proc template;
define statgraph barchartparm;
begingraph;
entrytitle "Average Mileage by Vehicle Type";
entryfootnote halign=left
"Error bars show +/- 1 Standard Error";
layout overlay;
barchartparm category=type response=mean /
errorlower=eval(mean-stderr)
errorupper=eval(mean+stderr) ;
endlayout;
endgraph;
end;
run;
BIHISTOGRAM3DPARM Statement
Creates a three-dimensional bivariate histogram of three variables X, Y, and Z, where the values of X
and Y have been gridded. The Z variable represents a response value for the frequency, percentage
counts, or densities of each bin combination.
Restriction: BIHISTOGRAM3DPARM does not support the data tips that are enabled by the
IMAGEMAP= option in the ODS GRAPHICS statement.
Requirements: The input data must be binned by both X and Y. That is, the values for X column
and Y column must form a complete rectangular grid of bins. Input data with non-
binned columns should be preprocessed with the KDE procedure (SAS/STAT),
which enables you to set the number of bins for X and Y, or with a technique similar
to that used in “Example: BIHISTOGRAM3DPARM Statement” on page 346.
The BIHISTOGRAM3DPARM statement must be specified within a LAYOUT
OVERLAY3D statement and cannot be nested under an OVERLAY,
OVERLAYEQUATED, or PROTOTYPE layout.
The input data for Z= column must be nonnegative.
Notes: In the plot display, the direction of the Z axis is upward rather than outward.
If the plot data is a CAS in-memory table, the data is sorted automatically by X and
Y before it is plotted.
See: The KDE Procedure in SAS/STAT User’s Guide
Syntax
BIHISTOGRAM3DPARM X=numeric-column | expression
Y=numeric-column | expression
Z=non-negative-numeric-column | expression </options>;
Axes options
BINAXIS=TRUE | FALSE
specifies whether to use bins as the basis for the axis tick marks.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
Label options
ENDLABELS=TRUE | FALSE
specifies whether the axis ticks and value labels are drawn at the bin
endpoints (TRUE) or at the bin midpoints (FALSE).
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Required Arguments
X=numeric-column | expression
specifies the bin location of the numeric X values.
Y=numeric-column | expression
specifies the bin location of the numeric Y values.
Z=nonnegative-numeric-column | expression
specifies the response values, such as the frequency counts, percentages, or
densities.
Optional Arguments
BINAXIS=TRUE | FALSE
specifies whether to use bins as the basis for the axis tick marks.
TRUE
specifies that the ENDLABELS= option determines how the axis ticks and
value labels are displayed.
FALSE
specifies that standard axes are used. Bin boundaries and midpoints that are
set by the ENDLABELS= option are ignored.
Default TRUE
344 Chapter 6 / Plot Statements
Interactions For this option to take effect, this plot must be the primary plot in
the parent OVERLAY3D layout. For more information, see the
PRIMARY= option.
When this option is set to TRUE, some X-axis options that are set
on the parent layout might not apply, such as INTEGER=,
TICKVALUELIST=, TICKVALUESEQUENCE=, and
INCLUDERANGES=.
“boolean ” on page xii for other Boolean values that you can use.
DATATRANSPARENCY=number
specifies the degree of the transparency of the bins.
Default 0
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
FILL
displays the bin fill color
OUTLINE
displays the bin outline
STANDARD
specifies FILL
ALL
specifies FILL and OUTLINE
Default STANDARD
ENDLABELS=TRUE | FALSE
specifies whether the axis ticks and value labels are drawn at the bin endpoints
(TRUE) or at the bin midpoints (FALSE).
Default FALSE.
Interactions This option is ignored if this plot is not the primary plot in the
parent layout. For more information, see the PRIMARY= option.
See “boolean ” on page xii for other Boolean values that you can use.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
Restriction This option uses only the color specification in the style element or
line options. The line pattern and line thickness specifications are
ignored.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
346 Chapter 6 / Plot Statements
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
Default MIDPOINTS
Default MIDPOINTS
Details
Because the BIHISTOGRAM3DPARM statement does not perform a binning
computation on the input columns, you must pre-bin the data. In addition, input
data for the statement must be binned by both X and Y. That is, the values for the X
column and the Y column must form a complete, rectangular grid of bins. Input data
with non-binned columns should be preprocessed with the KDE procedure
(SAS/STAT), which enables you to set the number of bins for X and Y. Alternatively,
the data can be preprocessed with a technique similar to the example, where a pre-
defined bin width is used.
The bounding cube can be titled, rotated, and zoomed to provide a different
viewpoint. By default, the outline of the bounding cube is displayed and the viewing
rotation angle is 57 degrees, the tilt angle is 20 degrees and the zoom factor is 1.
See the CUBE=, ROTATE=, TILT=, and ZOOM= options of the LAYOUT OVERLAY3D
statement for information about how to change the viewpoint.
The X axis, Y axis, and Z axis are linear by default. You can change axis properties
with the XAXISOPTS=, YAXISOPTS=, and ZAXISOPTS= options of the LAYOUT
OVERLAY3D statement.
Note: When BINAXIS=TRUE, some axis options for the X- and Y-axes might not
apply.
Example Program
proc template;
define statgraph bihistogram;
begingraph;
entrytitle "Distribution of Height and Weight";
entryfootnote halign=right "SASHELP.HEART";
layout overlay3d / cube=false zaxisopts=(griddisplay=on);
bihistogram3dparm x=height y=weight z=count / display=all;
endlayout;
endgraph;
end;
run;
data heart;
set sashelp.heart(keep=height weight);
if height ne . and weight ne .;
height=round(height,5);
weight=round(weight,25);
run;
BLOCKPLOT Statement
Creates one or more strips of rectangular blocks containing text values. The width of each block
corresponds to specified numeric intervals.
Syntax
BLOCKPLOT X=column | expression
BLOCK=column | expression </options>;
Axes options
BLOCKPLOT Statement 349
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
Label options
BLOCKLABEL=column | expression
specifies alternative text to display for the internal block text values.
LABEL="string"
specifies an external label for a single block plot.
LABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the external block label(s).
LABELPOSITION=LEFT | RIGHT | TOP | BOTTOM
specifies the alignment of BLOCK label.
Text options
VALUEATTRS=style-element | style-element (text-options) | (text-options)
specifies the appearance of the internal block text values or the
alternative values that are specified by the BLOCKLABEL= option.
VALUEFITPOLICY=NONE | SHRINK | SPLIT | SPLITALWAYS | TRUNCATE
specifies how text values are adjusted to fit within the containing block.
VALUEHALIGN=LEFT | CENTER | RIGHT | START
specifies the horizontal alignment of the value text within the blocks.
VALUESPLITCHAR="character-list"
specifies one or more characters on which the values can be split, if
needed.
VALUESPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the displayed
values.
VALUEVALIGN=TOP | CENTER | BOTTOM
specifies the vertical alignment of the value text within the blocks.
Required Arguments
X=column | expression
specifies numeric X-axis positions. If the X axis is discrete and the specified
column is numeric, values are treated as numeric-discrete. If the X axis is
interval and the specified X column is numeric, the following guidelines apply:
n If the data is a SAS data set, you must sort the data in ascending order by the
specified X column before you plot it.
n If the data is a CAS in-memory table, you do not need to sort the data. The
data is automatically sorted in ascending order by the X column before it is
plotted.
350 Chapter 6 / Plot Statements
BLOCK=column | expression
specifies a value for each X position. Numeric values are converted to text
strings according to an assigned format or according to BEST6.
Optional Arguments
ALTFILLATTRS=style-element | style-element (fill-options) | (fill-options)
specifies the appearance of alternate fills. This option in conjunction with the
FILLATTRS= option controls fill appearance when FILLTYPE=ALTERNATE.
Requirement FILLTYPE= ALTERNATE must set for this option to have any
effect.
Interaction For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
To make all block fill areas the same color, set the FILLATTRS=
and ALTFILLATTRS= options to the same value.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
BLOCKINDEX=positive-integer-column | expression
specifies indices for remapping the assignment of the color of the block fills.
Requirements FILLTYPE= MULTICOLOR must be set for this option to have any
effect.
All of the indices for a specific block value must be the same.
Otherwise, the results are unpredictable.
BLOCKPLOT Statement 351
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style element to use.
If this option is not used, then the color values are mapped in the
order of GraphData1–GraphDataN.
BLOCKLABEL=column | expression
specifies alternative text to display for the internal block text values.
Interaction The DISPLAY= option must include VALUES for the alternative text
to appear.
Note The text for each block segment must be the same. Otherwise, the
results are unpredictable.
The font and color attributes for the alternative text are specified by
the VALUEATTRS= option.
CLASS=column | expression
creates a separate block plot for each unique value of the specified column or
expression. Each block plot is labeled externally by the class value.
Interactions The DISPLAY= option must include LABEL for any external labels
to appear.
Note If you specify a column in a SAS data set, the visual attributes for
each class value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each class value
are assigned in ascending order of the class column character
values or of unformatted numeric values.
Tip The font and color attributes for the external labels are specified by
the LABELATTRS= option.
DATATRANSPARENCY=number
specifies the degree of the transparency of the block fill and outline.
Default 0
Notes This option does not affect the block values or labels.
Tip The ALTFILLATTRS= option can be used to set transparency for just
the alternate block fills. The FILLATTRS= option can be used to specify
transparency for the block fills. You can combine this option with
ALTFILLATTRS= and with FILLATTRS= to set one transparency for the
outlines but a different transparency for the block fills. Example:
datatransparency=0.2
altfillattrs=(transparency=0.6) fillattrs=(transparency=0.6)
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
FILL
displays the block fill color
LABEL
displays the external block label or labels
OUTLINE
displays the block outline
VALUES
displays internal block values or the alternative block values that are
specified by the BLOCKLABEL= option
STANDARD
specifies FILL and OUTLINE
ALL
specifies all features: FILL, LABEL, OUTLINE, and VALUES
Default STANDARD
EXTENDBLOCKONMISSING=TRUE | FALSE
specifies whether a missing value in the BLOCK column starts a new block or
reverts to the previous nonmissing value.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Requirement FILLTYPE= ALTERNATE must set for this option to have any
effect.
Interaction For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
To make all block fill areas the same color, set the FILLATTRS=
and ALTFILLATTRS= options to the same value.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLTYPE=MULTICOLOR | ALTERNATE
specifies how the blocks are filled.
MULTICOLOR
fills the blocks with the color specified by the Color attribute of the style
elements GraphData1–GraphDataN and GraphMissing (for missing BLOCK=
values), or the style elements indicated by the BLOCKINDEX= column.
ALTERNATE
alternates the block fill between the colors specified by the FILLATTRS= and
ALTFILLATTRS= options.
354 Chapter 6 / Plot Statements
Default MULTICOLOR
Interactions For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
When this option is set to ALTERNATE, the block plot does not
support a DISCRETELEGEND entry.
INCLUDEMISSINGCLASS=TRUE | FALSE
specifies whether missing values in the class column are included in the plot.
Missing class values are included by default. When the data contains missing
class values, the label for those values is either blank for missing character
values or a dot for missing numeric values.
The following figure shows block plots for classes Class 1, Class 2, and any
missing class values.
The following figure shows an X-axis axis table that displays values for classes
Class 1, Class 2, and any missing class values.
Notice that the label for the missing class values is blank. You can use the
INCLUDEMISSINGCLASS=FALSE option to exclude the missing class values. If
you want to keep the missing class values, then you can create a format that
specifies a more meaningful label for the missing class. For example, here is a
format that specifies a label for missing character and numeric class values.
proc format;
value $missingClass " " = "(Missing)";
value missingClass . = "(Missing)";
run;
The following figure shows the previous example when format $missingClass is
applied to the class variable.
BLOCKPLOT Statement 355
Note: In SAS 9.4M2 and in earlier releases, ODS Graphics does not support
Unicode values in user-defined formats. Starting with SAS 9.4M3, ODS Graphics
supports Unicode values in user-defined formats only if they are preceded by
the (*ESC*) escape sequence. Example: "(*ESC*){unicode beta}". ODS
Graphics does not support an escape character that is defined in an ODS
ESCAPECHAR statement in user-defined formats.
Default TRUE
Interaction The CLASS= option must be specified for this option to have any
effect.
See “boolean ” on page xii for other Boolean values that you can use.
LABEL="string"
specifies an external label for a single block plot.
The DISPLAY= option must include LABEL for any external label(s)
to appear.
Tip The font and color attributes for the external label are specified by
the LABELATTRS= option.
Interaction If one or more text options are specified and they do not include all
of the font properties such as color, family, size, weight, style, then
the non-specified properties are derived from the GraphLabelText
style element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
LEFT
places the label to the left of the strip of block values.
RIGHT
places the label to the right of the strip of block values.
TOP
places the label above the strip of block values.
BOTTOM
places the label below the strip of block values.
Default LEFT
NAME="string"
assigns a name to this plot statement for reference in other template
statements. This option is used mostly in the DISCRETELEGEND statement in
order to coordinate the use of colors and line patterns between the plot and the
legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interactions For this option to have any effect, the outlines must be enabled by
the ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
REPEATEDVALUES=TRUE | FALSE
specifies whether contiguous block values that are identical create separate
blocks.
FALSE
creates only one block when two or more identical block values appear
consecutively.
TRUE
creates one block for each identical value when two or more identical values
appear consecutively.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
BLOCKPLOT Statement 357
Interaction If one or more text options are specified and they do not include all
of the font properties such as color, family, size, weight, style, then
the non-specified properties are derived from the GraphValueText
style element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
NONE
makes no attempt to fit values that collide.
SHRINK
reduces the font size of the values until they all fit.
SPLIT
splits a value that does not fit within the containing block at a split character
in order to make the value fit the available space.
No split occurs at split characters that occur where a split is not needed. If
the value does not contain any of the specified split characters, then a split
does not occur.
SPLITALWAYS
splits each value at every occurrence of a split character.
If the value does not contain any of the specified split characters, then a
split does not occur.
TRUNCATE
truncates any value that does not fit.
For a numeric column, an asterisk (*) is substituted for the entire value
whenever truncation occurs. For a character column, the truncated portion
of the text is replaced by an ellipsis (...).
Default TRUNCATE
358 Chapter 6 / Plot Statements
Interaction The SPLIT and SPLITALWAYS policies are ignored when the
BLOCKPLOT statement is placed in a DATALATTICE or DATAPANEL
layout and the BLOCKPLOT CLASS= option is set. In that case, the
TRUNCATE fit policy is used instead.
LEFT
left-aligned within the block
CENTER
center-aligned within the block
RIGHT
right-aligned within the block
START
center-aligned at the starting value of the block
Default LEFT
Requirement For this option to have any effect, the DISPLAY= option must
include VALUE.
VALUESPLITCHAR="character-list"
specifies one or more characters on which the values can be split, if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the value. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no delimiter between each character and
enclosed in quotation marks.
VALUESPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the displayed values.
TRUE
drops a split character from the value when a split occurs at that character.
Split characters at which a split does not occur are left in place. The
VALUEFITPOLICY= option determines where the values are split. When
VALUEFITPOLICY=SPLIT, each value is split at a split character only where
a split is needed in order to make the value fit the available space. At each
split point, the split character is dropped, and the characters that follow the
split character, up to but not including the split character at the next split
point, are wrapped to the following line.
The following figure shows how value Product*Group*1 is split when the
VALUESPLITCHARDROP=TRUE, VALUESPLITCHAR="*", and
VALUEHALIGN=CENTER options are specified with the SPLIT and
SPLITALWAYS fit policies.
FALSE
includes the split characters in the value display.
The following figure shows how value Product*Group*1 is split when the
VALUESPLITCHARDROP=FALSE, VALUESPLITCHAR="*", and
VALUEHALIGN=CENTER options are specified with the SPLIT and
SPLITALWAYS fit policies.
Default TRUE. A split character is dropped from the value display when a
split occurs at that character.
See “boolean ” on page xii for other Boolean values that you can use.
Default CENTER
Interaction For this option to have any effect, the DISPLAY= option must
include VALUE.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
A block plot contains information about X locations and text values to be
associated with corresponding intervals along the X axis. There is no Y-axis
information in this plot.
Examples
Example Output
Input Data
To prepare input data for the graph, “event” information must be added to the
existing data for stock prices. Here is the SAS code that generates the data for this
example. Notice that the first DATA step creates a Release column. That column is
later specified on the BLOCK= argument to display text values on the wall of the
block plot.
data MSevents;
input Date date9. Release $5.;
label Release="Windows Release";
datalines;
01jun1990 3.0
01sep1995 95
01jul1998 98
01mar2000 2000
01nov2001 XP
;
data events;
BLOCKPLOT Statement 363
In the merged input data set, the Release column value is missing for each
observation until the first event defined in the MSEvents data, 3.0, occurs in June of
1990. The Release column value is missing again for the subsequent observations
until the next event defined in the MSEvents data, 95, occurs in September of 1995.
Here is a sample of the merged data.
Obs Stock Date Close Release
...
45 Microsoft 02APR90 $58.00
46 Microsoft 01MAY90 $73.00
47 Microsoft 01JUN90 $76.00 3.0
48 Microsoft 02JUL90 $66.50
49 Microsoft 01AUG90 $61.50
50 Microsoft 04SEP90 $63.00
...
Example Program
Here is the code for this example.
proc template;
define statgraph blockplot1;
begingraph;
entrytitle "Microsoft Share Prices";
entrytitle "and Significant OS Releases";
layout overlay;
blockplot x=date block=release /
datatransparency=0.3 valuevalign=top
labelposition=top display=(fill values label)
extendblockonmissing=true ;
seriesplot x=date y=close;
endlayout;
endgraph;
end;
run;
Details
In the GTL template code for this example, BLOCK=RELEASE is specified in the
BLOCKPLOT statement so that the RELEASE values are displayed on the wall of
the resulting block plot. In this template, the BLOCKPLOT statement sets
364 Chapter 6 / Plot Statements
Example Output
Example Program
In this example, the lattice ROWWEIGHTS=(0.04 0.96) option apportions 4% of the
vertical space to the block plot. Here is the code for this example.
proc template;
BOXPLOT Statement 365
BOXPLOT Statement
Creates box plots that are computed from input data.
Tip: Starting with SAS 9.4M3, you can use subpixel rendering with this statement. It is
enabled by default. To disable subpixel rendering, specify SUBPIXEL=OFF in the
BEGINGRAPH statement or in an ODS GRAPHICS statement. For information
about the BEGINGRAPH statement SUBPIXEL= option, see SUBPIXEL= on page 39.
For information about the ODS GRAPHICS statement SUBPIXEL= option, see “ODS
GRAPHICS Statement” on page 1561.
Syntax
BOXPLOT Y=numeric-column | expression < /options >;
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
DATALABEL=column
specifies the labels of the outliers. Either a numeric or a character column
can be used.
DATALABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the outlier labels.
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if
needed.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
DATALABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the data label
blocks.
LABELFAR=TRUE | FALSE
specifies whether all outliers or only far outliers are labeled.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
DISCRETEOFFSET=number
368 Chapter 6 / Plot Statements
Statistics options
DISPLAYSTATS=NONE | STANDARD | ALL | (statistics-list)
specifies the statistics to be displayed for each box.
FREQ=numeric-column | expression
specifies a numeric column that provides frequencies for each
observation that is read.
PERCENTILE=1 | 2 | 3 | 4 | 5
specifies one of five definitions used to calculate percentiles.
WEIGHT=numeric-column | expression
specifies a column that contains a statistics calculation a priori weight for
each observation of the input data object.
WHISKERPERCENTILE=number
specifies the whisker length, in percentile units.
Required Arguments
Specifying only Y= creates a single box plot. Specifying both X= and Y= creates a box plot
for each unique value of X.
Y=numeric-column | expression
specifies the column for the Y values. This argument is required.
X=column | expression
specifies the column for the X values. This argument is required if you want to
create a box plot for each unique X value.
Optional Arguments
BOXWIDTH=number
specifies the width of a box as a ratio of the maximum possible width.
BOXPLOT Statement 369
Defaults For a discrete category axis, 0.4 for a nongrouped box plot or 0.6
for a grouped box plot.
Interactions For a grouped box plot with a discrete category axis when
GROUPDISPLAY=CLUSTER, the box width is a percentage of the
cluster width. See CLUSTERWIDTH.
Prior to SAS 9.4M3, for an interval box plot, this option is ignored,
and the box width is controlled by the INTERVALBOXWIDTH=
option. Starting with SAS 9.4M3, for an interval box plot, this option
is ignored when the INTERVALBOXWIDTH= option is specified.
Otherwise, the BOXWIDTH= option is honored.
CAPSCALE=positive-number
specifies a positive number to use as a multiplier for determining the default
width of the whisker caps.
Default 1
SERIF
specifies a short line perpendicular to the whisker.
LINE
specifies a line perpendicular to the whisker that extends the width of the
box.
BRACKET
specifies a line perpendicular to the whiskers that extends the width of the
box and that has short extensions at each end.
NONE
specifies that no shape appears at the ends of the whiskers.
Default SERIF
Interactions The cap color and the thickness are specified by the
WHISKERATTRS= option. The cap pattern is always solid.
The DISPLAY= option must include CAPS in order for cap lines to
be shown.
CLUSTERWIDTH=number
specifies the width of the group clusters as a fraction of the midpoint spacing or
bin width.
Default 0.7
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
BOXPLOT Statement 371
Requirement For this option to take effect, the GROUP= option must also be
specified, and the GROUPDISPLAY= option must be set to
CLUSTER.
Note When the X axis is an interval axis, the cluster width is a fraction
of the smallest data interval.
Interaction This option applies only when the X= argument is used to generate
multiple boxes.
Note Starting with SAS 9.4M3, the connect lines are drawn in axis order.
In prior releases, they are drawn in data order.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CONNECTBREAK=TRUE | FALSE
specifies whether the connect line is broken for values that have no
observations.
Default FALSE
Requirement DISPLAY= must include CONNECT for this option to have any
effect.
DATALABEL=column
specifies the labels of the outliers. Either a numeric or a character column can
be used.
If one or more label options are specified and they do not include
all the font properties (color, family, size, weight, style), then the
non-specified properties are derived from the GraphDataText style
element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters. When
set to TRUE, the data label is split unconditionally at each occurrence of any of
the specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the data label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
TRUE
drops the split characters from the data label.
FALSE
includes the split characters in the data label.
The following figure shows an example of a data label with the following
specifications:
n the data label text for this label is Product*Group*A
n DATALABELSPLIT=TRUE
n DATALABELSPLITCHARDROP=TRUE | FALSE
n DATALABELSPLITCHAR="*"
Default TRUE. The split characters are dropped from the data label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the DATALABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The gray vertical line at the bottom of each label represents the
horizontal center of the text box for reference.
Default AUTO
Requirement For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
When a data skin is applied, all bar outlines are set by the skin, and
the OUTLINEATTRS= option is ignored.
DATATRANSPARENCY=number
specifies the degree of the transparency of the box outlines, box fill, whiskers,
mean, median, caps, connect lines, outliers, and data labels, if displayed.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
interior fill area of the boxes. You can combine this option with
376 Chapter 6 / Plot Statements
FILLATTRS= to set one transparency for the box outlines and the
whiskers, mean, median, caps, and connect lines, but a different
transparency for the box fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
DISCRETEOFFSET=number
specifies an amount to offset all boxes from the discrete X ticks.
Default 0 (no offset, all boxes are centered on the discrete ticks)
Range -0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. A positive offset is to the right when
ORIENT=VERTICAL, and up when ORIENT=HORIZONTAL. (If the
layout's axis options set REVERSE=TRUE, then the offset direction
is also reversed.)
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
CAPS
displays caps at the ends of the whiskers.
CONNECT
displays the line connecting multiple boxes.
FILL
displays the box fill color.
FILLPATTERN
displays the box fill pattern.
Tip By default, this option has no effect if the active ODS style does
not specify a fill pattern. To display a fill pattern in that case,
select an ODS style that supports fill patterns or use the
FILLPATTERNATTRS= option to specify a fill pattern for the
boxes.
BOXPLOT Statement 377
MEAN
displays the mean symbol within the box.
MEDIAN
displays the median line within the box.
NOTCHES
displays notched boxes.
OUTLIERS
displays markers for the outliers.
STANDARD
specifies CAPS, FILL, MEAN, MEDIAN, and OUTLIERS.
ALL
specifies all features: CAPS, CONNECT, FILL, FILLPATTERN, MEAN,
MEDIAN, NOTCHES, and OUTLIERS.
Notes Starting with SAS 9.4M3, connect lines are drawn in axis order. They
are drawn in data order in prior releases.
NONE
does not display any statistics.
STANDARD
displays N, MEAN, and STD.
ALL
displays all available statistics.
378 Chapter 6 / Plot Statements
(statistics-list)
specifies a space-separated list of one or more statistics, enclosed in
parentheses.
DATAMAX
maximum data value that includes not only the maximum whisker values
but also the maximum outlier values.
This option is valid in SAS 9.4M1 and later releases. The DATAMAX value
is greater than or equal to the MAX value and is always represented in
the axis range.
DATAMIN
minimum data value that includes not only the minimum whisker values
but also the minimum outlier values.
This option is valid in SAS 9.4M1 and later releases. The DATAMIN value
is less than or equal to the MIN value and is always represented in the
axis range.
IQR
interquartile range (Q3–Q1).
MAX
maximum data value below the box upper fence.
MEAN
mean data value for the box.
MEDIAN
median data value for the box.
MIN
minimum data value above the box lower fence.
N
number of observations for the box.
Q1
lower quartile (25th percentile) for the box.
Q3
upper quartile (75th percentile) for the box.
RANGE
range of the data (MAX–MIN).
STD
standard deviation of the data for the box.
SUMWGT
sum of the weights for the box.
Default NONE
BOXPLOT Statement 379
Note The notches in the box plot can extend beyond DATAMIN and
DATAMAX in some cases.
EXTREME=TRUE | FALSE
specifies whether the whiskers can extend beyond the fences. Fences are
locations above and below the box. The upper and lower fences are located at a
distance 1.5 times the Interquartile Range (IQR) (IQR = Q3 - Q1). The upper and
lower far fences are located at a distance 3 times the IQR .
FALSE
specifies that whiskers be drawn from the upper edge of the box to the
largest value within the upper fence, and from the lower edge of the box to
the smallest value within the lower fence.
TRUE
specifies that whiskers be drawn to the largest and smallest data values,
whether these values are inside or outside the fences.
The outliers and far outliers are not displayed and are not labeled. This
representation is sometime called a skeletal box and whisker plot.
Default FALSE
“boolean ” on page xii for other Boolean values that you can use.
Interaction For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
Tip The DATATRANSPARENCY option sets the transparency for the box
outlines, box fill, whiskers, mean, median, caps, connect lines, and
outliers. You can combine this option with DATATRANSPARENCY=
to set one transparency for the box outlines and the whiskers, mean,
median, caps, and connect lines, but a different transparency for the
box fills. Example:
380 Chapter 6 / Plot Statements
datatransparency=0.2 fillattrs=(transparency=0.6)
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
Interaction For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS styles
such as HTMLBlue that use color-priority attribute rotation, specify
ATTRPRIORITY=NONE in an ODS GRAPHICS statement or in the
BEGINGRAPH statement in your graph template. For more
information, see “Attribute Rotation Patterns” in SAS Graph
Template Language: User’s Guide.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FREQ=numeric-column | expression
specifies a numeric column that provides frequencies for each observation that
is read.
Note If n is the value of the numeric column for a given observation, then
that observation is used n times for the purposes of any statistical
computation. The marker for that observation is drawn n times,
which increases the marker weight slightly with frequency.
discrete-attr-var
specifies a discrete attribute map variable.
BOXPLOT Statement 381
A distinct box is created for each group value by varying the visual attributes of
the box display features. The display features are controlled by the current ODS
style or by the DISPLAY= option. The default group appearance for each display
feature is shown in the following table.
Display
Feature 1 Style Attributes That Control Default Group Appearance
1 The default display features are determined by the DisplayOpts attribute of the GraphBox style
element.
2 Fill patterns are valid for box plots starting with SAS 9.4M5.
By default, the group values are mapped in the order of the data.
The GROUPORDER= option can be used to control the sorting
order of the group values. The INDEX= option can be used to alter
the default sequence of colors and markers.
Tips The representations that are used to identify the groups can be
overridden individually. For example, each distinct group value is
represented by a different line pattern for the box outlines, but the
PATTERN= setting in the OUTLIERATTRS= option could be used to
assign the same line pattern to all box outlines and connect lines.
See “Example 2: Box Plot of City MPG and Vehicle Type Grouped by
Origin” on page 403
GROUPDISPLAY=OVERLAY | CLUSTER
specifies how to display the boxes that represent group values for the
coordinate pairs. The following example shows a box plot with
GROUPDISPLAY=CLUSTER:
OVERLAY
draws boxes for a given group value at the exact coordinate.
CLUSTER
draws boxes for a given group value adjacent to each other.
Default OVERLAY
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Tip This option is useful when you want to reverse the category axis.
ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.
Interactions This option is ignored if the GROUP= option is not also specified.
By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.
Notes When plotting a SAS data set, attributes such as color, symbol, and
pattern are assigned to each group in DATA order by default. When
plotting a CAS in-memory table, attributes are assigned in
ascending order of the group column character values or
unformatted numeric values by default.
In SAS 9.4M6 and earlier releases, when data stored in a CAS in-
memory table is used and DATA or REVERSEDATA is specified,
unpredictable results might occur. To generate consistent graphs in
that case, specify ASCENDING or DESCENDING. Starting with SAS
Viya 3.5 and SAS Studio 5.2, when data stored in a CAS in-memory
table is used and DATA or REVERSEDATA is specified, it is ignored,
and ASCENDING is used instead.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
384 Chapter 6 / Plot Statements
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping box attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
INTERVALBOXWIDTH=AUTO | dimension
specifies the box width when an interval category (X) column is specified.
AUTO
the system determines the box width.
Prior to SAS 9.4M3, AUTO uses 85% of the smallest interval between any
two boxes for the given plot. Starting with SAS 9.4M3, if the BOXWIDTH=
option is specified, AUTO uses the BOXWIDTH= option value. Otherwise, it
uses 85% of the smallest interval between any two boxes for the given plot.
uses one of the following box-width values listed in the order of precedence:
BOXPLOT Statement 385
dimension
sets the box width to the specified value.
Default AUTO
Requirement The category axis (X by default) must be an interval axis for the
INTERVALBOXWIDTH= option to have any effect.
Interaction Prior to SAS 9.4M3, this option controls the box width for an
interval box plot. Starting with SAS 9.4M3, this option overrides
the BOXWIDTH= option for an interval box plot.
Tip The box width that you specify with this option is honored even if
the boxes overlap. If the boxes overlap, reduce the interval box
width or use the BOXWIDTH= option instead.
LABELFAR=TRUE | FALSE
specifies whether all outliers or only far outliers are labeled.
FALSE
applies the labels specified by the DATALABEL= option to both the outliers
and the far outliers.
TRUE
applies the labels specified by the DATALABEL= option to the far outliers.
Default FALSE
“boolean ” on page xii for other Boolean values that you can use.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Default The Y= column label. If a label is not defined, then the Y= column
name is used.
Interaction This option is ignored if the DISPLAY= option does not display the
mean.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Interaction This option is ignored if the DISPLAY= option does not display the
median.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and of the boxes.
Default VERTICAL
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
OUTLIERTIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over an
outlier. If this option is used, then it replaces all of the information that is
displayed by default. Roles for columns that do not contribute to the box plot
can be specified along with roles that do contribute.
(role-list)
an ordered, space-separated list of unique BOXPLOT roles. BOXPLOT roles
for OUTLIERTIP include X, Y, STAT, and DATALABEL.
Note In the data tip, the STAT role displays the text “outlier” or “far
outlier” as applicable.
Example The following example displays data tips only for the column that
is assigned to the X role:
OUTLIERTIP=(X)
Interaction The labels and formats for the OUTLIERTIP variables can be
controlled with the TIPLABEL= and TIPFORMAT= options.
See the TIP= option for specifying the information to display when the
cursor is positioned over a box or whisker in the box plot.
For grouped data and filled boxes, the LineStyle and LineThickness
attributes of the GraphOutlines style element, and the ContrastColor
attribute of the GraphData1–GraphDataN style elements.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
388 Chapter 6 / Plot Statements
PERCENTILE=1 | 2 | 3 | 4 | 5
specifies one of five definitions used to calculate percentiles.
Note The percentile definition and default are the same as those that are
used by the PCTLDEF= option of the UNIVARIATE procedure and the
QNTLDEF= option of the SUMMARY procedure.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
SPREAD=TRUE | FALSE
specifies whether outliers with the same value are spread out to avoid overlap.
For vertical box plots this means offsetting the outliers horizontally. If this
option is false, then outliers with the same value are plotted in the same
position, which means only one is visible.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a box or
whisker in the box plot. If this option is used, then it replaces all of the
information that is displayed by default.
(role-list)
an ordered, space-separated list of unique BOXPLOT roles.
BOXPLOT Statement 389
BOXPLOT roles for TIP include DATAMAX, DATAMIN, MAX, MIN, MEAN,
MEDIAN, N, Q1, Q2, STD, SUMWGT, and X.
Note The roles DATAMAX, DATAMIN, and SUMWGT apply to SAS 9.4M1
and later releases.
Tip Statistics such as N, MIN, and MAX are special roles, They are not
column-based like the X role.
Example The following example displays data tips only for the columns that
are assigned to the roles X (CATEGORY) and the statistic MEAN:
TIP=(X MEAN)
NONE
suppresses data tips from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example TIP=(X Y)
TIPFORMAT=(X=4. Y=4.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the OUTLIERTIP= or TIP= options are
used.
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example TIP=(X)
TIPLABEL=(X="Type")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the OUTLIERTIP= or TIP= options are
used.
WEIGHT=numeric-column | expression
specifies a column that contains a statistics calculation a priori weight for each
observation of the input data object.
Note The values of the weight variable must be greater than zero. If the
weight value for an observation is zero, negative, or missing, that
observation is deleted from the analysis.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
WHISKERPERCENTILE=number
specifies the whisker length, in percentile units. When this option is specified,
number is used as the low percentile, and 100–number is used as the high
percentile.
Default The whiskers are drawn from the box to the most extreme point that is
less than or equal to 1.5 times the IQR
Range 0–25
Notes When this option is specified, fences and far outliers are not drawn.
When this option is set to 25, no whiskers are drawn because the box
extends from the 25 th to the 75 th percentile.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
Statement Summary
The BOXPLOT statement displays a single box if given just a Y argument. It
displays multiple boxes if given both Y and X arguments and X has more than one
unique value.
When ORIENT= VERTICAL, the X (or X2) axis is used for the X column and the Y
(or Y2) axis is used for the Y column. When ORIENT=HORIZONTAL, the X (or X2)
axis is used for the Y column and the Y (or Y2) axis is used for the X column.
392 Chapter 6 / Plot Statements
Two basic box plot representations can be drawn with the BOXPLOT statement: a
schematic (Tukey) box plot and a skeletal box plot. See the EXTREME= option for
details.
As shown in the figure, the bottom and top edges of the box are located at the 25th
and 75th percentiles of the sample. Within the box, you can display the median
(50th percentile) as a line and the mean as a marker (see DISPLAY= option).
You can also display markers and data labels for outliers. Outliers are observations
that are more extreme than the upper and lower fences (± 1.5 IQR). Outliers that
are beyond upper and lower far fences (± 3 IQR) are called FAR OUTLIERS and can
also be identified and labeled. From a graphical perspective, the locations of fences
along the axis are known, but there is no line or marker that displays a fence. (See
DISPLAY= , LABELFAR= , and DATALABEL= options).
Finally, you can control the range represented by the whiskers. By default, the
whiskers are drawn from the upper edge of the box to the MAX value, and from the
lower edge of the box to the MIN value. (See the EXTREME= option.)
Calculating Percentiles
You can specify one of five definitions for computing the percentiles with the
PERCENTILE= option. Let n be the number of nonmissing values for a variable, and
let X1, X2, ..., Xn represent the ordered values of the variable. X1 is the smallest
BOXPLOT Statement 393
value, X2 is the next smallest, and Xn is the largest value. Let the tth percentile be y,
set:
t
p= 100
and let:
np = j + g
when PERCENTILE=4, where j is the integer part of np, and g is the fractional part
of np. Then the PERCENTILE= option defines the tth percentile, y, as described in
the following table:
y = xj + 1 1
Used when g = 2 and j
1
is odd or when g > 2
5 Empirical distribution 1
y = 2 (x j + x j + 1) Used when g = 0
function with
averaging
y = xj + 1 Used when g > 0
example, here is a portion of the style template for elements that are related to box
plots:
proc template;
define style Default;
...
style GraphBox /
capstyle = "serif"
connect = "mean"
displayopts = "fill caps median mean outliers";
style GraphBoxMean / ...;
style GraphBoxMedian / ...;
style GraphBoxOutlier / ...;
style GraphBoxWhisker / ...;
...
end;
run;
Table 6.2 Attributes and Values for the GraphBox Style Element
The two display options that are not the default are CONNECT (show connect
lines) and NOTCHES.
396 Chapter 6 / Plot Statements
The STATISTICAL style is derived from the DEFAULT style and inherits the
GraphBox element from the parent DEFAULT style. The following code generates a
box plot for the STATISTICAL style:
/* Specify a path for the ODS output */
filename odsout "output-path";
proc template;
define statgraph boxplotdef;
begingraph;
entrytitle "Statistical Style";
layout overlay / xaxisopts=(label="Age" type=linear);
boxplot x=ageatstart y=cholesterol / intervalboxwidth=40;
endlayout;
endgraph;
end;
For this example, the following attributes on the default box plot are changed:
n By default, serif caps are displayed at the end of the fences. Those caps are
removed from the fence lines.
n By default, the boxes are filled. Empty, notched boxes are displayed.
To make these changes, you can derive a new style from the STATISTICAL style
and set the attributes that you want to change. Any attribute settings that you do
not change are inherited from the parent STATISTICAL style. The following style
template effects the desired changes:
proc template;
define style Boxplot;
parent = styles.statistical;
style GraphBox from GraphBox /
capstyle = "line"
displayopts = "caps median mean outliers notches";
style GraphBoxMean from GraphBoxMean /
markersymbol="diamondfilled"
contrastcolor=GraphColors("gcdata1")
markersize = 5px;
style GraphOutlier from GraphOutlier /
markersize = 5px
markersymbol = "x"
contrastcolor = GraphColors("gcdata2");
end;
run;
n On the GraphBox style element, the CapStyle attribute is set to LINE, which
removes the serif caps from the end of the fences. The DisplayOpts attribute
drops the FILL value from the display list and adds the NOTCHES value; these
changes determine that the graph displays empty, notched boxes.
n On the GraphBoxMean style element, the marker symbol is changed to a filled
diamond and the marker size is reduced to 5 pixels (the default is 9 pixels). The
ContrastColor attribute is set to GCDATA1 (the default is GCDATA).
n On the GraphBoxOutlier style element, the marker symbol is changed to an X
and the marker size is reduced to 5 pixels (the default is 7 pixels). The
CONTRASTCOLOR= attribute is set to GCDATA2 (the default is GCOUTLIER).
The following code generates a box plot for the BOXPLOT style:
/* Specify a path for the ODS output */
filename odsout "output-path";
proc template;
define statgraph boxplotdef;
begingraph;
entrytitle "Boxplot Style";
layout overlay / xaxisopts=(label="Age" type=linear);
boxplot x=ageatstart y=cholesterol / intervalboxwidth=40;
endlayout;
endgraph;
end;
When making such style changes, remember that you are affecting all box plot
displays for all procedures that produce box plots when this style is in effect. It is
possible to change the box plot appearance for specific procedures, but to do this, a
specific graph template must be modified, not a style template.
For a comprehensive description of the style elements affecting ODS graphics, see
“Graph Style Elements Used by ODS Graphics” in SAS Graph Template Language:
User’s Guide.
Notches
In a notched box plot, the endpoints of the notches are at the following computed
locations:
1.58 IQR
median ±
n
In the equation, IQR (IQR=Q3-Q1) is the interquartile range and n is the sample size.
The medians (central lines) of the two boxes are significantly different at
approximately the 0.05 level if the corresponding notches do not overlap.
400 Chapter 6 / Plot Statements
Maximum observation
th
75 percentile (upper
quartile)
1/2
1.58(IQR) / n
+ Mean
Median
1/2
1.58(IQR) / n
th
25 percentile (lower
quartile)
Minimum observation
Note: In some cases, the notches in the box plot can extend beyond DATAMIN and
DATAMAX.
To place the different response values side by side, you can assign a different offset
to each BOXPLOT statement. The BOXWIDTH= option can be used in conjunction
with the DISCRETEOFFSET= option to create narrower boxes when desired.
layout overlay / cycleattrs=true
yaxisopts=(label="Miles Per Gallon");
boxplot x=type y=mpg_city / name="City"
discreteoffset=0.2 legendlabel="City";
boxplot x=type y=mpg_highway / name="Highway"
discreteoffset=-0.2 legendlabel="Highway";
discretelegend "City" "Highway";
endlayout;
402 Chapter 6 / Plot Statements
Examples
Example Program
proc template;
define statgraph boxplot;
begingraph;
entrytitle "City Mileage for Vehicle Types";
layout overlay /
xaxisopts=(offsetmin=0.1 offsetmax=0.1);
boxplot y=mpg_city x=type /
datalabel=make spread=true;
endlayout;
endgraph;
end;
run;
Example Program
proc template;
define statgraph boxplot;
begingraph;
entrytitle "City Mileage and Vehicle Type By Origin";
layout overlay /
xaxisopts=(offsetmin=0.1 offsetmax=0.1);
boxplot y=mpg_city x=type / name="box"
group=origin groupdisplay=cluster
spread=true datalabel=make;
discretelegend "box";
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.cars template=boxplot;
label type="Vehicle Type";
run;
BOXPLOTPARM Statement
Creates side-by-side box plots specified by parameters.
404 Chapter 6 / Plot Statements
Requirements: The input data must be precomputed. See “Input Data Requirements for the
BOXPLOTPARM Statement” on page 435.
Nonmissing Y values for statistical observations of Q1 and Q3 are required in order
for a box to be drawn.
The statistical values, if present, must conform to the following rules in order for a
box to be displayed:
Q1 <= MEDIAN <= Q3
MIN <= MAX
STD >= 0
N > 0
Tip: Starting with SAS 9.4M3, you can use subpixel rendering with this statement. It is
enabled by default. To disable subpixel rendering, specify SUBPIXEL=OFF in the
BEGINGRAPH statement or in an ODS GRAPHICS statement. For information
about the BEGINGRAPH statement SUBPIXEL= option, see SUBPIXEL= on page 39.
For information about the ODS GRAPHICS statement SUBPIXEL= option, see “ODS
GRAPHICS Statement” on page 1561.
Syntax
BOXPLOTPARM Y=numeric-column | expression
STAT=string-column < /option(s) >;
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
406 Chapter 6 / Plot Statements
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
DATALABEL=column
specifies the labels of the values that are identified as outlier or far
outlier by the STAT= column.
DATALABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the outlier labels.
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if
needed.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
DATALABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the data label
blocks.
LABELFAR=TRUE | FALSE
specifies whether all outliers or only far outliers are labeled.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
DISCRETEOFFSET=number
specifies an amount to offset all boxes from the discrete X ticks.
GROUP=column | discrete-attr-var | expression
creates a box plot for each unique group value of the specified column.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies how to display the boxes that represent group values for the
coordinate pairs.
GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
BOXPLOTPARM Statement 407
ODS options
URL=string-column
specifies an HTML page that is displayed when a box or an outlier marker
is selected.
Statistics options
DISPLAYSTATS=NONE | STANDARD | ALL | (statistics-list)
specifies the statistics to be displayed for each box.
Required Arguments
Specifying only Y= creates a single box plot. Specifying both X= and Y= creates a box plot
for each unique value of X.
Y=numeric-column | expression
specifies the column for the Y values. The Y values must be the statistical
values needed for the box plot. At a minimum, there must be nonmissing values
for the 25th and 75th percentiles.
X=column | expression
specifies the column for the X values. The X values must qualify or classify the
values in the Y column. This optional argument is used to create a plot box for
each classifier.
Restriction When you specify a numeric column for the X= argument and the
category axis is an interval axis, you should not change the column
value format. Doing so might result in incorrect output.
STAT=string-column
specifies the name of a column that contains the statistic represented by the
value in the Y column. Valid STAT= column values include the following (see the
requirements listed at the end of this description):
BOXWIDTH
specifies the width of the boxes as a ratio of the maximum possible width.
DATAMAX
specifies the maximum data value that includes not only the maximum
whisker values but the maximum outlier values as well.
408 Chapter 6 / Plot Statements
The DATAMAX value is greater than or equal to the MAX value and is always
represented in the axis range.
DATAMIN
specifies the minimum data value that includes not only the minimum
whisker values but the minimum outlier values as well.
The DATAMIN value is less than or equal to the MIN value and is always
represented in the axis range.
FAROUTLIER
specifies the observations that are outside the lower and upper far fences.
The far fences are located at a distance 3 times the Interquartile Range (IQR
= Q3–Q1) above and below the box. The far outliers are labeled when the
DATALABEL= option is used. Specify that LABELFAR= TRUE to label only
the far outliers but not the outliers.
MAX
specifies the maximum data value less than or equal to the upper fence.
MEAN
specifies the data mean.
MEDIAN
specifies the data median.
MIN
specifies the minimum data value greater than or equal to the lower fence.
N
specifies the subgroup sample size.
The N value is not shown in the plot but is used to calculate notch locations
when the DISPLAY= option displays notches.
OUTLIER
specifies the observations that are outside the lower and upper fences.
The fences are located at a distance 1.5 times the Interquartile Range (IQR =
Q3–Q1) above and below the box. The outliers are labeled when the
DATALABEL= option is used.
Q1
specifies the 1st quartile (25th percentile).
Q3
specifies the 3rd quartile (75th percentile).
STD
specifies the data standard deviation.
BOXPLOTPARM Statement 409
SUMWGT
specifies the sum of the weights for the box.
Optional Arguments
BOXWIDTH=number
specifies the width of a box as a ratio of the maximum possible width.
Defaults For a discrete category axis, 0.4 for a nongrouped box plot or 0.6
for a grouped box plot.
Interactions For a grouped box plot with a discrete category axis when
GROUPDISPLAY=CLUSTER, the box width is a percentage of the
cluster width. See CLUSTERWIDTH.
Prior to SAS 9.4M3, for an interval box plot, this option is ignored,
and the box width is controlled by the INTERVALBOXWIDTH=
option. Starting with SAS 9.4M3, for an interval box plot, this option
is ignored when the INTERVALBOXWIDTH= option is specified.
Otherwise, the BOXWIDTH= option is honored.
CAPSCALE=positive-number
specifies a positive number to use as a multiplier for determining the default
width of the whisker caps.
Default 1
SERIF
specifies a short line perpendicular to the whisker.
LINE
specifies a line perpendicular to the whisker that extends the width of the
box.
BRACKET
specifies a line perpendicular to the whiskers that extends the width of the
box and that has short extensions at each end.
NONE
specifies that no shape appears at the ends of the whiskers.
Default SERIF
Interactions The cap color and the thickness are specified by the
WHISKERATTRS= option. The cap pattern is always solid.
The DISPLAY= option must include CAPS in order for cap lines to
be shown.
CLUSTERWIDTH=number
specifies the width of the group clusters as a fraction of the midpoint spacing or
bin width.
BOXPLOTPARM Statement 411
Default 0.7
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
Requirement For this option to take effect, the GROUP= option must also be
specified, and the GROUPDISPLAY= option must be set to
CLUSTER.
Interaction This option applies only when the X= argument is used to generate
multiple boxes.
Note Starting with SAS 9.4M3, the connect lines are drawn in axis order.
In prior releases, they are drawn in data order.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CONNECTBREAK=TRUE | FALSE
specifies whether the connect line is broken for values that have no
observations.
Default FALSE
Requirement DISPLAY= must include CONNECT for this option to have any
effect.
DATALABEL=column
specifies the labels of the values that are identified as outlier or far outlier by
the STAT= column. Either a numeric or a character column can be used.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters. When
set to TRUE, the data label is split unconditionally at each occurrence of any of
the specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if needed.
When multiple split characters are specified, each character in the list is treated
BOXPLOTPARM Statement 413
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
TRUE
drops the split characters from the data label.
FALSE
includes the split characters in the data label.
The following figure shows an example of a data label with the following
specifications:
n the data label text for this label is Product*Group*A
n DATALABELSPLIT=TRUE
n DATALABELSPLITCHARDROP=TRUE | FALSE
414 Chapter 6 / Plot Statements
n DATALABELSPLITCHAR="*"
Default TRUE. The split characters are dropped from the data label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the DATALABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The gray vertical line at the bottom of each label represents the
horizontal center of the text box for reference.
BOXPLOTPARM Statement 415
Default AUTO
Requirement For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
416 Chapter 6 / Plot Statements
When a data skin is applied, all bar outlines are set by the skin, and
the OUTLINEATTRS= option is ignored.
DATATRANSPARENCY=number
specifies the degree of the transparency of the box outlines, box fill, whiskers,
mean, median, caps, connect lines, outliers, and data labels, if displayed.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
interior fill area of the boxes. You can combine this option with
FILLATTRS= to set one transparency for the box outlines and the
whiskers, mean, median, caps, and connect lines, but a different
transparency for the box fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
DISCRETEOFFSET=number
specifies an amount to offset all boxes from the discrete X ticks.
Default 0 (no offset, all boxes are centered on the discrete ticks)
Range -0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. A positive offset is to the right when
ORIENT=VERTICAL, and up when ORIENT=HORIZONTAL. (If the
layout's axis options set REVERSE=TRUE, then the offset direction
is also reversed.)
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
CAPS
displays caps at the ends of the whiskers.
CONNECT
displays the line connecting multiple boxes.
FILL
displays the box fill color.
FILLPATTERN
displays the box fill pattern.
Tip By default, this option has no effect if the active ODS style does
not specify a fill pattern. To display a fill pattern in that case,
select an ODS style that supports fill patterns or use the
FILLPATTERNATTRS= option to specify a fill pattern for the
boxes.
MEAN
displays the mean symbol within the box.
MEDIAN
displays the median line within the box.
NOTCHES
displays notched boxes.
OUTLIERS
displays markers for the outliers.
STANDARD
specifies CAPS FILL MEAN MEDIAN, and OUTLIERS.
ALL
specifies all features: CAPS, CONNECT, FILL, FILLPATTERN, MEAN,
MEDIAN, NOTCHES, and OUTLIERS.
Restriction The display features requested can be displayed only if the input
data includes this information.
Notes Starting with SAS 9.4M3, the connect lines are drawn in axis order.
They are drawn in data order in prior releases.
NONE
does not display any statistics.
STANDARD
displays N, MEAN, and STD.
ALL
displays all available statistics.
(statistics-list)
specifies a space-separated list of one or more statistics, enclosed in
parentheses.
DATAMAX
maximum data value that includes not only the maximum whisker values
but also the maximum outlier values.
This option is valid in SAS 9.4M1 and later releases. The DATAMAX value
is greater than or equal to the MAX value and is always represented in
the axis range.
DATAMIN
minimum data value that includes not only the minimum whisker values
but also the minimum outlier values.
This option is valid in SAS 9.4M1 and later releases. The DATAMIN value
is less than or equal to the MIN value and is always represented in the
axis range.
IQR
interquartile range (Q3–Q1).
MAX
maximum data value below the box upper fence.
MEAN
mean data value for the box.
MEDIAN
median data value for the box.
BOXPLOTPARM Statement 419
MIN
minimum data value above the box lower fence.
N
number of observations for the box.
Q1
lower quartile (25th percentile) for the box.
Q3
upper quartile (75th percentile) for the box.
RANGE
range of the data (MAX–MIN).
STD
standard deviation of the data for the box.
SUMWGT
sum of the weights for the box.
Default NONE
Only those statistics that are included in the STAT= column can be
displayed. RANGE requires both MAX and MIN to be included. IQR
requires both Q1 and Q3 to be included.
Note The notches in the box plot can extend beyond DATAMIN and
DATAMAX in some cases.
EXTREME=TRUE | FALSE
specifies whether the whiskers can extend beyond the fences. Fences are
locations above and below the box. The upper and lower fences are located at a
distance 1.5 times the Interquartile Range (IQR) (IQR = Q3 - Q1). The upper and
lower far fences are located at a distance 3 times the IQR .
FALSE
specifies that whiskers be drawn from the upper edge of the box to the
largest value within the upper fence, and from the lower edge of the box to
the smallest value within the lower fence.
TRUE
specifies that whiskers be drawn to the largest and smallest data values,
whether these values are inside or outside the fences.
The outliers and far outliers are not displayed and are not labeled. This
representation is sometime called a skeletal box and whisker plot.
420 Chapter 6 / Plot Statements
Default FALSE
“boolean ” on page xii for other Boolean values that you can use.
Interaction For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
Interaction For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS styles
such as HTMLBlue that use color-priority attribute rotation, specify
ATTRPRIORITY=NONE in an ODS GRAPHICS statement or in the
BEGINGRAPH statement in your graph template. For more
BOXPLOTPARM Statement 421
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
discrete-attr-var
specifies a discrete attribute map variable.
The box plot display depends on the setting for the GROUPDISPLAY= option.
This option can be used to group the box plots in the display.
A distinct box is created for each group value by varying the visual attributes of
the box display features. The display features are controlled by the current ODS
style or by the DISPLAY= option. The default group appearance for each display
feature is shown in the following table.
Display
Feature 1 Style Attributes That Control Default Group Appearance
Display
Feature 1 Style Attributes That Control Default Group Appearance
1 The default display features are determined by the DisplayOpts attribute of the GraphBox style
element.
2 Fill patterns are valid for box plots starting with SAS 9.4M5.
Defaults If box fills are enabled by the ODS style or by the DISPLAY= option,
then each distinct group value is represented in the plot by a
different fill color. Starting with SAS 9.4M5, each distinct group
value can be represented by a different fill pattern, with or without
a different fill color. The fill color and fill pattern are defined by the
Color and FillPattern attributes of the GraphData1–GraphDataN
and GraphMissing style elements.
Tips By default, the group values are mapped in the order of the data.
The GROUPORDER= option can be used to control the sorting
order of the group values. The INDEX= option can be used to alter
the default sequence of colors and markers.
See the GROUPDISPLAY= option to see the output for the grouped
boxes
GROUPDISPLAY=OVERLAY | CLUSTER
specifies how to display the boxes that represent group values for the
coordinate pairs. The following example shows a box plot with
GROUPDISPLAY=CLUSTER:
OVERLAY
draws boxes for a given group value at the exact coordinate.
CLUSTER
draws boxes for a given group value adjacent to each other.
This option is available only when the category (X) column is discrete.
Default OVERLAY
The groups in the legend are shown in the order that is specified in
GROUPORDER by default.
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Tip This option is useful when you want to reverse the category axis.
ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.
Interactions This option is ignored if the GROUP= option is not also specified.
By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.
Notes When plotting a SAS data set, attributes such as color, symbol, and
pattern are assigned to each group in DATA order by default. When
plotting a CAS in-memory table, attributes are assigned in
ascending order of the group column character values or
unformatted numeric values by default.
In SAS 9.4M6 and earlier releases, when data stored in a CAS in-
memory table is used and DATA or REVERSEDATA is specified,
BOXPLOTPARM Statement 425
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping box attributes (fill and outline) to one of the
GraphData1–GranphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
INTERVALBOXWIDTH=AUTO | dimension
specifies the box width when an interval category (X) column is specified.
426 Chapter 6 / Plot Statements
AUTO
the system determines the box width.
uses one of the following box-width values listed in the order of precedence:
n the BOXWIDTH statistic, if it is included in the Stat column and if the Y
value is within the range of 0–1
n starting with SAS 9.4M3, the BOXWIDTH= option value, if it is specified
n otherwise, 85% of the smallest interval between any two boxes for the
given plot
dimension
sets the box width to the specified value.
Default AUTO
Requirement The category axis (X by default) must be an interval axis for the
INTERVALBOXWIDTH= option to have any effect.
Interactions Starting with SAS 9.4M3, this option is overridden by the Y value
when the STAT= column value is BOXWIDTH and the
corresponding Y value is within the range of 0–1.
Prior to SAS 9.4M3, this option controls the box width for an
interval box plot. Starting with SAS 9.4M3, this option overrides
the BOXWIDTH= option for an interval box plot.
Tip The box width that you specify with this option is honored even if
the boxes overlap. If the boxes overlap, reduce the interval box
width or use the BOXWIDTH= option instead.
LABELFAR=TRUE | FALSE
specifies whether all outliers or only far outliers are labeled.
FALSE
applies the labels specified by the DATALABEL= option to both the outliers
and the far outliers.
TRUE
applies the labels specified by the DATALABEL= option to the far outliers.
Default FALSE
“boolean ” on page xii for other Boolean values that you can use.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
BOXPLOTPARM Statement 427
Default The Y= column label. If a label is not defined, then the Y= column
name is used.
Interaction This option is ignored if the DISPLAY= option does not display the
mean.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Interaction This option is ignored if the DISPLAY= option does not display the
median.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
428 Chapter 6 / Plot Statements
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and of the boxes.
Default VERTICAL
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
OUTLIERTIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over an
outlier. If this option is used, then it replaces all of the information that is
displayed by default.
(role-list)
an ordered, space-separated list of unique BOXPLOTPARM roles and user-
defined roles. BOXPLOTPARM roles for OUTLIERTIP include X, Y, STAT, and
DATALABEL.
Note In the data tip, the STAT role displays the text “outlier” or “far
outlier” as applicable.
Example The following example displays data tips for the columns that are
assigned to the X and Y roles, and also the data column Obs, which
is not assigned to any pre-defined BOXPLOTPARM role. The Obs
column must first be assigned a role:
ROLENAME=(TIP1=OBS)
OUTLIERTIP=(X Y TIP1)
Interaction The labels and formats for the OUTLIERTIP variables can be
controlled with the TIPLABEL= and TIPFORMAT= options.
the TIP= option for specifying the information to display when the
cursor is positioned over a box or whisker in the box plot.
For grouped data and filled boxes, the LineStyle and LineThickness
attributes of the GraphOutlines style element, and the ContrastColor
attribute of the GraphData1–GraphDataN style elements.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the OUTLIERTIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
430 Chapter 6 / Plot Statements
Requirement The role names that you choose must be unique and different from
the predefined roles DATAMAX, DATAMIN, MAX, MIN, MEAN,
MEDIAN, N, Q1, Q2, STD, SUMWGT, and X.
Note The roles DATAMAX, DATAMIN, and SUMWGT are valid in SAS
9.4M1 and in later releases.
SPREAD=TRUE | FALSE
specifies whether outliers with the same value are spread out to avoid overlap.
For vertical box plots this means offsetting the outliers horizontally. If this
option is false, then outliers with the same value are plotted in the same
position, which means only one is visible.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a box or
whisker in the box plot. If this option is used, then it replaces all of the
information that is displayed by default. Roles for columns that do not
contribute to the box plot can be specified along with roles that do contribute.
(role-list)
an ordered, space-separated list of unique BOXPLOTPARM roles.
Note The roles DATAMAX, DATAMIN, and SUMWGT are valid in SAS
9.4M1 and later releases.
Tip Statistics such as N, MIN, and MAX are special roles, They are not
column-based like the X role.
Example The following example displays data tips only for the columns that
are assigned to the roles X (CATEGORY) and the statistic MEAN:
TIP=(X MEAN)
NONE
suppresses data tips from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
BOXPLOTPARM Statement 431
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the OUTLIERTIP= or TIP= options are
used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the OUTLIERTIP= or TIP= options are
used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
URL=string-column
specifies an HTML page that is displayed when a box or an outlier marker is
selected.
432 Chapter 6 / Plot Statements
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each box or outlier marker that is to have an active link.
Example http://www.sas.com
The character column can specify different target URLs for each box and outlier
marker.
Requirements The target URLs for the boxes must be specified in the Q1 statistic
observations, and the target URLs for the outlier markers must be
specified in the OUTLIER statistic observations. URLs that are
specified in observations other than Q1 and OUTLIER are ignored.
Tips The URL value can be blank for a box or outlier, meaning that no
action is taken when that box or outlier marker is selected.
Example The following vehicle mileage data sample shows box and outlier
URLs specified in column URL for Sedan.
STAT X VALUE DATALABEL URL
...
N Sedan 262.0
MEAN Sedan 08
MEDIAN Sedan 20.00
Q1 Sedan 18.00 ./mileageSedan.html
Q3 Sedan 24.00
STD Sedan 4.23
OUTLIER Sedan 36.00 Honda ./mileageHonda.html
OUTLIER Sedan 35.00 Toyota ./mileageToyota.html
OUTLIER Sedan 35.00 Toyota ./mileageToyota.html
OUTLIER Sedan 38.00 Volkswagen ./mileageVolkswagen.html
MIN Sedan 12.00 Volvo
MAX Sedan 33.00 Volvo
...
BOXPLOTPARM Statement 433
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
Statement Summary
The BOXPLOTPARM statement requires precomputed input data. One reason to
choose this statement over the BOXPLOT statement is that you can control the
computational technique used to compute various statistics for the box plot, such
as the mean, quartiles, location of fences, outlier definition, and so on. See
Appendix 5, “Generalized Macro for BOXPLOTPARM Data,” on page 1627 for
examples of such computations using PROC SUMMARY and multiple DATA steps.
The BOXPLOTPARM statement displays a single box if given just Y and a STAT
argument. It displays multiple boxes if given both Y and X and a STAT argument
and X has more than one unique value.
434 Chapter 6 / Plot Statements
When ORIENT= VERTICAL, the X (or X2) axis is used for the X column and the Y
(or Y2) axis is used for the Y column. When ORIENT=HORIZONTAL, the X (or X2)
axis is used for the Y column and the Y (or Y2) axis is used for the X column.
Two basic box plot representations can be drawn with the BOXPLOTPARM
statement: a schematic (Tukey) box plot and a skeletal box plot. See the EXTREME=
option for details.
As shown in the figure, the bottom and top edges of the box are located at the 1st
quartile (25th percentile) and 3rd quartile (75th percentile) of the sample. Within
the box, you can display the median (50th percentile) as a line and the mean as a
marker (see the DISPLAY= option).
You can also display markers and data labels for outliers. Outliers are observations
that are more extreme than the upper and lower fences (± 1.5 IQR). Outliers that
are beyond upper and lower far fences (±3 IQR) are called FAR OUTLIERS and can
also be identified and labeled. From a graphical perspective, the locations of fences
BOXPLOTPARM Statement 435
along the axis are known, but there is no line or marker that displays a fence. (See
DISPLAY= , LABELFAR= , and DATALABEL= options).
Finally, you can control the range represented by the whiskers. By default, the
whiskers are drawn from the upper edge of the box to the MAX value, and from the
lower edge of the box to the MIN value. (See the EXTREME= option.)
For example, a petroleum company uses a turbine to heat water into steam that is
pumped into the ground to make oil more viscous and easier to extract. This
process occurs 20 times daily, and the amount of power (in kilowatts) used to heat
the water to the desired temperature is recorded. The following data show the
statistics that are calculated for one day of this process:
PowerOutputs Statistic
3180.00 MIN
3340.00 Q1
3487.40 MEAN
3490.00 MEDIAN
3610.00 Q3
4050.00 MAX
20.00 N
To plot the data from the preceding table, the following BOXPLOTPARM statement
uses the Y= and STAT= arguments to generate a single box plot for the recorded
statistics:
If the data contain statistics for multiple days of the process, then a third column in
the data must be present to identify the days that the statistics were recorded. For
example, the following data show the statistics that are calculated for two days of
this process:
04JUL 3340.00 Q1
04JUL 3610.00 Q3
04JUL 20.00 N
05JUL 3333.50 Q1
05JUL 3605.00 Q3
05JUL 20.00 N
BOXPLOTPARM Statement 437
To plot the data from the preceding table, the BOXPLOTPARM statement needs
the Y=, STAT=, and X= arguments to generate a separate box plot for each day that
the statistics were recorded:
See Appendix 5, “Generalized Macro for BOXPLOTPARM Data,” on page 1627 for a
more complete example of providing input data for BOXPLOTPARM.
Notches
In a notched box plot, the endpoints of the notches are at the following computed
locations:
1.58 IQR
median ±
n
In the equation, IQR (IQR=Q3-Q1) is the interquartile range and n is the sample size.
The medians (central lines) of the two boxes are significantly different at
approximately the 0.05 level if the corresponding notches do not overlap.
438 Chapter 6 / Plot Statements
Maximum observation
th
75 percentile (upper
quartile)
1/2
1.58(IQR) / n
+ Mean
Median
1/2
1.58(IQR) / n
th
25 percentile (lower
quartile)
Minimum observation
Note: In some cases, the notches in the box plot can extend beyond DATAMIN and
DATAMAX.
To place the different response values side by side, you can assign a different offset
to each BOXPLOTPARM statement. The BOXWIDTH= option can be used in
conjunction with the DISCRETEOFFSET= option to create narrower boxes when
desired.
layout overlay / cycleattrs=true
yaxisopts=(label="Miles Per Gallon");
Use the %BOXCOMPUTE macro to generate the data for this example. See
Appendix 5, “Generalized Macro for BOXPLOTPARM Data,” on page 1627 to see the
code for creating all of the data.
%boxcompute(indsn=sashelp.cars,x=type,y=mpg_city,datalabel=make);
Example Program
Here is the code for this example.
/* Define the template for the plot. */
proc template;
define statgraph boxplotparm1;
begingraph;
entrytitle "City Mileage for Vehicle Types";
layout overlay;
boxplotparm y=value x=x stat=stat /
datalabel=datalabel spread=true ;
endlayout;
endgraph;
end;
run;
BUBBLEPLOT Statement 441
BUBBLEPLOT Statement
Creates a bubble plot of the input data. The locations of the bubble centers correspond to the values
of X and Y columns in the data, and the bubble radii correspond to the values of a SIZE column.
Tip: Starting with SAS 9.4M3, you can use subpixel rendering with this statement. It is
enabled by default. To disable subpixel rendering, specify SUBPIXEL=OFF in the
BEGINGRAPH statement or in an ODS GRAPHICS statement. For information
about the BEGINGRAPH statement SUBPIXEL= option, see SUBPIXEL= on page 39.
For information about the ODS GRAPHICS statement SUBPIXEL= option, see “ODS
GRAPHICS Statement” on page 1561.
Syntax
BUBBLEPLOT X=column | expression
Y=column | expression
SIZE=numeric-column | expression </options>;
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
DATALABEL=column | expression
BUBBLEPLOT Statement 443
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a separate bubble color for each unique grouping that is
specified.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
ODS options
URL=string-column
specifies an HTML page to display when a bubble is selected.
Required Arguments
X=column | expression
specifies the column for the X values of the bubble centers.
Y=column | expression
specifies the column for the Y values of the bubble centers.
SIZE=numeric-column | expression
specifies the bubble SIZE values.
444 Chapter 6 / Plot Statements
Optional Arguments
BUBBLERADIUSMAX=dimension
specifies the drawing size of the largest bubble.
BUBBLERADIUSMIN=dimension
specifies the drawing size of the smallest bubble.
Default GraphDataDefault:markerSize
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
BUBBLEPLOT Statement 445
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.
Tip To reverse the start and end colors of the ramp that is assigned to
the color model, use the REVERSECOLORMODEL= option.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
Interactions Prior to SAS 9.4M5, when the GROUP= option is specified with the
COLORRESPONSE= option, the GROUP= option is ignored. Starting
with SAS 9.4M5, the COLORRESPONSE= option controls the color
of the group fill patterns when the fill patterns are displayed.
Notes When both the fill and outline are displayed, the bubble fill color
varies according to the color gradient or attribute map but the
446 Chapter 6 / Plot Statements
The mapped color used for the bubbles is also used for the data
labels.
DATALABEL=column | expression
specifies a column for bubble labels. The label positions are adjusted to prevent
them from overlapping.
For grouped data, the text color is derived from the GraphData1–
GraphDataN style elements. The data label color changes to match
the group color derived from the ContrastColor attribute of the style
element that is in effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Default TOPRIGHT
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters. When
set to TRUE, the data label is split unconditionally at each occurrence of any of
the specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
BUBBLEPLOT Statement 447
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the data label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
TRUE
drops the split characters from the data label.
FALSE
includes the split characters in the data label.
The following figure shows an example of a data label with the following
specifications:
n the data label text for this label is Product*Group*A
448 Chapter 6 / Plot Statements
n DATALABELSPLIT=TRUE
n DATALABELSPLITCHARDROP=TRUE | FALSE
n DATALABELSPLITCHAR="*"
Default TRUE. The split characters are dropped from the data label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the DATALABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The gray vertical line at the bottom of each label represents the
horizontal center of the text box for reference.
BUBBLEPLOT Statement 449
Default AUTO
Requirement For this option to have any effect, DISPLAY= FILL must be in
effect. Otherwise, this option is ignored.
When a data skin is applied, all bubble outlines are set by the skin,
and the OUTLINEATTRS= option is ignored.
DATATRANSPARENCY=number
specifies the degree of the transparency of the bubble fills and bubble outlines
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
filled bubble areas. You can combine this option with FILLATTRS= to
set one transparency for the bubble outlines but a different
transparency for the bubble fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
OUTLINE
displays the bubble outline
FILL
displays the bubble fill color
FILLPATTERN
displays the bubble fill pattern
Tip By default, this option has no effect if the active ODS style does
not specify a fill pattern. To display a fill pattern in that case,
select an ODS style that supports fill patterns or use the
FILLPATTERNATTRS= option to specify a fill pattern for the
bubbles.
STANDARD
specifies FILL and OUTLINE
ALL
specifies all features: FILL, FILLPATTERNATTRS, and OUTLINE
BUBBLEPLOT Statement 451
Default STANDARD
DRAWORDER=SIZE | DATA
specifies whether the bubbles are drawn according to bubble size or according
to data order.
SIZE
draws the bubbles according to bubble size, from the largest to the smallest
DATA
draws the bubbles according to data order
The following figure shows the effect of SIZE and DATA on four bubbles. The
bubble labels indicate the data order, and the bubble sizes increase linearly
starting with 1.
Default SIZE
Interactions For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
Interactions For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS
styles such as HTMLBlue that use color-priority attribute rotation,
specify ATTRPRIORITY=NONE in an ODS GRAPHICS statement or
in the BEGINGRAPH statement in your graph template. For more
information, see “Attribute Rotation Patterns” in SAS Graph
Template Language: User’s Guide.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
discrete-attr-var
specifies a discrete attribute map variable.
A distinct bubble is created for each group value by varying the visual attributes
of the bubble display features. The display features are controlled by the
current ODS style or by the DISPLAY= option. The default group appearance for
each display feature is shown in the following table.
BUBBLEPLOT Statement 453
Display
Feature1 Style Attributes That Control Default Group Appearance
The mapped color that is used for outlines is also used as the color
of the data labels.
Notes All bubbles have only one fill and one outline color as specified by
the FILLATTRS= and OUTLINEATTRS options.
If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping bubble attributes (fill and outline) to one of the
GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
BUBBLEPLOT Statement 455
Default The SIZE= column label. If a label is not defined, then the SIZE=
column name is used.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
Interactions For this option to have any effect, outlines must be enabled by the
ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
RELATIVESCALE=TRUE | FALSE
specifies whether the SIZE= column values are interpreted as relative values.
Relative means that the size values do not translate directly into bubble radii.
Rather, the bubble sizes are scaled to represent the value range of the SIZE=
column.
For example, when RELATIVESCALE=TRUE, if only two bubbles are drawn with
sizes of 2 and 4, then they appear the same as only two bubbles with sizes of
4000 and 8000. By contrast, when RELATIVESCALE=FALSE, the size values
are interpreted in the same units as the axes.
If you set this option to FALSE, then it is recommended that you also place the
BUBBLEPLOT statement in a LAYOUT OVERLAYEQUATED container. This
ensures that the X axis and Y-axis units are the same. For more information, see
“Details” on page 460.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
RELATIVESCALETYPE=LINEAR | PROPORTIONAL
specifies the type of scaling that is to be applied to the SIZE= column values.
LINEAR
increases the size of the bubbles in linear proportion to the range of the
SIZE= column values.
For example, if only two bubbles are drawn with sizes of 2 and 4, then they
appear the same as only two bubbles with sizes of 4000 and 8000.
PROPORTIONAL
increases the size of each bubble in direct proportion to its corresponding
SIZE= column value.
For example, if only two bubbles are drawn with sizes of 50 and 100, then
the bubble for SIZE=50 is drawn to half the size of the bubble for SIZE=100.
Default LINEAR
If all the values for the SIZE= column are negative, then
RELATIVESCALETYPE=PROPORTIONAL is ignored, and the
default value is used.
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by either
the ODS style that is in effect or by the COLORMODEL= option.
Default FALSE
See COLORMODEL=
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
458 Chapter 6 / Plot Statements
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles X, Y , SIZE, GROUP, DATALABEL, and
COLORRESPONSE.
SIZETHRESHOLDMAX=numeric-value
specifies a SIZE= column value threshold at which bubble size is clamped to the
BUBBLERADIUSMAX= option value. The size of the bubbles for all SIZE=
column values that equal or exceed the specified threshold value is set to the
BUBBLERADIUSMAX= value.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over the
bubbles. If this option is used, then it replaces all of the information that is
displayed by default. Roles for columns that do not contribute to the bubble
plot can be specified along with roles that do.
(role-list)
an ordered, space-separated list of unique BUBBLEPLOT and user-defined
roles.
Example The following example displays data tips for the columns assigned
to the roles X, Y, and SIZE, as well as the column Pop_2009. The
POP_2009 column is not assigned to any pre-defined
BUBBLEPLOT role, so it must first be assigned a role:
ROLENAME=(TIP1=POP_2009)
TIP=(TIP1 X Y SIZE)
NONE
suppresses data tips and URLs (if requested) from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
BUBBLEPLOT Statement 459
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
URL=string-column
specifies an HTML page to display when a bubble is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each bubble that is to have an active link.
Example http://www.sas.com
460 Chapter 6 / Plot Statements
Tips The URL value can be blank for some X and Y pairs, meaning that
no action is taken when the corresponding point is selected.
The URL value can be the same for any X and Y pairs. In that case,
the same action is taken when the bubbles for those X and Y pairs
are selected.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
The BUBBLEPLOT statement displays one bubble for each row in the data,
provided that row contains nonmissing values for X, Y, and SIZE. By default, the
bubbles are displayed as filled, outlined circles. Regardless of the data order, the
bubbles are always drawn from the largest size to the smallest size.
BUBBLEPLOT Statement 461
By default, the minimum and maximum values of the SIZE= column establish a
range over which the bubble radii increase in linear proportion. The actual drawing
size of the smallest and largest bubble is set automatically. You can adjust the
smallest and largest bubble sizes with the BUBBLERADIUSMIN= and
BUBBLERADIUSMAX= options. In these cases where the bubble sizes are
proportional to each other, the default setting RELATIVESCALE=TRUE is
appropriate.
If the SIZE= values are in the same units as the X and Y values, and both X and Y
are numeric, then you can generate a plot where the bubble-radius units match the
axis-scale units. To do so, specify the BUBBLEPLOT statement within a LAYOUT
OVERLAYEQUATED block, and in the BUBBLEPLOT statement, set
RELATIVESCALE=FALSE.
By default, for character columns, the X and Y axes are always discrete. For
numeric columns, the X and Y axes are linear. You can change axis type for numeric
axes with the layout options XAXISOPTS= and YAXISOPTS=.
Note: Within a LAYOUT OVERLAY, the unit-interval of the X and Y axes are not
necessarily the same and the bubbles might be distorted into ellipses when
RELATIVESCALE=FALSE. The OVERLAYEQUATED container ensures that the
bubbles are displayed as circles, assuming that both the X= and Y= arguments
specify numeric columns.
data influence;
input x y radius category;
datalines;
2 4 1 1
5 5 2 1
6 3 2 2
12 7 3 2
;
proc template;
define statgraph equatedbubbles;
begingraph;
entrytitle 'Radius of Influence';
entrytitle 'Bubbles Show Distance Covered by Observation';
layout overlayequated /
xaxisopts = (griddisplay=on)
yaxisopts = (griddisplay=on);
bubbleplot x=x y=y size=radius /
group=category datatransparency=0.5
relativescale=false ;
endlayout;
endgraph;
end;
Example Program
data bubbleintro;
input Engineer $ Salary number;
format Salary dollar7.0 number comma6.0;
datalines;
Electric 59000 89382
Civil 54000 73273
Software 56000 34833
Chemical 62000 25541
Mechanical 60000 19601
;
proc template;
define statgraph engineer;
begingraph;
entrytitle 'Median Salary for Entry Level Engineers';
entrytitle 'Bubbles Show Number of Engineers in Survey';
layout overlay;
bubbleplot x=engineer y=salary
size=number / datalabel=number;
endlayout;
endgraph;
end;
CONTOURPLOTPARM Statement
Creates a contour plot representing a response variable evaluated over a grid of X and Y values.
Starting with SAS 9.4M3, you can use subpixel rendering with this statement. It is
enabled by default. To disable subpixel rendering, specify SUBPIXEL=OFF in the
BEGINGRAPH statement or in an ODS GRAPHICS statement. For information
about the BEGINGRAPH statement SUBPIXEL= option, see SUBPIXEL= on page 39.
For information about the ODS GRAPHICS statement SUBPIXEL= option, see “ODS
GRAPHICS Statement” on page 1561.
Syntax
CONTOURPLOTPARM X=numeric-column | expression
Y=numeric-column | expression
Z=numeric-column | expression </options>;
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
CONTOURPLOTPARM Statement 465
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
LINELABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the contour line labels.
LINELABELBASELINE=HORIZONTAL | TANGENT
specifies the text alignment of the contour line labels.
LINELABELFORMAT=format
specifies the format to use for the contour line labels.
LINELABELPOSITION=MIDDLE | BEGIN | END
specifies the position for the contour line labels.
Required Arguments
X=numeric-column | expression
specifies the X coordinates for the grid.
Y=numeric-column | expression
specifies the Y coordinates for the grid.
Z=numeric-column | expression
specifies the contour response values.
Optional Arguments
COLORMODEL=style-element | (color-list)
specifies a color ramp that is to be used to determine the colors of filled or
gradient contours.
style-element
specifies the name of a style element. The style element can contain these
style attributes:
(color-list)
specifies a space-separated list of colors to use in the color ramp.
466 Chapter 6 / Plot Statements
LINE
displays contour levels as unlabeled lines.
FILL
displays the area between the contour levels as filled.
GRADIENT
displays a smooth gradient of color to represent contour levels.
LINEFILL
combines the LINE and FILL types.
Each contour interval is filled with one color. Displays contour levels as
unlabeled lines.
LINEGRADIENT
combines the LINE and GRADIENT types.
LABELEDLINE
adds labels to the LINE type, displaying contour levels as labeled lines.
LABELEDLINEFILL
adds labels to the LINEFILL type.
Each contour interval is filled with one color. Displays contour levels as lines
with labels showing contour level values.
LABELEDLINEGRADIENT
adds labels to the LINEGRADIENT type.
Displays contour levels as lines with labels showing contour level values.
CONTOURPLOTPARM Statement 467
Interactions The fill colors of the types that enable FILL or GRADIENT are
controlled by the COLORMODEL= option.
GRIDDED=TRUE | FALSE
specifies whether the X and Y values are equally spaced in a rectangular grid. If
set to FALSE, then additional calculations are performed in order to complete
the grid.
For information about the algorithm used to calculate the grid, see “Mesoscale
Objective Map Analysis Using Weighted Time-Series Observations.”1
Default TRUE
1. Barnes, Stanley L March 1973. “Mesoscale Objective Map Analysis Using Weighted Time-Series Observations.” Technical
Memorandum (NOAA TM ERLNSSL-62), United States National Oceanic and Atmospheric Administration, Environmental
Research Labs, Norman, OK..
468 Chapter 6 / Plot Statements
the X-Y grid is not complete, then specify GRIDDED=FALSE so that the
plot calculates the values needed to complete the grid. Otherwise,
unexpected results might occur.
See “boolean ” on page xii for other Boolean values that you can use.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Default The Z-column label. If a label is not defined, then the Z-column
name is used.
LEVELS=(contour-value-list)
specifies a list of contour level values.
(contour-value-list)
a space-separated list of numeric values, enclosed in parentheses.
Default The number of levels and the level values are determined internally
using the NHINT= or NLEVELS= option value.
Notes Values that are outside of the data range are ignored.
When the LEVELS= option is not specified, the data range might be
extended in order to accommodate the internally computed levels.
Example The following example specifies six levels for a contour plot:
levels=(0.0001 0.0004 0.0007 0.0010 0.0013 0.0016)
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
LINELABELBASELINE=HORIZONTAL | TANGENT
specifies the text alignment of the contour line labels. Each contour line has a
precomputed label point.
HORIZONTAL
specifies that each label is parallel to the X axis.
The label intersects its contour line and is centered at the label point.
TANGENT
specifies that each label is drawn tangent to the contour line at the label
point.
This reduces intersection with the contour line and causes labels to be tilted
at various angles in relation to the X axis.
Default HORIZONTAL
LINELABELFORMAT=format
specifies the format to use for the contour line labels.
Default MIDDLE
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
indicate the colors associated with the Z values.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
470 Chapter 6 / Plot Statements
NHINT=integer
specifies the suggested number of contour levels for the Z column.
Default 7
NLEVELS=integer
specifies the actual number of contour levels for the Z column.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by either
the ODS style that is in effect or by the COLORMODEL= option.
Default FALSE
See COLORMODEL=
“boolean ” on page xii for other Boolean values that you can use.
CONTOURPLOTPARM Statement 471
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
A CONTOURPLOTPARM statement uses the CONTOURTYPE= option to specify
the type of contour plot to generate. Contour types that display fills or gradients
but no contour lines can use only a CONTINUOUSLEGEND statement to represent
the contour level values in a legend. Contour types that display lines can use either
a CONTINUOUSLEGEND or DISCRETELEGEND statement to identify contour level
values.
For filled or gradient contour types, small gaps might be visible between the axes
and the bounding box of the contour data. To eliminate these gaps, set the axis
options of the LAYOUT OVERLAY statement as follows:
XAXISOPTS=(OFFSETMIN=0 OFFSETMAX=0
LINEAROPTS=(THRESHOLDMIN=0 THRESHOLDMAX=0))
YAXISOPTS=(OFFSETMIN=0 OFFSETMAX=0
LINEAROPTS=(THRESHOLDMIN=0 THRESHOLDMAX=0))
Contour plots do not support the data tips that are enabled by the IMAGEMAP=
option in the ODS GRAPHICS statement.
Example Program
proc template;
define statgraph contourplotparm;
begingraph;
entrytitle "Contour Plot of Height and Weight";
layout overlay /
xaxisopts=(offsetmin=0 offsetmax=0
linearopts=(thresholdmin=0 thresholdmax=0))
yaxisopts=(offsetmin=0 offsetmax=0
linearopts=(viewmax=250
thresholdmin=0 thresholdmax=0));
contourplotparm x=height y=weight z=density /
contourtype=fill nhint=12
name="Contour" colormodel=twocolorramp;
continuouslegend "Contour" / title="Density";
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.gridded template=contourplotparm;
run;
DENDROGRAM Statement 473
DENDROGRAM Statement
Creates a tree diagram that is typically used to display the results of a hierarchical clustering
analysis.
Restriction: The DENDROGRAM statement does not support CAS in-memory tables. In SAS
9.4M6 and earlier releases, unexpected results might occur when data stored in a
CAS in-memory table is used. Starting with SAS Viya 3.5 and SAS Studio 5.2, the
dendrogram is dropped when data stored in a CAS in-memory table is used.
Syntax
DENDROGRAM NODEID=column | expression
PARENTID=column | expression
CLUSTERHEIGHT=numeric-column | expression </options>;
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
474 Chapter 6 / Plot Statements
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Required Arguments
NODEID=column | expression
specifies a column for the ID values of the nodes. Each node ID value must be
unique. If duplicate NODEID values are found, then the dendrogram is not
rendered . The column can be numeric or character, but it must be of the same
type and have the same formatted length as the ParentID column.
Note If the data is a SAS data set, the nodes are displayed in data order. If the
data is a CAS in-memory table, the nodes are displayed in ascending
order of the NODEID values by default.
PARENTID=column | expression
specifies a column for the parent ID values of the nodes. The column can be
numeric or character, but it must be of the same type and have the same
formatted length as the NodeID column.
CLUSTERHEIGHT=numeric-column | expression
specifies the column for the height values for each node.
DENDROGRAM Statement 475
Optional Arguments
CLUSTERS=numeric-column | expression
specifies a numeric column containing the resultant number of clusters at each
node.
Interaction For this option to take effect, the pruning options in the CUTOPTS=
option must set TYPE=NCLUSTERS and specify a number for the
NCLUSTERS= setting.
CUT=TRUE | FALSE
specifies whether the tree is to be cut.
Default FALSE
Tip To set the properties of the CUT, use the CUTOPTS= option.
See “boolean ” on page xii for other Boolean values that you can use.
CUTOPTS=(pruning-options)
specifies pruning options for cutting the dendrogram. The following pruning-
options must be specified as a space-separated list of option = value pairs
enclosed in parentheses.
CUTHEIGHT=number
specifies the height at which the tree is to be pruned.
NCLUSTERS=number
specifies the number of clusters to use for pruning the tree.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TYPE=CUTHEIGHT | NCLUSTERS
specifies which rule to use to prune the tree.
Default CUTHEIGHT
DATATRANSPARENCY=number
specifies the degree of the transparency of the dendrogram lines.
Default 0
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the dendrogram leaf axis.
Default VERTICAL
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
DENDROGRAM Statement 477
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a
dendrogram line. If this option is used, then it replaces all of the information
that is displayed by default.
(role-list)
an ordered, space-separated list of unique DENDROGRAM roles, which
include NODEID , PARENTID , and CLUSTERHEIGHT .
Example The following example displays data tips for the columns assigned
to the roles NODEID and PARENTID.
TIP=(NODEID PARENTID)
NONE
suppresses data tips from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
478 Chapter 6 / Plot Statements
Example TIPFORMAT=(CLUSTERHEIGHT=4.1)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example TIPLABEL=(CLUSTERHEIGHT="Height")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
TREETYPE=RECTANGULAR | TRIANGULAR
specifies the type of tree structure to draw.
Default RECTANGULAR
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
DENDROGRAM Statement 479
Details
A dendrogram is a tree diagram that is typically used to show the cluster
arrangements in hierarchical data. The DENDROGRAM statement supports clusters
with only a single root. If multiple roots are found in the data, then a warning is
written to the SAS log and the dendrogram is not drawn. The maximum number of
nodes that is supported by the DENDROGRAM statement is determined by the
DISCRETEMAX= option in the ODS GRAPHICS statement, which is 1000 by
default.
Using the DENDROGRAM statement in layouts where the axis ranges are merged
across cells might produce unexpected results.
Example Program
data clustree;
input id $ parent $7-12 height nClus;
480 Chapter 6 / Plot Statements
proc template;
define statgraph dendrogram;
begingraph;
layout overlay;
dendrogram nodeID=id parentID=parent clusterheight=height;
endlayout;
endgraph;
end;
run;
DENSITYPLOT Statement
Creates a univariate probability density curve computed from input data.
Requirement: If you include a histogram and a density plot in your graph and both plots specify
the same data column, you must either specify SCALE=DENSITY in the
HISTOGRAM statement or place the HISTOGRAM statement before the
DENSITYPLOT statement in your template code. Otherwise, the density plot
values might not scale properly to the histogram bins on the dependent axis. This
requirement applies even when the histogram and density plots are in different
cells in a multicell graph.
Tips: If the data density is not known, then use the KERNEL distribution option in the
DENSITYPLOT statement.
Starting with SAS 9.4M3, subpixel rendering is enabled by default. To disable
subpixel rendering, specify SUBPIXEL=OFF in the BEGINGRAPH statement or in an
ODS GRAPHICS statement. For information about the BEGINGRAPH statement
DENSITYPLOT Statement 481
SUBPIXEL= option, see SUBPIXEL= on page 39. For information about the ODS
GRAPHICS statement SUBPIXEL= option, see “ODS GRAPHICS Statement” on
page 1561.
Syntax
DENSITYPLOT numeric-column | expression </<distribution-option> <options>>;
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
CURVELABEL="string"
specifies a label for the density curve.
CURVELABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the density curve label.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the density curve label relative to the plot area.
CURVELABELPOSITION=AUTO | MAX | MIN | START | END
specifies the position of the density curve label relative to the curve line.
482 Chapter 6 / Plot Statements
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the curve label at the specified split characters.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the curve label can be split if
needed.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the curve label text.
CURVELABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the curve label
block.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a separate density curve for each unique group value in the
specified column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Statistics options
FREQ=numeric-column | expression
specifies a numeric column that provides frequencies for each
observation that is read.
WEIGHT=numeric-column | expression
specifies a column that contains a density-curve calculation a priori
weight for each observation of the input data object.
Required Arguments
numeric-column
specifies a numeric column of data values that are used to calculate the
parameters for the probability distribution.
expression
specifies an expression that calculates values when those values are not stored
in the data.
Optional Arguments
CURVELABEL="string"
specifies a label for the density curve.
Restriction This option is not valid when the GROUP= option is specified.
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the density curve label relative to the plot area.
INSIDE
locates the labels inside the plot area
OUTSIDE
locates the labels outside the plot area
Default INSIDE
AUTO
positions the density label automatically near the end of the density curve
along unused axes whenever possible (typically Y2 or X2) to avoid collision
with tick values.
MAX
forces the density label to appear near maximum density X-values (typically,
to the right).
484 Chapter 6 / Plot Statements
MIN
forces the density label to appear near minimum density X-values (typically,
to the left).
START
forces the density label to appear near the beginning of the curve.
Tip This option is particularly useful when the curve line has a spiral
shape.
END
forces the density label to appear near the end of the curve.
Tip This option is particularly useful when the curve line has a spiral
shape.
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the curve label at the specified split characters. When
a curve label is split, the label is split on each occurrence of the specified split
characters.
See “boolean ” on page xii for other Boolean values that you can use.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the curve label can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the curve label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no delimiter between each character and
enclosed in quotation marks.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the curve label text.
TRUE
drops the split characters from the curve label text.
FALSE
includes the split characters in the curve label text.
486 Chapter 6 / Plot Statements
The following figure shows an example of a curve label with the following
specifications:
n CURVELABELPOSITION=MAX
n CURVELABEL="Product*Group*A"
n CURVELABELSPLIT=TRUE
n CURVELABELSPLITCHARDROP=TRUE | FALSE
n CURVELABELSPLITCHAR="*"
Note: The horizontal line to the left of the label represents the maximum end of
the curve for reference.
Default TRUE. The split characters are dropped from the curve label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the CURVELABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The horizontal line to the left of each label represents the maximum end
of the curve for reference.
Default AUTO
DATATRANSPARENCY=number
specifies the degree of the transparency of the density curve and curve label.
Default 0
FREQ=numeric-column | expression
specifies a numeric column that provides frequencies for each observation that
is read.
Note If n is the value of the numeric column for a given observation, then
that observation is used n times for the purposes of any statistical
computation. The marker for that observation is drawn n times,
which increases the marker weight slightly with frequency.
discrete-attr-var
specifies a discrete attribute map variable.
Default Each distinct group value is represented in the plot by a different line
color and pattern. The line color is determined by the ContrastColor
attribute of the GraphData1–GraphDataN and GraphMissing style
elements. The line pattern is determined by the LineStyle attribute of
the GraphData1–GraphDataN and GraphMissing style elements.
Notes The group values are mapped in the order in which they appear in the
data.
If you specify a column in a SAS data set, the visual attributes for each
group value are assigned in data order. If you specify a column in a CAS
in-memory table, the visual attributes for each group value are
assigned in ascending order of the group column character values or of
unformatted numeric values.
Tips You can individually override the representations that are used to
identify the groups. For example, in some ODS styles, each distinct
group value is represented by a different line color and pattern. In that
case, you can use the PATTERN= setting on the LINEATTRS= option to
assign the same line pattern to all of the curves.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
DENSITYPLOT Statement 489
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the MISSING= system option changes the default missing
character, or a user-defined format is applied to the group value. In
those cases, the attributes of the missing group value are
determined by a GraphData1–GraphDataN style element instead of
by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis.
Default VERTICAL
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
490 Chapter 6 / Plot Statements
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example TIPFORMAT=(Y=6.2)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Requirement To enable data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example TIPLABEL=(Y="Curve")
Default The column label or column name of the column assigned to the role.
Note The columns assigned to the X and Y roles are automatically included
in the data tip information.
WEIGHT=numeric-column | expression
specifies a column that contains a density-curve calculation a priori weight for
each observation of the input data object.
Note The values of the weight variable must be greater than zero. If the
weight value for an observation is zero, negative, or missing, that
observation is deleted from the analysis.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Distribution Options
KERNEL (<C=positive-number> <WEIGHTFUNCTION=NORMAL | QUADRATIC |
TRIANGULAR> <MAXPOINTS=positive-integer>)
specifies a nonparametric kernel density estimate. By default, the kernel density
estimates are computed by minimizing the approximate mean integrated square
error (AMISE). It is the same method that the UNIVARIATE procedure uses to
compute kernel density estimates. The general form of the kernel density
estimator is as follows.
n
x − xi
fλ x =
100h %
nλ ∑ K0 λ
i=1
For more information about the kernel density estimate, see Kernel Density
Estimates in the UNIVARIATE procedure description in Base SAS Procedures
Guide: Statistical Procedures.
TIP Use the KERNEL distribution option when the data density is not
known.
492 Chapter 6 / Plot Statements
C=positive-number
specifies a positive number (0 < number <= 100) that represents the
standardized bandwidth.
Default Calculated from the data as the bandwidth that minimizes the
AMISE.
The following table shows the formulas for the weight functions.
NORMAL 1 1
K0 t = exp − 2 t2 for ‐∞ < t < ∞
2π
QUADRATIC 3
K0 t = 4 1 − t2 for t ≤ 1
TRIANGULAR K0 t = 1 − t for t ≤ 1
Default NORMAL
Note In prior SAS releases, the weight function was specified with the
WEIGHT= option. In SAS 9.4 and later releases, the WEIGHT=
option is not valid as a distribution option. You must use the
WEIGHTFUNCTION= option instead.
MAXPOINTS=positive-integer
specifies the maximum number of points generated for the curve.
Default 512
In the equation, μ is the mean and σ is the standard deviation (σ > 0). You can
specify μ with the MU= suboption and σ with the SIGMA= suboption. By default,
ODS estimates μ with the sample mean and σ with the sample standard
deviation.
For more information, see the discussion of Kernel Density Estimates for the
UNIVARIATE procedure in the documentation for Base SAS.
MU=number
specifies the mean.
SIGMA=number
specifies the standard deviation.
MAXPOINTS=positive-integer
specifies the maximum number of points generated for the curve.
Default 200
Details
A typical DENSITYPLOT statement specifies either the NORMAL or the KERNEL
distribution option. If no distribution option is specified, then the NORMAL() option
is used. The following syntax explicitly shows the default case:
DENSITYPLOT numeric-column / NORMAL()
If more than one distribution option is specified, then the last distribution option
specified is used.
494 Chapter 6 / Plot Statements
Examples
Example Program
When used as a standalone plot or overlaid with other density plots, the dependent
axis shows the computed density values.
proc template;
define statgraph densityplot1;
begingraph;
entrytitle "Fitted Density Curves";
entrytitle "of Patient Weight";
entryfootnote halign=left "Framingham Heart Study";
layout overlay;
densityplot weight / normal()
lineattrs=graphfit name="n" legendlabel="Normal";
densityplot weight / kernel()
lineattrs=graphfit2 name="k" legendlabel="Kernel";
discretelegend "n" "k";
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.heart template=densityplot1;
label weight="Patient Weight";
DENSITYPLOT Statement 495
run;
Example Program
proc template;
define statgraph densityplot2;
begingraph;
entrytitle "Patient Weight Distribution";
entrytitle "with Fitted Normal Curve";
entryfootnote halign=left "Framingham Heart Study";
layout overlay;
histogram weight / primary=true scale=count;
densityplot weight / normal() lineattrs=graphfit;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.heart template=densityplot2;
label weight="Patient Weight";
run;
496 Chapter 6 / Plot Statements
Example Program
proc template;
define statgraph densityplot;
begingraph;
entrytitle "Highway Mileage Distribution by Origin";
layout overlay /
xaxisopts=(griddisplay=on
gridattrs=(color=lightgray pattern=dot))
yaxisopts=(griddisplay=on
gridattrs=(color=lightgray pattern=dot));
densityplot mpg_highway / name="densityplot" group=origin;
discretelegend "densityplot" / title="Origin:";
endlayout;
endgraph;
end;
run;
DROPLINE Statement
Creates a horizontal or vertical drop line from a point to an axis.
Requirement: A DROPLINE statement must be used within a 2-D layout (for example, an
OVERLAY, OVERLAYEQUATED, DATALATTICE, or DATAPANEL layout).
DROPLINE Statement 497
Syntax
DROPLINE X=x-axis-value | column | expression
Y=y-axis-value | column | expression </options>;
Axes options
DISCRETEOFFSET=number
specifies an amount to offset all drop lines from discrete X values, or Y
values, or both.
DROPTO=X | Y | BOTH
specifies the axis to which the line is dropped.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
LABEL="string" | string-column
specifies a label for the point(s) indicated by the X= and Y= arguments.
LABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the drop line label(s).
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Required Arguments
X=x-axis-value | column | expression
specifies the X coordinate of the drop line(s).
Requirement Values must agree in type with the X-axis data type. For example,
you should use numeric SAS date or time values (or SAS date/time
constants) for a time axis.
Requirement Values must agree in type with the Y-axis data type.
Optional Arguments
CLIP=TRUE | FALSE
specifies whether the data for the line are considered when determining the
data ranges for the axes.
FALSE
specifies that the reference line values are to be considered when the axis
range is determined. The reference lines are drawn as follows based on the
axis type:
n For a discrete axis, the reference line values that are not already on the
axis are added to the end of the axis data list. When applicable, the axis
values are then sorted:
o If the axis values are numeric values, then they are sorted ordinally.
o If the axis values are character values and a sorting option is applied to
the axis, then they are sorted as specified by the sorting option.
Reference lines are then drawn at the specified locations.
n For a linear, log, or time axis, a new axis data list is created by performing
a mathematical union of the data values and the reference line values.
The reference lines are then drawn at the locations specified.
DROPLINE Statement 499
TRUE
specifies that the reference line values are not to be considered when the
axis range is determined. The reference lines are drawn as follows based on
the axis type:
n For a discrete axis, if the reference line value exactly matches a value on
the axis, then a reference line is drawn at that location. Otherwise, the
reference line is not drawn.
Note: If the axis values are formatted, then the reference line value must
exactly match the formatted axis value in order for the line to be drawn.
n For a linear, log, or time axis, if the reference line value is within the axis
data range, then the reference line is drawn at the specified location.
Otherwise, the reference line is not drawn.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Restriction Starting with SAS 9.4M1, the maximum number of skinned graphical
elements is limited to 200 per plot in an OVERLAY or PROTOTYPE
layout. When this limit is exceeded for a plot, the specified data skin
is not applied to that plot. In that case, use the DATASKINMAX=
option in your ODS GRAPHICS statement to increase the maximum
limit.
DATATRANSPARENCY=number
specifies the degree of the transparency of the drop line.
Default 0
DISCRETEOFFSET=number
specifies an amount to offset all drop lines from discrete X values, or Y values,
or both.
Default 0 (no offset, all drop lines are centered on discrete X values, or
discrete Y values, or both)
Range -0.5 to +0.5 where 0.5 represents half the distance between discrete
ticks. If the X axis is discrete, then a positive offset is to the right. If
the Y axis is discrete, then a positive offset is up. If REVERSE=TRUE
on the X or Y axis, then the offset direction is also reversed.
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
DROPTO=X | Y | BOTH
specifies the axis to which the line is dropped.
X
draws one or more droplines to an X axis.
Tip The XAXIS= option determines whether the X axis or X2 axis is the
endpoint for the line.
Y
draws one or more droplines to a Y axis.
Tip The YAXIS= option determines whether the Y axis or Y2 axis is the
endpoint for the line.
BOTH
draws one or more droplines to both axes.
Default X
LABEL="string" | string-column
specifies a label for the point(s) indicated by the X= and Y= arguments.
DROPLINE Statement 501
Interaction If drawing multiple drop lines using X=column or Y=column, then you
can assign corresponding labels by using a column to define the
labels.
Note Starting with SAS 9.4M1, space is reserved at the maximum end of
the X axis to accommodate the length of the labels regardless of
where the labels appear in the plot.
Tips You can use the OFFSETMAX= axis option to adjust the amount of
space that is reserved on the X axis for the labels.
The font and color attributes for the label are specified by the
LABELATTRS= option.
Interaction For this option to have any effect, the LABEL= option must also be
specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
502 Chapter 6 / Plot Statements
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Restriction Another plot that establishes a data range for the designed axis
must be included.
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Restriction Another plot that establishes a data range for the designed axis
must be included.
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
A drop line is always drawn perpendicular from the specified point to the X
(bottom), X2 (top), Y (left), or Y2 (right) axis. Axis offsets do not apply to drop
lines, so they always meet the axis line.
The DROPTO= option controls whether a horizontal or vertical drop line is created.
DROPTO=X specifies the horizontal axis for a vertical drop line, and DROPTO=Y
specifies the vertical axis for a horizontal drop line.
To generate both a vertical and a horizontal drop line from a single point, use
multiple DROPLINE statements.
DROPLINE Statement 503
Example Program
proc template;
define statgraph dropline;
begingraph;
entrytitle "Drop lines at Inflection Point";
layout overlay / yaxisopts=(linearopts=(viewmin=0));
seriesplot x=x y=y;
dropline x=3 y=5 / dropto=x
lineattrs=(color=blue pattern=dot) label="(3,5)";
dropline x=3 y=5 / dropto=y
lineattrs=(color=blue pattern=dot);
endlayout;
endgraph;
end;
run;
data test;
do X=0 to 8 by 0.25;
Y=(x-3)*(x-3) + 5;
output;
end;
504 Chapter 6 / Plot Statements
run;
ELLIPSE Statement
Creates a confidence ellipse computed from input data.
Syntax
ELLIPSE X=numeric-column | expression
Y=numeric-column | expression < /options >;
Axes options
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
ELLIPSE Statement 505
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a separate ellipse for each unique group value in the specified
column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Statistics options
ALPHA=positive-number
sets a significance value for the confidence level to compute for the
ellipse.
FREQ=numeric-column | expression
specifies a numeric column that provides frequencies for each
observation that is read.
TYPE=MEAN | PREDICTED
specifies the type of ellipse.
Required Arguments
X=numeric-column | expression
specifies the numeric column for the X values.
Y=numeric-column | expression
specifies the numeric column for the Y values.
Optional Arguments
ALPHA=positive-number
sets a significance value for the confidence level to compute for the ellipse.
Default 0.05
See TYPE=
506 Chapter 6 / Plot Statements
CLIP=TRUE | FALSE
specifies whether the data for the ellipse are considered when determining the
data ranges for the axes.
FALSE
the data for the ellipse contribute to the data range for each axis.
Each axis might be extended to force the display of the entire ellipse.
TRUE
the data for the ellipse are ignored when establishing axis scales.
Each axis scale is determined by the other plots in the parent layout. This
might result in the ellipse not being entirely displayed (clipped) if its data
range is not within the data ranges of the other plots.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
DATATRANSPARENCY=number
specifies the degree of the transparency of the ellipse fill color and outline.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
ellipse fill. You can combine this option with FILLATTRS= to set one
transparency for the ellipse outline but a different transparency for the
ellipse fill. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
OUTLINE
displays the ellipse outline
FILL
displays the ellipse fill color
FILLPATTERN
displays the ellipse fill pattern
Tip By default, this option has no effect if the active ODS style does
not specify a fill pattern. To display a fill pattern in that case,
select an ODS style that supports fill patterns or use the
ELLIPSE Statement 507
STANDARD
specifies OUTLINE only
ALL
specifies all features: FILL, FILLPATTERN, and OUTLINE
Interaction For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
Interaction For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS styles
such as HTMLBlue that use color-priority attribute rotation, specify
ATTRPRIORITY=NONE in an ODS GRAPHICS statement or in the
BEGINGRAPH statement in your graph template. For more
508 Chapter 6 / Plot Statements
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FREQ=numeric-column | expression
specifies a numeric column that provides frequencies for each observation that
is read.
Note If n is the value of the numeric column for a given observation, then
that observation is used n times for the purposes of any statistical
computation. The marker for that observation is drawn n times,
which increases the marker weight slightly with frequency.
discrete-attr-var
specifies a discrete attribute map variable.
A distinct ellipse is created for each group value by varying the visual attributes
of the ellipse display features. The display features are controlled by the current
ODS style or by the DISPLAY= option. The default group appearance for each
display feature is shown in the following table.
Display
Feature 1 Style Attributes That Control Default Group Appearance
Display
Feature 1 Style Attributes That Control Default Group Appearance
If the active ODS style does not specify FillPattern, fill patterns
are not displayed by default.
1 The default display features are determined by the DisplayOpts attribute of the GraphEllipse
style element.
2 Fill patterns are valid for ellipse plots starting with SAS 9.4M5.
Notes The group values are mapped in the order in which they appear in the
data.
If you specify a column in a SAS data set, the visual attributes for each
group value are assigned in data order. If you specify a column in a CAS
in-memory table, the visual attributes for each group value are assigned
in ascending order of the group column character values or of
unformatted numeric values.
Tips You can individually override the representations that are used to
identify the groups. For example, in some ODS styles, each distinct
group value is represented by a different line color and pattern. In that
case, you can use the PATTERN= setting on the OUTLINEATTRS= option
to assign the same line pattern to all of the ellipses.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the MISSING= system option changes the default missing
character, or a user-defined format is applied to the group value. In
those cases, the attributes of the missing group value are
510 Chapter 6 / Plot Statements
See “boolean ” on page xii for other Boolean values that you can use.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
Interaction For this option to have any effect, the outlines must be enabled by
the ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TYPE=MEAN | PREDICTED
specifies the type of ellipse.
MEAN
specifies a confidence ellipse of the mean
PREDICTED
specifies a prediction ellipse for a new observation
Default MEAN
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
Statement Description
The ELLIPSE statement can be used only within 2-D overlay-type layouts. It
computes an ellipse for a set of points specified by the X and Y columns and a
confidence level specified by the ALPHA= option. Use the TYPE= option to control
whether a predicted or confidence ellipse is generated.
Let Z and S be the sample mean and sample covariance matrix of a random sample
of size n from a bivariate normal distribution with mean μ and covariance matrix Σ.
The variable Z − μ is distributed as a bivariate normal variate with mean zero and
1
covariance ( n )Σ, and it is independent of S. Using Hotelling’s T 2 statistic, which is
defined as follows:
T 2 = n(Z − μ)′S−1(Z − μ)
Denote a new observation as the bivariate random variable Znew. The following
variable:
Znew − Z = (Znew − μ) − (Z − μ)
is distributed as a bivariate normal variate with mean zero (the zero vector) and
1
covariance (1 + n )Σ, and it is independent of S. A 100(1 − α) % prediction ellipse is
then given by the following equation:
n −1 2(n + 1)
n−1
(Z − μ)′S (Z − μ) = F
n − 2 2, n − 2
(1 − α)
The family of ellipses generated by different critical values of the F distribution has
a common center (the sample mean) and common major and minor axis directions.
The shape of an ellipse depends on the aspect ratio of the plot. The ellipse
indicates the correlation between the two variables if the variables are
standardized (by dividing the variables by their respective standard deviations). In
this situation, the ratio between the major and minor axis lengths is:
1+ r
1− r
Examples
Example Program
This example overlays two ELLIPSE statements on a SCATTERPLOT of the same
data. Both ELLIPSE statements use TYPE= PREDICTED. One ELLIPSE statement
uses ALPHA= 0.2, and the other uses ALPHA=0.05.
proc template;
define statgraph ellipse;
begingraph;
entrytitle "Prediction Ellipses";
layout overlayequated / equatetype=equate;
scatterplot x=petallength y=petalwidth /
datatransparency=0.5;
ellipse x=petallength y=petalwidth /
type=predicted alpha=0.2
name="p80" legendlabel="80%"
outlineattrs=graphconfidence;
ellipse x=petallength y=petalwidth /
type=predicted alpha=0.05
name="p95" legendlabel="95%"
outlineattrs=graphconfidence2;
discretelegend "p80" "p95" /
location=inside autoalign=(topleft);
endlayout;
entryfootnote halign=left "Fisher's Iris Data";
endgraph;
end;
run;
proc sgrender data=sashelp.iris template=ellipse;
run;
514 Chapter 6 / Plot Statements
Example Program
proc template;
define statgraph ellipsegroup;
begingraph;
entrytitle "95% Prediction By Species";
layout overlay;
scatterplot x=petallength y=petalwidth / name="sp"
group=species;
ellipse x=petallength y=petalwidth / group=species
type=predicted alpha=0.05 name="p95";
mergedlegend "sp" "p95" / location=inside
autoalign=(topleft) across=1;
endlayout;
endgraph;
end;
run;
ELLIPSEPARM Statement
Creates an ellipse specified by slope, axis, and origin parameters.
ELLIPSEPARM Statement 515
Syntax
ELLIPSEPARM SEMIMAJOR=number | numeric-column | expression
SEMIMINOR=number | numeric-column | expression
SLOPE=number | numeric-column | expression
XORIGIN=number | numeric-column | expression
YORIGIN=number | numeric-column | expression </options>;
Axes options
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
516 Chapter 6 / Plot Statements
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a separate ellipse for each unique group value of the specified
column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Required Arguments
SEMIMAJOR=number | numeric-column | expression
specifies half the length of the major axis for the ellipse. Values are in the same
units as the data. The SEMIMAJOR value can be greater than, smaller than, or
equal to the SEMIMINOR value.
Note The slope value is in the data space and might or might not be maintained
in the screen space. Thus, setting SLOPE=1 does not always generate a 45-
degree line on the screen.
Tip Setting SLOPE=0 creates a major axis parallel to the X axis. Setting
SLOPE=. (missing value) creates a major axis parallel to the Y axis.
Tip By default, if the value specified for the XORIGIN= option is outside of the
X-axis data range, then the data range is extended to include the specified
point. This behavior can be changed with the CLIP= option.
Tip By default, if the value specified for the YORIGIN= option is outside of the
Y-axis data range, then the data range is extended to include the specified
point. This behavior can be changed with the CLIP= option.
Optional Arguments
CLIP=TRUE | FALSE
specifies whether the data for the ellipse are considered when determining the
data ranges for the axes.
FALSE
The data for the ellipse contribute to the data range for each axis.
Each axis might be extended to force the display of the entire ellipse.
TRUE
The data for the ellipse are ignored when establishing axis scales.
Each axis scale is determined by the other plots in the parent layout. This
might result in the ellipse not being entirely displayed (clipped) if its data
range is not within the data ranges of the other plots.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
DATATRANSPARENCY=number
specifies the degree of the transparency of the ellipse fill color and outline.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
ellipse fill. You can combine this option with FILLATTRS= to set one
518 Chapter 6 / Plot Statements
transparency for the ellipse outline but a different transparency for the
ellipse fill. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
OUTLINE
displays the ellipse outline
FILL
displays a filled ellipse
FILLPATTERN
displays the ellipse fill pattern
Tip By default, this option has no effect if the active ODS style does
not specify a fill pattern. To display a fill pattern in that case,
select an ODS style that supports fill patterns or use the
FILLPATTERNATTRS= option to specify a fill pattern for the
ellipse.
STANDARD
displays OUTLINE only
ALL
displays all features: FILL, FILLPATTERN, and OUTLINE
Interaction For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
datatransparency=0.2 fillattrs=(transparency=0.6)
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
Interaction For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS styles
such as HTMLBlue that use color-priority attribute rotation, specify
ATTRPRIORITY=NONE in an ODS GRAPHICS statement or in the
BEGINGRAPH statement in your graph template. For more
information, see “Attribute Rotation Patterns” in SAS Graph
Template Language: User’s Guide.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
discrete-attr-var
specifies a discrete attribute map variable.
A distinct ellipse is created for each group value by varying the visual attributes
of the ellipse display features. The display features are controlled by the current
ODS style or by the DISPLAY= option. The default group appearance for each
display feature is shown in the following table.
520 Chapter 6 / Plot Statements
Display
Feature 1 Style Attributes That Control Default Group Appearance
1 The default display features are determined by the DisplayOpts attribute of the GraphEllipse
style element.
2 Fill patterns are valid for ellipse plots starting with SAS 9.4M5.
The representations that are used to identify the groups can be overridden
individually. For example, each distinct group value might be represented by a
different line pattern for the ellipses, but the PATTERN= suboption of the
OUTLINEATTRS= option could be used to assign the same line pattern to all
ellipse outlines, letting outline color distinguish group values.
Defaults If ellipse fills are enabled by the ODS style or by the DISPLAY=
option, then each distinct group value is represented in the plot by a
different fill color. Starting with SAS 9.4M5, each distinct group
value can be represented by a different fill pattern, with or without a
different fill color. The fill color and fill pattern are defined by the
Color and FillPattern attributes of the GraphData1–GraphDataN and
GraphMissing style elements.
Restriction When the GROUP= option is specified, the group value must be a
character or numeric column. For each group value, there must be a
numeric column that does not contain missing values for
SEMIMAJOR=, SEMIMINOR=, XORIGIN=, and YORIGIN=.The
SLOPE=column can contain missing values. Under these
circumstances, an ellipse is drawn for each group value.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
ELLIPSEPARM Statement 521
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping ellipse attributes (fill and outline) to one of the
GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
522 Chapter 6 / Plot Statements
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Restriction Another plot that establishes a data range for the designed axis
must be included.
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
ELLIPSEPARM Statement 523
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Restriction Another plot that establishes a data range for the designed axis
must be included.
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
The ELLIPSEPARM statement plots an ellipse with specified semimajor and
semiminor axis lengths, a specified slope for the major axis, and the ellipse center.
The ellipse center is the point of intersection of the semimajor and semiminor axes.
It can be used only within a two-dimensional overlay-type layout (for example, an
OVERLAY, OVERLAYEQUATED, or PROTOTYPE layout). The ELLIPSEPARM
statement does not perform computations on input data to derive the location and
shape of the ellipse. Another plot that is derived from data values that provide
boundaries for the axis area must be included in the layout. It is typically overlaid
with a scatter plot. See “ELLIPSE Statement” on page 504 for information about
computed ellipses.
Overview
This is a simplified version of the CorrLoadPlot template for PROC PLS in the
SAS/STAT product. It consists of overlaid scatter plots of the scores of the first
two factors, the loadings of the model effects, and the loadings of the dependent
variables. The loadings are scaled so that the amount of variation in the variables
that is explained by the model is proportional to the distance from the origin;
circles indicating various levels of explained variation are also overlaid.
The circles are drawn with ELLIPSEPARM statements by setting the SEMIMAJOR
and SEMIMINOR lengths to be the same. Notice that all circles are concentric
because they share the same origin (0,0). The radius of each circle is passed
dynamically.
Also note that an OVERLAYEQUATED layout was used to force the length of unit
intervals on both axes to be the same.
The input data shown is representative of that computed by the PLS procedure for
the Correlation Loadings Plot shown in the PLS procedure example Spectrometric
Calibration in SAS/STAT User’s Guide.
Example Program
Here is the SAS program for this example.
proc template;
define statgraph ellipseparm;
ELLIPSEPARM Statement 525
data corrplot;
infile cards missover dlm="#";
length CorrGroup $ 18 CorrLabel CorrLabel CircleLabel $ 8;
input Corr1 Corr2 CorrGroup CorrLabel xCircleLabel
yCircleLabel CircleLabel;
datalines;
-0.179 # -0.268 # Predictor Loading # S1 # 0 # 0.5 # 25%
0.105 # 0.332 # Predictor Loading # S2 # 0 # -0.5 # 25%
-0.654 # 0.094 # Predictor Loading # S3 # 0 # 0.707 # 50%
-0.653 # 0.685 # Predictor Loading # S4 # 0 # -0.707 # 50%
0.096 # 0.059 # Predictor Loading # S5 # 0 # 0.866 # 75%
0.132 # 0.036 # Predictor Loading # L1 # 0 # -0.866 # 75%
0.087 # 0.156 # Predictor Loading # L2 # 0 # 1 # 100%
0.940 # 0.160 # Predictor Loading # L3 # 0 # -1 # 100%
0.607 # -0.350 # Predictor Loading # L4
0.096 # 0.059 # Predictor Loading # L5
-0.111 # -0.534 # Predictor Loading # P1
0.003 # 0.256 # Predictor Loading # P2
0.293 # 0.551 # Predictor Loading # P3
-0.480 # 0.643 # Predictor Loading # P4
-0.096 # -0.059 # Predictor Loading # P5
0.946 # 0.279 # Response Loading # log_RAI
526 Chapter 6 / Plot Statements
FRINGEPLOT Statement
Creates a fringe plot on the X axis of an X-Y plot.
Syntax
FRINGEPLOT numeric-column | expression </options>;
Axes options
XAXIS=X | X2
FRINGEPLOT Statement 527
Label options
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a distinct set of lines for each unique group value of the specified
column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Required Argument
numeric-column | expression
specifies a column that provides the X coordinates of the data values.
Optional Arguments
DATATRANSPARENCY=number
specifies the degree of the transparency of the fringe.
Default 0
FRINGEHEIGHT=dimension
specifies the height of the fringe lines.
Default 10 px
528 Chapter 6 / Plot Statements
discrete-attr-var
specifies a discrete attribute map variable.
Interactions The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of colors and
line patterns.
Notes You can override the representations that are used to identify the
groups. For example, you can use the
LINEATTRS=(PATTERN=pattern) option to assign the same line
pattern to all of the plot’s line patterns, letting line color indicate
group values. Likewise, you can use LINEATTRS=(COLOR=color) to
assign the same color to all lines, letting line pattern indicate group
values.
If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
FRINGEPLOT Statement 529
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color and line pattern) to one of
the GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Default The X-column label. If a label is not defined, then the X-column
name is used.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined role X.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a fringe
line. If this option is used, then it replaces all of the information that is displayed
by default. Roles for columns that do not contribute to the fringe plot can be
specified along with roles that do.
role-list
an ordered, space-separated list of unique FRINGEPLOT and user-defined
roles.
Example The following example displays data tips for the columns assigned
to the roles X and Y, as well as the column Pct, which is not
assigned to any pre-defined FRINGEPLOT role. The Pct column
should appear first in the data tip:
ROLENAME=(TIP1=PCT)
TIP=(X TIP1)
NONE
suppresses data tips from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
532 Chapter 6 / Plot Statements
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Note The display of the fringe lines is always anchored on the X axis (at
the bottom of the plot area), even when the FRINGEPLOT’s X-
column data range is mapped to the X2 axis.
Details
In a FRINGEPLOT, each fringe line represents the location of the corresponding raw
data value on the X axis. All fringe lines are of equal length.
Example Program
proc template;
define statgraph fringeplot;
dynamic VAR VARLABEL;
begingraph;
entrytitle "Histogram and Fringeplot";
layout overlay / xaxisopts=(label=VARLABEL)
yaxisopts=(offsetmin=0.03);
fringeplot VAR / datatransparency=0.75
fringeheight=3pct;
histogram VAR;
endlayout;
endgraph;
end;
run;
HEATMAP Statement
Creates a plot of color-coded rectangles for the response variable of a pair of X and Y variables after
it bins the data in two dimensions.
534 Chapter 6 / Plot Statements
Syntax
HEATMAP X=numeric-column | expression
Y=numeric-column | expression </options>;
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot are used for determining
default axis features.
XAXIS=X | X2
HEATMAP Statement 535
Binning options
NXBINS=positive-integer
specifies the number of bins to use for the X role.
NYBINS=positive-integer
specifies the number of bins to use for the Y role.
XBINSIZE=positive-number
specifies the size of bins along the X role, in data units.
XBINSTART=number
specifies the data value for the first bin of the X role.
XBOUNDARY=UPPER | LOWER
specifies how an input value is counted when it lies on the endpoint of an
X bin.
XVALUES=MIDPOINTS | LEFTPOINTS | RIGHTPOINTS
specifies whether the XBINSTART= value represents the midpoint, lower
endpoint, or upper endpoint of the bin.
YBINSIZE=positive-number
specifies the size of bins along the Y role, in data units.
YBINSTART=number
specifies the data value for the first bin of the Y role.
YBOUNDARY=UPPER | LOWER
specifies how an input value is counted when it lies on the endpoint of an
Y bin.
YVALUES=MIDPOINTS | LEFTPOINTS | RIGHTPOINTS
specifies whether the YBINSTART= value represents the midpoint, lower
endpoint, or upper endpoint of the bin.
Data option
DISCRETEX=TRUE | FALSE
specifies whether the X axis is discrete when X= specifies a numeric
column.
DISCRETEY=TRUE | FALSE
536 Chapter 6 / Plot Statements
Statistics options
FREQ=numeric-column | expression
specifies a column for the frequency count for each observation in the
input data.
Required Arguments
X=column | expression
specifies the column for the X values.
Y=column | expression
specifies the column for the Y values.
Optional Arguments
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
HEATMAP Statement 537
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.
Tip To reverse the start and end colors of the ramp that is assigned to
the color model, use the REVERSECOLORMODEL= option.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
Use the COLORSTAT= option to specify the statistic to compute for the
COLORRESPONSE= column.
Default FREQ
See COLORRESPONSE=
FREQ=
WEIGHT=
DATATRANSPARENCY=number
specifies the degree of the transparency of the outline and fill for each region.
Default 0
Tip Use the FILLATTRS= option to set transparency for just the rectangle
fills. You can combine this option with FILLATTRS= to set one
transparency for the rectangle outlines and a different transparency for
the rectangle fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
DISCRETEX=TRUE | FALSE
specifies whether the X axis is discrete when X= specifies a numeric column.
Default FALSE
DISCRETEY=TRUE | FALSE
specifies whether the Y axis is discrete when Y= specifies a numeric column.
Default FALSE
HEATMAP Statement 539
display-options
a space-separated list of options, enclosed in parentheses.
STANDARD
displays the region fill color
ALL
displays the region fill color and outline
Default STANDARD
FILLATTRS=(TRANSPARENCY=number)
specifies the transparency of the interior fill area of the regions.
Tip Use this option when you want the region fill to have a different
degree of transparency than the outline.
FREQ=numeric-column | expression
specifies a column for the frequency count for each observation in the input
data.
NAME="string"
assigns a name to a HEATMAP statement for reference in other template
statements and log messages.
Restriction The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
NXBINS=positive-integer
specifies the number of bins to use for the X role. The system determines the
XBINSIZE= and XBINSTART= values if they are not specified. The bins always
span the range of the data.
Restriction The number of bins is the product of the X and Y bins. Starting
with SAS 9.4M4, the number of bins is limited to 100,000, by
default.
Tip Starting with SAS 9.4M4, the limit on the number of bins is
specified by the ODS GRAPHICS statement NXYBINSMAX=
option, which defaults to 100,000. See NXYBINSMAX= on page
1573.
NYBINS=positive-integer
specifies the number of bins to use for the Y role. The system determines the
YBINSIZE= and YBINSTART= values if they are not specified. The bins always
span the range of the data.
Restriction The number of bins is the product of the X and Y bins. Starting
with SAS 9.4M4, the number of bins is limited to 100,000, by
default.
Tip Starting with SAS 9.4M4, the limit on the number of bins is
specified by the ODS GRAPHICS statement NXYBINSMAX=
option, which defaults to 100,000. See NXYBINSMAX= on page
1573.
Interaction For this option to have any effect, outlines must be enabled by the
DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element value
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot are used for determining default
axis features.
Tip This option is needed only when there are two or more plots within
an overlay that contribute to a common axis. If PRIMARY=TRUE for
one of them, then that plot’s data columns are used to determine
the axis features, regardless of where this plot statement occurs
within the OVERLAY layout block.
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient that is specified by the ODS style that
is in effect or by the COLORMODEL= option.
Default FALSE
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a
rectangle. If this option is used, the specified information replaces all the
information that is displayed by default. You can specify roles for columns that
do not contribute to the bar chart along with roles that do.
(role-list)
an ordered, space-separated list of unique HEATMAP roles and user-defined
roles.
Example To display data tips for the columns assigned to the roles X and Y
as well as the user-defined role TIP1:
ROLENAME=(TIP1=OBS)
542 Chapter 6 / Plot Statements
TIP=(TIP1 X Y)
NONE
suppresses data tips and URLs (if requested) in the graph output.
Tip You can control the labels and formats for the TIP variables with
the TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns.
(role-format-list)
a space-separated list of role-name = format pairs.
Default The column format of the variable assigned to the role or BEST6. if
no format is assigned to a numeric column.
Requirement This option provides a way to control the formats of columns that
appear in data tips. Only the roles that appear in the TIP= option
are used.
TIPLABEL=(role-label-list)
specifies display labels for tip columns.
(role-label-list)
a space-separated list of role-name ="string" pairs.
Default The column label or column name of the variable assigned to the
role.
Requirement This option provides a way to control the labels of columns that
appear in data tips. Only the roles that appear in the TIP= option
are used.
WEIGHT=numeric-column
specifies a variable in the input data set that contains values to be used as a
priori weights for the colored-region calculations.
HEATMAP Statement 543
XAXIS=X | X2
specifies whether data is mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
XBINAXIS=TRUE | FALSE
specifies whether to use bins as the basis for x-axis tick marks. When this
option is FALSE, a standard axis is used, ignoring bin boundaries and midpoints.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
XBINSIZE=positive-number
specifies the size of bins along the X role, in data units. The system determines
the NXBINS= and XBINSTART= values if they are not specified. The bins always
span the X data range.
Tip Starting with SAS 9.4M4, you can use the ODS GRAPHICS
statement NXYBINSMAX= option to change the limit on the number
of bins. See NXYBINSMAX= on page 1573.
XBINSTART=number
specifies the data value for the first bin of the X role. The system determines
the NXBINS= and XBINSIZE= values if they are not specified. The bins always
span the X data range.
XBOUNDARY=UPPER | LOWER
specifies how an input value is counted when it lies on the endpoint of an X bin.
If this option is set to UPPER, then the value is counted as one of the values in
the upper bin. Otherwise, it is counted in the lower bin.
Default UPPER
XENDLABELS=TRUE | FALSE
specifies whether the X-axis ticks and tick values are placed at the bin end-
points or at the bin mid-points.
Default FALSE. The axis ticks and tick values are placed at the bin mid-
points.
Tip The axis ticks and tick value placements are independent of the
XVALUES= option.
XGAP=number
specifies the amount of horizontal space on either side of each color-coded
region in the heat map.
Default 0
Default MIDPOINTS
YAXIS=Y | Y2
specifies whether data is mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YBINAXIS=TRUE | FALSE
specifies whether to use bins as the basis for x-axis tick marks. When this
option is FALSE, a standard axis is used, ignoring bin boundaries and midpoints.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
YBINSIZE=positive-number
specifies the size of bins along the Y role, in data units. The system determines
the NYBINS= and YBINSTART= values if they are not specified. The bins always
span the Y data range.
Tip Starting with SAS 9.4M4, you can use the ODS GRAPHICS
statement NXYBINSMAX= option to change the limit on the number
of bins. See NXYBINSMAX= on page 1573.
546 Chapter 6 / Plot Statements
YBINSTART=number
specifies the data value for the first bin of the Y role. The system determines
the NYBINS= and YBINSIZE= values if they are not specified. The bins always
span the Y data range.
YBOUNDARY=UPPER | LOWER
specifies how an input value is counted when it lies on the endpoint of an Y bin.
If this option is set to UPPER, then the value is counted as one of the values in
the upper bin. Otherwise, it is counted in the lower bin.
Default UPPER
YENDLABELS=TRUE | FALSE
specifies whether the Y-axis ticks and tick values are placed at the bin end-
points or at the bin mid-points.
Default FALSE. The axis ticks and tick values are placed at the bin mid-
points.
Tip The axis ticks and tick value placements are independent of the
YVALUES= option.
YGAP=number
specifies the amount of horizontal space on either side of each color-coded
region in the heat map.
Default 0
Default MIDPOINTS
Example Program
proc template;
define statgraph heatmap;
begingraph;
entrytitle "Vehicle Mileage By Curb Weight";
layout overlay /
xaxisopts=(label="Curb Weight (LBS)");
heatmap x=weight y=mpg_city / name="heatmap"
nybins=11 ybinstart=10 ybinsize=5
nxbins=11 xbinstart=2000 xbinsize=500;
continuouslegend "heatmap" / title="Count"
location=outside;
endlayout;
endgraph;
end;
run;
HEATMAPPARM Statement
Creates a two-dimensional plot that represents the values of three variables. Generating an X, Y grid
of rectangles from the values of two independent variables, it colors the rectangles to represent the
values of a third variable, which can be a response variable or a group variable.
548 Chapter 6 / Plot Statements
Restriction: Starting with SAS 9.4M4, the number of bins is limited to 100,000. If the number of
bins exceeds the maximum, the heat map is not drawn. A warning message is
written to the SAS log in that case.
Requirements: The COLORGROUP= or the COLORRESPONSE= role must be specified.
The data for a parameterized heat map in a single-cell graph or in a cell in a
classification panel must have at least two bins for both the X and Y axes.
Otherwise, the heat map is not drawn.
Note: The data for a parameterized heat map should contain only one observation for
each X and Y value pair.
Tips: Starting with SAS 9.4M4, the limit on the number of bins is specified by the ODS
GRAPHICS statement NXYBINSMAX= option. The default value is 100,000. See
NXYBINSMAX= on page 1573.
Starting with SAS 9.4M3, you can use subpixel rendering with this statement. It is
enabled by default. To disable subpixel rendering, specify SUBPIXEL=OFF in the
BEGINGRAPH statement or in an ODS GRAPHICS statement. For information
about the BEGINGRAPH statement SUBPIXEL= option, see SUBPIXEL= on page 39.
For information about the ODS GRAPHICS statement SUBPIXEL= option, see “ODS
GRAPHICS Statement” on page 1561.
Syntax
HEATMAPPARM X=column | expression
Y=column | expression
COLORGROUP=column | discrete-attr-var | expression </options>;
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by
either the ODS style that is in effect or by the COLORMODEL= option.
XGAP=number
specifies the amount of horizontal space on either side of each filled
rectangle.
XVALUES=MIDPOINTS | LEFTPOINTS | RIGHTPOINTS
specifies whether the input X values represent midpoints, lower
endpoints, or upper endpoints of the bins.
YGAP=number
specifies the amount of vertical space on either side of each filled
rectangle.
YVALUES=MIDPOINTS | LEFTPOINTS | RIGHTPOINTS
specifies whether the input Y values represent midpoints, lower
endpoints, or upper endpoints of the bins.
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
XBINAXIS=TRUE | FALSE
specifies whether to use bins as the basis for X-axis tick marks.
XBOUNDARIES=(numeric-list)
specifies the boundaries of the X-value bins.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
YBINAXIS=TRUE | FALSE
specifies whether to use bins as the basis for Y-axis tick marks.
YBOUNDARIES=(numeric-list)
specifies the boundaries of the Y-value bins.
Data option
DISCRETEX=TRUE | FALSE
specifies whether the X axis is discrete when X= specifies a numeric
column.
DISCRETEY=TRUE | FALSE
specifies whether the Y axis is discrete when Y= specifies a numeric
column.
Label options
XENDLABELS=TRUE | FALSE
specifies whether the axis ticks and value labels are drawn at the
endpoints of the bins or midpoints of the bins.
YENDLABELS=TRUE | FALSE
specifies whether the axis ticks and value labels are drawn at the
endpoints of the bins or midpoints of the bins.
ODS options
URL=string-column
specifies an HTML page to display when a rectangle is selected.
Required Arguments
X=column | expression
specifies the column for the X values.
Y=column | expression
specifies the column for the Y values.
discrete-attr-var
specifies a discrete attribute map variable.
Note If you specify a column in a SAS data set, colors are mapped to
group values in data order. If you specify a column in a CAS in-
memory table, colors are mapped to group values in ascending
order of the group column character values or unformatted
numeric values.
range-attr-var
specifies a range attribute variable that is defined in a RANGEATTRVAR
statement.
When numeric-column or expression is specified, the colors for each region are
computed by mapping the values to a color ramp that is defined by the
COLORMODEL= option. When attr-variable is specified, the colors defined in
the associated RANGEATTRVAR or DISCRETEATTRVAR statement are used to
color the regions.
Optional Arguments
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.
Tip To reverse the start and end colors of the ramp that is assigned to
the color model, use the REVERSECOLORMODEL= option.
DATATRANSPARENCY=number
specifies the degree of the transparency of the filled rectangles.
Default 0
DISCRETEX=TRUE | FALSE
specifies whether the X axis is discrete when X= specifies a numeric column.
Default FALSE
DISCRETEY=TRUE | FALSE
specifies whether the Y axis is discrete when Y= specifies a numeric column.
Default FALSE
display-options
a space-separated list of options, enclosed in parentheses.
STANDARD
displays the region fill color
ALL
displays the region fill color and outline
Default STANDARD
FILLATTRS=(TRANSPARENCY=number)
specifies the transparency of the area fill in the rectangles.
554 Chapter 6 / Plot Statements
INCLUDEMISSINGCOLOR=TRUE | FALSE
specifies whether missing values of the color-group variable or of the color-
response variable are included in the plot.
Default TRUE
“boolean ” on page xii for other Boolean values that you can use.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction For this option to have any effect, outlines must be enabled by the
DISPLAY= option.
HEATMAPPARM Statement 555
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by either
the ODS style that is in effect or by the COLORMODEL= option.
Default FALSE
See COLORMODEL=
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles X, Y, COLORGROUP=, and
COLORRESPONSE=.
556 Chapter 6 / Plot Statements
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a filled
rectangle. If this option is used, then it replaces all of the information that is
displayed by default. Roles for columns that do not contribute to the heat map
can be specified along with roles that do.
(role-list)
an ordered, space-separated list of unique HEATMAPPARM and user-
defined roles. HEATMAPPARM roles include X and Y.
Example The following example displays data tips for the columns X and
PCT. The Pct column is not assigned to any pre-defined
HEATMAPPARM role, so it must first be assigned a role:
ROLENAME=(TIP1=PCT)
TIP=(X TIP1)
NONE
suppresses data tips from the plot.
Requirement To enable data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP variables can be controlled with
the TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
HEATMAPPARM Statement 557
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
URL=string-column
specifies an HTML page to display when a rectangle is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each rectangle that is to have an active link.
Example http://www.sas.com
Tips The URL value can be blank for some X and Y pairs. In that case, no
action is taken when the corresponding rectangle is selected.
The URL value can be the same for any X and Y pairs. In that case,
the same action is taken when the rectangle for those X and Y
pairs is selected.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
XBINAXIS=TRUE | FALSE
specifies whether to use bins as the basis for X-axis tick marks. When this
option is FALSE, a standard axis is used, ignoring bin boundaries and midpoints.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
XBOUNDARIES=(numeric-list)
specifies the boundaries of the X-value bins. The boundaries are specified as a
space-separated list of values enclosed in parentheses. The keywords MIN and
MAX can be used as one of the values in the list of boundaries. Keywords MIN
and MAX indicate the minimum and maximum data values for the X variable.
XENDLABELS=TRUE | FALSE
specifies whether the axis ticks and value labels are drawn at the endpoints of
the bins or midpoints of the bins.
Default FALSE. The axis ticks and values labels are drawn at the bin
midpoints.
Interactions If this option is set to FALSE, then the axis ticks and value labels
are drawn at the bin midpoints, regardless of whether the
XVALUES= option identifies the X data as endpoint values or
midpoint values.
See “boolean ” on page xii for other Boolean values that you can use.
XGAP=number
specifies the amount of horizontal space on either side of each filled rectangle.
Default 0
Default MIDPOINTS
See XENDLABELS=
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YBINAXIS=TRUE | FALSE
specifies whether to use bins as the basis for Y-axis tick marks. When this
option is FALSE, a standard axis is used, ignoring bin boundaries and midpoints.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
YBOUNDARIES=(numeric-list)
specifies the boundaries of the Y-value bins. The boundaries are specified as a
space-separated list of values enclosed in parentheses. The keywords MIN and
MAX can be used as one of the values in the list of boundaries. Keywords MIN
and MAX indicate the minimum and maximum data values for the Y variable.
Example:
yboundaries=(MIN 20 200 250 MAX)
YENDLABELS=TRUE | FALSE
specifies whether the axis ticks and value labels are drawn at the endpoints of
the bins or midpoints of the bins.
Default FALSE. The axis ticks and values labels are drawn at the bin
midpoints.
Interactions If this option is set to FALSE, then the axis ticks and value labels
are drawn at the bin midpoints, regardless of whether the
YVALUES= option identifies the Y data as endpoint values or
midpoint values.
See “boolean ” on page xii for other Boolean values that you can use.
YGAP=number
specifies the amount of vertical space on either side of each filled rectangle.
Default 0
Default MIDPOINTS
See YENDLABELS=
Details
A heat map is useful for visualizing the magnitude of a response variable in relation
to two independent variables. For example, in molecular biology, heat maps can be
used to track the expression of genes across multiple sample studies. In the
HEATMAPPARM statement, you specify the independent variables in the X and Y
arguments. For a response variable that has discrete values, use the COLORGROUP
argument, or for a response variable that has interval values, use the
COLORRESPONSE argument. For interval response variables, you can use the
COLORMODEL= option to define the color ramp that is used to fill the rectangles.
Example Program
proc template;
define statgraph heatmapparm;
begingraph;
layout overlay;
heatmapparm x=height y=weight colorresponse=count /
name="heatmapparm" xbinaxis=false ybinaxis=false;
continuouslegend "heatmapparm" / location=outside
valign=bottom;
endlayout;
endgraph;
end;
run;
HIGHLOWPLOT Statement
Creates a display of floating vertical or horizontal lines or bars that connect the minimum and
maximum response values for each value of a categorical variable.
Requirements: Either the X= or Y= argument must be specified, but you cannot specify both on the
same HIGHLOWPLOT statement.
The HIGH= and LOW= arguments are required.
562 Chapter 6 / Plot Statements
Note: Specifying the X= option creates a vertical high-low chart, which would typically be
used in the financial industry to plot stock values over time. Specifying the Y=
option creates a horizontal high-low chart, which would typically be used in the
Health and Life Sciences industry to display over time the duration of adverse
events or of adverse reactions to medication.
Tips: For charts that have a large number of bars that are very close together, slight
variations in spacing that normally occur due to integer rounding can become more
obvious. Subpixel rendering provides more precise bar spacing in that case. In SAS
9.4M2 and in earlier releases, specify SUBPIXEL=ON in the BEGINGRAPH
statement to enable subpixel rendering. See SUBPIXEL= on page 39. Starting with
SAS 9.4M3, subpixel rendering is enabled by default.
To disable subpixel rendering in SAS 9.4M3 and in later releases, specify
SUBPIXEL=OFF in the BEGINGRAPH statement or in an ODS GRAPHICS
statement. For information about the BEGINGRAPH statement SUBPIXEL= option,
see SUBPIXEL= on page 39. For information about the ODS GRAPHICS statement
SUBPIXEL= option, see “ODS GRAPHICS Statement” on page 1561.
Syntax
HIGHLOWPLOT X=column | expression
LOW=numeric-column | expression
HIGH=numeric-column | expression < /options >;
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
564 Chapter 6 / Plot Statements
Label options
HIGHLABEL=column | expression
specifies the label to display at the high end of the bar or line.
LABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the labels for the bars or lines.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
LOWLABEL=column | expression
specifies the label to appear at the low end of each floating bar or line.
Midpoint options
DISCRETEOFFSET=number
specifies an amount to offset all bars or lines from the category
midpoints when graphing multiple response variables side by side on a
common axis.
GROUP=column | discrete-attr-var | expression
creates a distinct set of floating bars or lines for each unique group value
in the specified column.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies whether grouped bars or lines are overlaid or clustered around
the category midpoints.
GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
specifies the ordering of the groups within a category.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Required Arguments
Either the X= or Y= argument must be specified, but you cannot specify both on the same
HIGHLOWPLOT statement. The HIGH= and LOW= arguments are required.
X=column | expression
specifies a column or expression representing the values in a vertical high-low
chart. The values can be character or numeric.
Y=column | expression
specifies a column or expression representing the values in a horizontal high-
low chart. The values can be character or numeric.
LOW=numeric-column | expression
specifies a column or expression representing the values of the lower end of the
floating bar or line.
HIGH=numeric-column | expression
specifies a column or expression representing the values of the higher end of
the floating bar or line.
Optional Arguments
BARWIDTH=number
specifies the width of a bar as a ratio of the maximum possible width.
Default 0.85
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
Interaction Prior to SAS 9.4M3, this option is ignored for an interval high-low
plot, and the bar width is controlled by the INTERVALBARWIDTH=
option. Starting with SAS 9.4M3, this option is honored for an
interval high-low plot but it can be overridden by the
INTERVALBARWIDTH= option.
CLIPCAP=TRUE | FALSE
specifies whether a special clip cap is displayed to indicate where clipping
occurred. When the VIEWMIN= and VIEWMAX= axis options are specified for
an axis and a data value exceeds the specified axis range, the bar for that value
is clipped. In that case, when CLIPCAP=TRUE, a special clip cap is displayed at
the clipped end of the bar. If the bar already has a high or low cap, then it is
replaced by the clip cap.
566 Chapter 6 / Plot Statements
For vertical bars, the clip cap is added to the end of the bar that is clipped by the
Y-axis range. The default clip cap is a vertical clipped arrowhead that points
toward the clip edge ( or ). For horizontal bars, the cap is added to the end of
the bar that is clipped by the X-axis range. The default clip cap is a horizontal
clipped arrowhead that points toward the clip edge ( or ). If an entire bar is
clipped, then a clip cap is displayed at the high or low side where the bar was
clipped.
The first graph shows the default case in which no clipping occurs. The second
graph shows the case in which VIEWMIN= and VIEWMAX= specify a range that
causes clipping on the Y axis. In the second graph, the clip caps indicate clipping
for each category line as follows:
Default FALSE
Interaction Clip caps appear only when CLIPCAP=TRUE and the data values
exceed the axis range that is specified by the VIEWMIN= and
VIEWMAX= options. When the VIEWMIN= and VIEWMAX= options
are not specified, the axis range is adjusted to accommodate the
data values and clipping does not occur.
Note If the HIGHLABEL= and LOWLABEL= options are in effect and the
bar is clipped, then the label value at the clipped end is drawn at the
tip of the clip cap. If the entire bar is clipped, then the labels are not
shown.
HIGHLOWPLOT Statement 567
See “boolean ” on page xii for other Boolean values that you can use.
In SAS 9.4M1 and earlier releases, this option specifies the arrowhead shape
only for the clipped end of clipped lines (TYPE=LINE). For bars (TYPE=BAR),
this option is ignored, and CLIPPEDARROW is always used as the arrowhead
shape for the clipped end of clipped bars.
Starting with SAS 9.4M2, this option specifies the arrowhead shape for the
clipped end of clipped lines or clipped bars. For bars, you can specify the
CLIPPEDARROW shape for filled and unfilled bars. When any value other than
CLIPPEDARROW or DEFAULT is specified for bars, the FILLEDARROW shape is
used for filled bars, and the CLOSEDARROW shape is used for unfilled bars.
CLOSE=numeric-column | expression
specifies a column or expressions whose values are used to display a closing-
value indicator. This option is typically used when TYPE=LINE, but it can be
used when TYPE=BAR. For vertical high-low charts, the value is represented by
a short horizontal line extending from the side that displays the higher X values.
For horizontal high-low charts, the value is represented by a short vertical line
extending from the side that displays the higher Y values.
CLUSTERWIDTH=number
on a discrete axis, specifies the width of the group clusters as a fraction of the
midpoint spacing. On an interval axis, specifies the width of the group clusters
as a fraction of the minimum interval between adjacent data values.
568 Chapter 6 / Plot Statements
Default 0.85
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
Interaction For this option to take effect, the GROUP= option must also be
specified, and the GROUPDISPLAY= option must be set to
CLUSTER.
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
Restriction Starting with SAS 9.4M1, the maximum number of skinned graphical
elements is limited to 200 per plot in an OVERLAY or PROTOTYPE
layout. When this limit is exceeded for a plot, the specified data
skin is not applied to that plot. In that case, use the
DATASKINMAX= option in your ODS GRAPHICS statement to
increase the maximum limit.
DATATRANSPARENCY=number
specifies the degree of the transparency of the colored regions, and the high-
end and low-end labels.
Default 0
Tip The FILLATTRS option can be used to set transparency for just the
colored regions. You can combine this option with FILLATTRS= to set
one transparency for the outlines but a different transparency for the
region fills . Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
DISCRETEOFFSET=number
specifies an amount to offset all bars or lines from the category midpoints when
graphing multiple response variables side by side on a common axis.
HIGHLOWPLOT Statement 571
Default 0 (no offset, all bars or lines are centered on the category
midpoints)
Range –0.5 to +0.5, where 0.5 represents half the distance between
category ticks. Normally, a positive offset is to the right for a vertical
plot and up for a horizontal plot. (If the layout's axis options set
REVERSE=TRUE, then the offset direction is also reversed.)
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
FILL
displays the bar fill color
OUTLINE
displays the bar outline
FILLPATTERN
displays the bar fill pattern
Tip By default, this option has no effect if the active ODS style does
not specify a fill pattern. To display a fill pattern in that case,
select an ODS style that supports fill patterns or use the
FILLPATTERNATTRS= option to specify a fill pattern for the bars.
STANDARD
specifies FILL and OUTLINE
ALL
specifies all features: FILL, FILLPATTERN, and OUTLINE
ENDCAPDISPLAYPOLICY=AUTO | ALWAYS
specifies the policy for displaying end caps when end caps are present.
AUTO
draws the end caps only for the elements with a low-to-high range that is
large enough to accommodate the end caps.
ALWAYS
always draws the end caps.
Note When the low-to-high range is not large enough for the end caps, the
end caps might overlap. The data ranges that are smaller than the
end-cap size might not be resolvable beyond the rendered size of the
end caps.
Default AUTO
Interactions This option is honored only when the option TYPE=LINE is in effect.
Interactions For this option to take effect, TYPE=BAR must also be specified,
and the DISPLAY= option must allow the fill to be displayed.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
Interactions For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS
styles such as HTMLBlue that use color-priority attribute rotation,
specify ATTRPRIORITY=NONE in an ODS GRAPHICS statement or
in the BEGINGRAPH statement in your graph template. For more
information, see “Attribute Rotation Patterns” in SAS Graph
Template Language: User’s Guide.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
discrete-attr-var
specifies a discrete attribute map variable.
When TYPE= on page 583LINE (default), combinations of line color and line
style are used to create a distinct line for each group value. The ContrastColor
574 Chapter 6 / Plot Statements
When TYPE=BAR, a distinct bar is created for each group value by varying the
visual attributes of the bar display features. The display features are controlled
by the current ODS style or by the DISPLAY= option. The default group
appearance for each display feature is shown in the following table.
Display
Feature 1 Style Attributes That Control Default Group Appearance
Interactions If the X or Y role is discrete, then the bars or lines representing the
group can be drawn in a cluster or overlaid, based on the setting for
the GROUPDISPLAY= option. However, if the X or Y role is interval,
then the lines representing the group are overlaid and the
GROUPDISPLAY= option is ignored.
By default, the group values are mapped in the order of the data.
Use the GROUPORDER= option to control the sorting order of the
grouped bar segments. Use the INDEX= option to alter the default
sequence of colors and line patterns.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
Tips The representations that are used to identify the groups can be
overridden. For example, if each distinct group value is represented
by a different line pattern, you can use the
LINEATTRS=(PATTERN=pattern) specification to assign the same
line pattern to all the plot lines. In that case, the line color denotes
group values. Likewise, you can use LINEATTRS=(COLOR=color) to
assign the same color to all lines, letting line pattern denote group
values.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies whether grouped bars or lines are overlaid or clustered around the
category midpoints.
OVERLAY
centers the bars or lines for matching category values on the midpoints.
The bars or lines in each set of group values are superimposed on each other.
CLUSTER
clusters the bars or lines for matching category values around the midpoints.
Each cluster of group values is centered at the midpoint for the category.
The following example shows the effect of clustering the lines in a stock report
when the category values are grouped into a single response variable. Note that
if your category values are not grouped in the same column but are stored in
separate columns, then you can get this same effect by using the
DISCRETEOFFSET= option.
layout overlay /
yaxisopts=(label="Stock Value");
highlowplot x=month high=high low=low /
close=close open=open
legendlabel="Stock" name="cluster"
group=stock groupdisplay=cluster
lineattrs=(pattern=solid);
discretelegend "cluster" / title="Stock"
location=inside halign=right valign=top;
endlayout;
576 Chapter 6 / Plot Statements
Default OVERLAY
Interaction For this option to take effect, the GROUP= option must also be
specified.
Note When you plot a SAS data set, the items for each group value are
drawn in data order. When you plot a CAS in-memory table, they are
drawn in ascending order of the group column character values or
unformatted numeric values.
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Tip This option is useful when you want to reverse the category axis.
ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.
Interactions This option is ignored if the GROUP= option is not also specified.
HIGHLOWPLOT Statement 577
By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.
Notes When plotting a SAS data set, attributes such as color, symbol, and
pattern are assigned to each group in DATA order by default. When
plotting a CAS in-memory table, attributes are assigned in
ascending order of the group column character values or
unformatted numeric values by default.
In SAS 9.4M6 and earlier releases, when data stored in a CAS in-
memory table is used and DATA or REVERSEDATA is specified,
unpredictable results might occur. To generate consistent graphs in
that case, specify ASCENDING or DESCENDING. Starting with SAS
Viya 3.5 and SAS Studio 5.2, when data stored in a CAS in-memory
table is used and DATA or REVERSEDATA is specified, it is ignored,
and ASCENDING is used instead.
The following figure shows the effect of each cap value on horizontal lines,
filled bars, and unfilled bars.
578 Chapter 6 / Plot Statements
Figure 6.1 Horizontal High and Low Cap Shapes for Lines, Filled Bars, and
Unfilled Bars
Default NONE
Interaction When TYPE=BAR, the caps are drawn to fit within the bar width.
The width of the bar itself is reduced.
Note If the length of the high-low element is smaller than the cap, then
the cap is not drawn.
HIGHLABEL=column | expression
specifies the label to display at the high end of the bar or line.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color and line pattern) or bar
attributes (fill and outline) to one of the GraphData1–GraphDataN style
elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped
according to the setting of the GROUPORDER= option.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
INTERVALBARWIDTH=dimension
specifies the width of the floating bars.
Defaults Prior to SAS 9.4M3, 85% of the smallest interval between any two
bars for the given plot
Restriction For this option to take effect, TYPE=BAR must be set, and the
independent variable must be of type interval.
Interaction Prior to SAS 9.4M3, this option controls the bar width for a high-low
plot. Starting with SAS 9.4M3, this option overrides the
BARWIDTH= option.
Tip The bar width that you specify with this option is honored even if
the bars overlap. If the bars overlap, reduce the interval bar width or
use the BARWIDTH= option instead.
Defaults In SAS 9.4M2 and earlier releases, the GraphDataText style element.
See “General Syntax for Attribute Options” on page 1599 for the syntax for
using a style-element.
580 Chapter 6 / Plot Statements
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Interaction For this option to have any effect, TYPE= LINE must also be
specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Figure 6.4 on page 578 shows the effect of each cap value on horizontal lines,
filled bars, and unfilled bars.
Default NONE
Interaction When TYPE=BAR, the caps are drawn to fit within the bar width.
The width of the bar itself is reduced.
Note If the length of the high-low element is smaller than the cap, then
the cap is not drawn.
LOWLABEL=column | expression
specifies the label to appear at the low end of each floating bar or line.
HIGHLOWPLOT Statement 581
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
OPEN=numeric-column | expression
specifies a column or expressions whose values are used to display an opening-
value indicator. This option is typically used when TYPE=LINE, but it can be
used when TYPE=BAR. For vertical high-low charts, the value is represented by
a short horizontal line extending from the side that displays the lower X values.
For horizontal high-low charts, the value is represented by a short vertical line
extending from the side that displays the lower Y values.
Interactions For this option to have any effect, TYPE=BAR must be specified,
and outlines must be enabled by the ODS style or the DISPLAY=
option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
582 Chapter 6 / Plot Statements
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles X, Y, LOW, HIGH, OPEN, and CLOSE.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a bar or
line. If this option is used, then the information specified replaces all of the
information that is displayed by default. You can specify roles for columns that
do not contribute to the bar chart along with roles that do.
(role-list)
an ordered, space-separated list of unique HIGHLOWPLOT and user-defined
roles.
Example The following example displays data tips for the columns X and
Pct. The Pct column is not assigned to any pre-defined
HIGHLOWPLOT role, so it must first be assigned a role.
ROLENAME=(TIP1=PCT)
TIP=(X TIP1)
NONE
suppresses data tips from the plot.
HIGHLOWPLOT Statement 583
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement with the IMAGEMAP option specified,
and you must write the output to the ODS HTML destination.
Tip You can control the labels and formats for the TIP roles with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TYPE=LINE | BAR
specifies whether data values should be represented by bars or lines.
584 Chapter 6 / Plot Statements
BAR
uses fill and outline attributes.
LINE
uses line attributes.
Default LINE
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
Statement Description
A high-low chart specifies that floating vertical or horizontal lines or bars connect
the minimum and maximum response values for each value of a categorical
variable. The data should have at least two response values for every category
value. Otherwise, the single value is displayed without the connecting line or bar. In
the statement syntax, the X and Y arguments can specify a column with character
or numeric values. The LOW and HIGH arguments must specify a numeric column.
The HIGHLOWPLOT statement can be used to create a plot showing the high and
low response values for observations along a time axis. The independent variable
can be interval or discrete. The HIGHLOWPLOT has two common uses:
n One typical use of a high-low chart is in the financial industry to plot stock
values by day. The OPEN= and CLOSE= options are typically used in the plot,
HIGHLOWPLOT Statement 585
and the TYPE= option is set to LINE (the default), as illustrated in “Example 1:
Vertical High-low Chart” on page 586 .
n Another typical use of a high-low chart is in the Health and Life Sciences
industry to display over time the duration of adverse events or of adverse
reactions to medication. The HIGHCAP= and LOWCAP= options are typically
used in the plot, and the TYPE= option is set to BAR, as illustrated in “Example
2: Horizontal High-low Chart” on page 587 .
For both vertical and horizontal high-low charts, the data values can be grouped
using the GROUP= option. For grouped data, the data values are not summarized.
Each observation is plotted independently, and the line or bar segment for each
category value can use different display characteristics.
If you prefer to avoid superimposed bars or lines, then you can assign a different
offset to each HIGHLOWPLOT statement. If desired, you can adjust the width of
the bar or line in conjunction with DISCRETEOFFSET= to create narrower bars that
require less width within the plot area.
The following example defines offsets for the lines in a stock report:
layout overlay / cycleattrs=true
yaxisopts=(label="Stock Value");
highlowplot x=month high=a_high low=a_low /
close=a_close open=a_open
legendlabel="A" name="ahighlow" lineattrs=(pattern=solid)
discreteoffset=-0.2 ;
highlowplot x=month high=b_high low=b_low /
close=b_close open=b_open
legendlabel="B" name="bhighlow" lineattrs=(pattern=solid)
discreteoffset=0 ;
highlowplot x=month high=c_high low=c_low /
close=c_close open=c_open
legendlabel="C" name="chighlow" lineattrs=(pattern=solid)
discreteoffset=+0.2 ;
discretelegend "ahighlow" "bhighlow" "chighlow" / title="Stock"
location=inside halign=right valign=top;
endlayout;
586 Chapter 6 / Plot Statements
Examples
Example Program
proc template;
define statgraph highlow;
begingraph;
layout overlay /
yaxisopts=(griddisplay=on label="Stock Value");
highlowplot x=date high=high low=low /
open=open close=close;
endlayout;
endgraph;
end;
Example Program
data highlowbar;
length cap $ 12;
input drug $ 1-10 low high cap $;
datalines;
588 Chapter 6 / Plot Statements
Drug A 10 20 NONE
Drug A 30 60 FILLEDARROW
Drug B 20 35 NONE
Drug B 50 75 FILLEDARROW
Drug C 30 90 FILLEDARROW
;
proc template;
define statgraph highlowbar;
begingraph;
entrytitle 'Medications Plot';
layout overlay /
xaxisopts=(
griddisplay=on
linearopts=(viewmin=0 viewmax=100)
display=(line ticks tickvalues))
yaxisopts=(
griddisplay=on
display=(line ticks tickvalues));
highlowplot y=drug high=high low=low /
group=drug outlineattrs=(pattern=solid)
datatransparency=0.4
type=bar barwidth=0.4
highcap=cap lowcap=cap;
endlayout;
endgraph;
end;
HISTOGRAM Statement
Creates a univariate histogram computed from input data.
Requirement: If you include a histogram and a density plot in your graph and both plots specify
the same data column, you must either specify SCALE=DENSITY in the
HISTOGRAM statement or place the HISTOGRAM statement before the
DENSITYPLOT statement in your template code. Otherwise, the density plot
values might not scale properly to the histogram bins on the dependent axis. This
requirement applies even when the histogram and density plots are in different
cells in a multicell graph.
Note: When a histogram is placed on a log axis, binning is done on a linear scale, but the
bins are drawn on the log scale. As a result, the bins might have different widths
along the log axis.
Syntax
HISTOGRAM numeric-column | expression </options>;
HISTOGRAM Statement 589
Axes options
BINAXIS=TRUE | FALSE
specifies whether to use bins as the basis for the axis tick marks.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
SCALE=PERCENT | COUNT | PROPORTION | DENSITY
specifies the scale for the Y axis.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
590 Chapter 6 / Plot Statements
Label options
DATALABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the bar labels.
DATALABELTYPE=NONE | AUTO | COUNT | DENSITY | PERCENT |
PROPORTION
specifies the statistic to display at the end of each bar.
ENDLABELS=TRUE | FALSE
specifies whether the axis ticks and value labels are drawn at the bin
endpoints (TRUE) or at the bin midpoints (FALSE).
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a separate bar segment or bar for each unique group value in the
specified column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Statistics options
FREQ=numeric-column | expression
specifies a numeric column that provides frequencies for each
observation that is read.
WEIGHT=numeric-column | expression
specifies a column that contains a bin-width calculation a priori weight
for each observation of the input data object.
Required Argument
numeric-column | expression
specifies a column that contains numeric values, or a dynamic variable that
refers to such a column.
Optional Arguments
BINAXIS=TRUE | FALSE
specifies whether to use bins as the basis for the axis tick marks.
HISTOGRAM Statement 591
TRUE
specifies that the ENDLABELS= option determines how the axis ticks and
value labels are displayed.
FALSE
specifies that standard axes are used. Bin boundaries and midpoints that are
set by the ENDLABELS= option are ignored.
Default TRUE
Interactions This option is ignored when this histogram is not the primary plot.
For more information about primary plots, see “When Plots Share
Data and a Common Axis” on page 1046.
When this option is set to TRUE, some X-axis options that are set
on the parent layout might not apply, such as INTEGER=,
TICKVALUELIST=, TICKVALUESEQUENCE=, and
INCLUDERANGES=.
“boolean ” on page xii for other Boolean values that you can use.
BINSTART=number
specifies the X coordinate of the first bin. This option can be used with the
BINWIDTH= and NBINS= options to specify the bins.
Note If the BINSTART= value is less than the minimum data value, then
the lower end of the histogram might be padded with zero-height
bins in order to accommodate the BINSTART= value.
See XVALUES=
BINWIDTH=positive-number
specifies the bin width. This option can be used with the BINSTART= and
NBINS= options to specify the bins.
Interaction This option is ignored when the NBINS= option is also specified
(with or without the BINSTART= option) and the resulting data
592 Chapter 6 / Plot Statements
range does not completely span the unbinned input data range. In
that case, the NBINS= option is honored and the default bin width is
used instead.
Note When BINSTART=, NBINS=, or both are specified with this option
and the resulting data range is greater than the unbinned input data
range, the histogram might be padded with zero-height bins in order
to accommodate the BINSTART=, NBINS=, and BINWIDTH= option
values.
Tip Starting with SAS 9.4M4, the limit on the number of bins is specified
by the ODS GRAPHICS statement NBINSMAX= option. The default
value is 10,000. See NBINSMAX= on page 1573.
BOUNDARY=UPPER | LOWER
specifies how a boundary is counted when it lies on the endpoint of a bin. If this
option is set to UPPER, then the value is counted as one of the values in the
upper bin (the bin to the right). Otherwise, it is counted in the lower bin.
Default UPPER
Interactions The DATALABEL= option must be specified for this option to have
any effect.
When text options are specified, any font properties that are not
specified (color, family, size, weight, and style) are derived from the
GraphDataText style element.
NONE
suppresses the data labels.
AUTO
uses the SCALE= option value. By default, SCALE=PERCENT.
COUNT
DENSITY
PERCENT
PROPORTION
specifies that the count, density, percentage, or proportion statistic is to be
displayed at the end of each bar.
Default NONE
Requirement For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
When a data skin is applied, all bar outlines are set by the skin, and
the OUTLINEATTRS= option is ignored.
594 Chapter 6 / Plot Statements
DATATRANSPARENCY=number
specifies the degree of the transparency of the bar fills and bar outlines.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
bar fills. You can combine this option with FILLATTRS= to set one
transparency for the bar outlines but a different transparency for the
bar fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
FILL
displays the bar fill color
FILLPATTERN
displays the bar fill pattern
OUTLINE
displays the bar outline
STANDARD
specifies FILL and OUTLINE
ALL
specifies all features: FILL, FILLPATTERN, and OUTLINE
ENDLABELS=TRUE | FALSE
specifies whether the axis ticks and value labels are drawn at the bin endpoints
(TRUE) or at the bin midpoints (FALSE).
Default FALSE.
Interactions This option is ignored if this plot is not the primary plot in the
parent layout. For more information, see the PRIMARY= option.
HISTOGRAM Statement 595
See “boolean ” on page xii for other Boolean values that you can use.
Defaults In SAS 9.4M1 and earlier releases, the Color attribute of the
GraphDataDefault style element
Interactions For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
When a discrete attribute map is in effect for the histogram, the fill
colors that are specified by the attribute map take precedence over
COLOR. If the attribute map provides no color for a value, COLOR
prevails for that value.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLENDCOLOR=color
specifies the end color of the color gradient for the bar fill.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
596 Chapter 6 / Plot Statements
Restriction In SAS 9.4M4 and in earlier releases, the only styles that are
delivered by SAS that support fill patterns are JOURNAL2,
JOURNAL3, and MONOCHROMEPRINTER. If style-element is
specified and the active ODS style does not support fill patterns,
this option is ignored.
Interaction For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS styles
such as HTMLBlue that use color-priority attribute rotation, specify
ATTRPRIORITY=NONE in an ODS GRAPHICS statement or in the
BEGINGRAPH statement in your graph template. For more
information, see “Attribute Rotation Patterns” in SAS Graph
Template Language: User’s Guide.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
SOLID
fills each bar with the color that is assigned to that bar.
ALPHAGRADIENT
fills each bar with a color and a transparency gradient that starts at the bar
top with the initial transparency that is assigned to that bar, and ends with
full transparency at the bar baseline.
COLORGRADIENT
fills each bar with a color gradient that starts with the fill color that is
assigned to that bar and ends with the color that is specified in the
FILLENDCOLOR= option.
Alias GRADIENT
GRADIENT
fills each bar with a color and a transparency gradient that starts at the bar
top with the initial transparency that is assigned to that bar, and ends with
full transparency at the bar baseline.
Note: This option applies to SAS 9.4M2 through SAS 9.4M4. Starting with
SAS 9.4M5, ALPHAGRADIENT replaces GRADIENT, and GRADIENT is
changed to an alias of COLORGRADIENT.
Default SOLID
Interaction The DISPLAY= option must include FILL for this option to have any
effect.
Note The output for SAS programs written prior to SAS 9.4M5 that
specify FILLTYPE=GRADIENT might change starting with SAS
9.4M5. To restore the original appearance, specify
FILLTYPE=ALPHAGRADIENT.
598 Chapter 6 / Plot Statements
FREQ=numeric-column | expression
specifies a numeric column that provides frequencies for each observation that
is read.
discrete-attr-var
specifies a discrete attribute map variable.
A distinct bar or bar segment is created for each group value by varying the
visual attributes of the bar display features that are enabled by the current ODS
style or by the DISPLAY= option. The default group appearance for each display
feature is shown in the following table.
Display
Feature1 Style Attributes That Control Default Group Appearance
Display
Feature1 Style Attributes That Control Default Group Appearance
If the active ODS style does not specify FillPattern, fill patterns
are not displayed by default.
1 The default display features are determined by the DisplayOpts attribute of the
GraphHistogram style element.
Note If you specify a column in a SAS data set, the visual attributes for each
group value are assigned in data order. If you specify a column in a CAS
in-memory table, the visual attributes for each group value are assigned
in ascending order of the group column character values or of
unformatted numeric values.
Tips You can individually override the representations that are used to identify
the groups. For example, in some ODS styles, each distinct group value is
represented by a different line pattern for the bar outlines. In that case,
you can use the PATTERN= setting on the OUTLINEATTRS= option to
assign the same line pattern to all of the bar outlines.
By default, ODS Graphics limits the number of groups to 1000. When this
limit is exceeded, the GROUP= option is ignored. Use the GROUPMAX=
option in the ODS GRAPHICS statement to change the maximum number
of groups that can be processed.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
600 Chapter 6 / Plot Statements
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the MISSING= system option changes the default missing
character, or a user-defined format is applied to the group value. In
those cases, the attributes of the missing group value are
determined by a GraphData1–GraphDataN style element instead of
by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
NBINS=positive-integer
specifies the number of bins. This option can be used with the BINSTART= and
BINWIDTH= options to specify the bins.
Note When BINWIDTH=, BINSTART=, or both are specified with this option
and the resulting data range is greater than the unbinned input data
range, the histogram might be padded with zero-height bins in order to
accommodate the BINSTART=, BINWIDTH=, and NBINS= option
values.
Tip Starting with SAS 9.4M4, the limit on the number of bins is specified by
the ODS GRAPHICS statement NBINSMAX= option. The default value
is 10,000. See NBINSMAX= on page 1573.
HISTOGRAM Statement 601
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and the bars.
Default VERTICAL
In SAS 9.4M1 and earlier releases, for grouped data and filled bars,
the ContrastColor and LineStyle attributes of the GraphData1–
GraphDataN style elements, and the LineThickness attribute of the
GraphOutlines style element.
Starting with SAS 9.4M2, for grouped data and filled bars, the
ContrastColor attribute of the GraphData1–GraphDataN style
elements, and the LineThickness and LineStyle attributes of the
GraphOutlines style element.
Interaction For this option to have any effect, the outlines must be enabled by
the ODS style or by the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
PERCENT
displays the percentages between 0 and 100 on the Y axis.
602 Chapter 6 / Plot Statements
COUNT
displays the frequency counts on the Y axis.
PROPORTION
displays the proportions between 0 and 1 on the Y axis.
DENSITY
displays the true density estimates on the Y axis.
Default PERCENT
Requirement If you need to include a histogram and a density plot in your graph
and both plots specify the same data column, place the
HISTOGRAM statement before the DENSITYPLOT statement, or
specify SCALE=DENSITY in the HISTOGRAM statement. Otherwise,
the density plot values might not scale properly to the histogram
bins on the dependent axis. This requirement applies even when the
histogram and density plot are in different cells in the graph.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example TIPFORMAT=(Y=6.2)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Requirement To enable data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Note The X role represents the binned value. The Y role represents the
computed amount of X in the units specified by the SCALE=
option.
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example TIPLABEL=(Y="Percent")
HISTOGRAM Statement 603
Default The column label or column name of the column assigned to the role.
Note The Y role represents the computed amount of X in the units specified
by the SCALE= option.
WEIGHT=numeric-column | expression
specifies a column that contains a bin-width calculation a priori weight for each
observation of the input data object.
Note The values of the weight variable must be greater than zero. If the
weight value for an observation is zero, negative, or missing, that
observation is deleted from the analysis.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Default MIDPOINTS
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
The histogram’s default bin width is computed by using the number of observations
and the range of the data. When a curve is overlaid on the histogram, the
histogram’s bin width is used to scale the curve so that the area under the curve is
equal to the area of the histogram.
604 Chapter 6 / Plot Statements
The X axis and Y axis are linear by default. You can change axis properties with the
XAXISOPTS= and YAXISOPTS= options of the layout statement.
Examples
Example Program
proc template;
define statgraph histogram;
begingraph;
entrytitle "Histogram of Vehicle Weights";
layout overlay /
xaxisopts=(label="Vehicle Weight (LBS)")
yaxisopts=(griddisplay=on);
histogram weight;
endlayout;
endgraph;
end;
run;
Example Program
proc template;
define statgraph histogram;
begingraph;
entrytitle "Highway Mileage Distribution by Origin";
layout overlay /;
histogram mpg_highway / name="histogram" group=origin;
discretelegend "histogram" / title="Origin:";
endlayout;
endgraph;
end;
run;
HISTOGRAMPARM Statement
Creates a univariate histogram for specified values of bin midpoints and bin frequencies.
Starting with SAS 9.4M4, the number of bins is limited to 10,000. If the number of
bins exceeds the limit, the histogram is not drawn. A warning message is written to
the SAS log in that case.
Tips: Starting with SAS 9.4M4, the limit on the number of bins is specified by the ODS
GRAPHICS statement NBINSMAX= option. The default value is 10,000. See
NBINSMAX= on page 1573.
Starting with SAS 9.4M3, you can use subpixel rendering with this statement. It is
enabled by default. To disable subpixel rendering, specify SUBPIXEL=OFF in the
BEGINGRAPH statement or in an ODS GRAPHICS statement. For information
about the BEGINGRAPH statement SUBPIXEL= option, see SUBPIXEL= on page 39.
For information about the ODS GRAPHICS statement SUBPIXEL= option, see “ODS
GRAPHICS Statement” on page 1561.
Syntax
HISTOGRAMPARM X=numeric-column | expression
Y=non-negative-numeric-column | expression </options>;
Axes options
BINAXIS=TRUE | FALSE
HISTOGRAMPARM Statement 607
specifies whether to use bins as the basis for the axis tick marks.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
DATALABEL=column | expression
specifies a column for the bar labels.
DATALABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the bar labels.
DATALABELFITPOLICY=AUTO | NONE | ROTATE | SPLIT | SPLITALWAYS
specifies a policy for avoiding collisions among the bar labels when labels
are displayed.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
ENDLABELS=TRUE | FALSE
specifies whether the axis ticks and value labels are drawn at the bin
endpoints (TRUE) or at the bin midpoints (FALSE).
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Required Arguments
X=numeric-column | expression
specifies the column for the midpoint values.
Requirement When you plot a SAS data set, you must sort the data in ascending
order of the specified X column before you plot the data. When
you plot a CAS in-memory table, you do not need to sort the data.
The data is automatically sorted in ascending order of the X
column formatted character values or of the unformatted numeric
values before the data is plotted.
Y=non-negative-numeric-column | expression
specifies the column for the frequency values. These values can be frequency
counts, percentages, or proportions between 0 and 1.
Optional Arguments
BINAXIS=TRUE | FALSE
specifies whether to use bins as the basis for the axis tick marks.
TRUE
specifies that the ENDLABELS= option determines how the axis ticks and
value labels are displayed.
FALSE
specifies that standard axes are used. Bin boundaries and midpoints that are
set by the ENDLABELS= option are ignored.
Default TRUE
Interactions This option is ignored when this histogram is not the primary plot.
For more information about primary plots, see “When Plots Share
Data and a Common Axis” on page 1046.
When this option is set to TRUE, some X-axis options that are set
on the parent layout might not apply, such as INTEGER=,
TICKVALUELIST=, TICKVALUESEQUENCE=, and
INCLUDERANGES=.
“boolean ” on page xii for other Boolean values that you can use.
HISTOGRAMPARM Statement 609
DATALABEL=column | expression
specifies a column for the bar labels. The labels appear at the top or end of each
bar, depending on the chart orientation.
Interactions The DATALABEL= option must be specified for this option to have
any effect.
When text options are specified, any font properties that are not
specified (color, family, size, weight, and style) are derived from the
GraphDataText style element.
AUTO
selects a collision avoidance policy based on the chart orientation and data
type.
Tip If character labels do not fit after splitting, then try using ROTATE
instead of AUTO.
NONE
does not attempt to fit bar labels that collide.
ROTATE
rotates the bar labels for vertical bars if the labels collide in the available
width.
SPLIT
splits the label for vertical bars at a split character only if a split is needed at
that character in order to make the label fit the available space.
No split occurs at split characters that occur where a split is not needed. If
the label does not contain any of the specified split characters, then a split
610 Chapter 6 / Plot Statements
does not occur. In that case, if the label does not fit the available space, then
it might collide with the adjoining labels.
SPLITALWAYS
splits the label for vertical bars at every occurrence of a split character.
If the label does not contain any of the specified split characters, then a split
does not occur.
INSIDEPREFERRED
attempts to place the data labels in a horizontal bar chart inside the bars.
Notes If any bar label does not fit inside its bar because the font
height is too high, all of the bar labels are placed outside.
If any bar label cannot fit inside the length of its bar, that label
is placed outside of its bar and is fit using the AUTO fit policy.
Default AUTO
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split. When
multiple split characters are specified, each character in the list is treated as a
separate split character unless the specified characters appear consecutively in
the data label. In that case, all of the specified split characters together are
treated as a single split character.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
TRUE
drops a split character from the data label when a split occurs at that
character.
Split characters at which a split does not occur are left in place. The
DATALABELFITPOLICY= option determines where the labels are split. When
DATALABELFITPOLICY=SPLIT, each label is split at a split character only
where a split is needed in order to make the label fit the available space. At
each split point, the split character is dropped, and the characters that
follow the split character, up to but not including the split character at the
next split point, are wrapped to the following line.
612 Chapter 6 / Plot Statements
The following figure shows how label “Product*Group*1” is split when the
DATALABELSPLITCHARDROP=TRUE and DATALABELSPLITCHAR="*"
options are used with the SPLIT and SPLITALWAYS fit policies.
FALSE
includes the split characters in the data label.
The following figure shows how label “Product*Group*1” is split when the
DATALABELSPLITCHARDROP=FALSE and DATALABELSPLITCHAR="*"
options are used with the SPLIT and SPLITALWAYS fit policies.
HISTOGRAMPARM Statement 613
See “boolean ” on page xii for other Boolean values that you can use.
Requirement For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
614 Chapter 6 / Plot Statements
When a data skin is applied, all bar outlines are set by the skin, and
the OUTLINEATTRS= option is ignored.
DATATRANSPARENCY=number
specifies the degree of the transparency of the bars (outline and fill).
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
bar fills. You can combine this option with FILLATTRS= to set one
transparency for the bar outlines but a different transparency for the
bar fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
(display-options)
a space-separated list of one or more of the following options, enclosed in
parentheses:
FILL
displays the bar fill color
FILLPATTERN
displays the bar fill pattern
OUTLINE
displays the bar outline
STANDARD
specifies FILL and OUTLINE
ALL
specifies all features: FILL, FILLPATTERN, and OUTLINE
ENDLABELS=TRUE | FALSE
specifies whether the axis ticks and value labels are drawn at the bin endpoints
(TRUE) or at the bin midpoints (FALSE).
HISTOGRAMPARM Statement 615
Default FALSE.
Interactions This option is ignored if this plot is not the primary plot in the
parent layout. For more information, see the PRIMARY= option.
See “boolean ” on page xii for other Boolean values that you can use.
Interactions For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
When a discrete attribute map is in effect for the histogram, the fill
colors that are specified by the attribute map take precedence over
COLOR. If the attribute map provides no color for a value, COLOR
prevails for that value.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLENDCOLOR=color
specifies the end color of the color gradient for the bar fill.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
616 Chapter 6 / Plot Statements
Interaction For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS styles
such as HTMLBlue that use color-priority attribute rotation, specify
ATTRPRIORITY=NONE in an ODS GRAPHICS statement or in the
BEGINGRAPH statement in your graph template. For more
information, see “Attribute Rotation Patterns” in SAS Graph
Template Language: User’s Guide.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
SOLID
fills each bar with the color that is assigned to that bar.
ALPHAGRADIENT
fills each bar with a color and a transparency gradient that starts at the bar
top with the initial transparency that is assigned to that bar, and ends with
full transparency at the bar baseline.
COLORGRADIENT
fills each bar with a color gradient that starts with the fill color that is
assigned to that bar and ends with the color that is specified in the
FILLENDCOLOR= option.
HISTOGRAMPARM Statement 617
Alias GRADIENT
GRADIENT
fills each bar with a color and a transparency gradient that starts at the bar
top with the initial transparency that is assigned to that bar, and ends with
full transparency at the bar baseline.
Note: This option applies to SAS 9.4M2 through SAS 9.4M4. Starting with
SAS 9.4M5, ALPHAGRADIENT replaces GRADIENT, and GRADIENT is
changed to an alias of COLORGRADIENT.
Default SOLID
Interaction The DISPLAY= option must include FILL for this option to have any
effect.
Note The output for SAS programs written prior to SAS 9.4M5 that
specify FILLTYPE=GRADIENT might change starting with SAS
9.4M5. To restore the original appearance, specify
FILLTYPE=ALPHAGRADIENT.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis and the bars.
Default VERTICAL
Interaction For this option to have any effect, the outlines must be enabled by
the ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
HISTOGRAMPARM Statement 619
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles X, Y, and DATALABEL.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a
histogram bin. If this option is used, then it replaces all of the information that is
displayed by default. Roles for columns that do not contribute to the histogram
can be specified along with roles that do.
(role-list)
an ordered, space-separated list of unique HISTOGRAMPARM and user-
defined roles.
Example The following example displays data tips for the columns assigned
to the roles X and Y, as well as the column Pct, which is not
assigned to any pre-defined HISTOGRAMPARM role. The Pct
column must first be assigned a role:
ROLENAME=(TIP1=PCT)
TIP=(X Y TIP1)
NONE
suppresses data tips from the plot.
Requirement To enable data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Default MIDPOINTS
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
When a curve is overlaid on the histogram, the histogram bin width is used to scale
the curve so that the area under the curve is equal to the area of the histogram.
The X axis and Y axis are linear by default. You can change axis properties with the
XAXISOPTS= and YAXISOPTS= options of the LAYOUT OVERLAY statement.
Example Program
proc template;
define statgraph histogramparm;
begingraph;
entrytitle "Histogram of Vehicle Weights";
layout overlay;
histogramparm x=midpoint y=frequency;
endlayout;
endgraph;
end;
run;
data bins;
input Midpoint Frequency;
label midpoint="Vehicle Weight (LBS)";
datalines;
2000 18
3000 208
4000 159
5000 36
6000 6
7000 1
;
run;
LINECHART Statement
Creates a line chart that is computed from input data.
Restrictions: GROUPDISPLAY= STACK has stringent requirements for the data. If the
requirements are not met for all the data, then the line chart is not drawn. If the
LINECHART statement is in a LAYOUT DATALATTICE or LAYOUT DATAPANEL
block, then the requirements are tested for all of the data, not for each individual
panel.
The category axis (the X axis when ORIENT=VERTICAL or the Y axis when
ORIENT=HORIZONTAL) is always discrete.
The response axis (the Y axis when ORIENT=VERTICAL or the X axis when
ORIENT=HORIZONTAL) is always numeric.
The LINECHART statement performs discrete binning for a numeric category
column only.
Note: Specifying only the CATEGORY= option creates a computed line chart with vertices
representing frequency counts or percents of unique CATEGORY values. For a non-
grouped chart, specifying both the CATEGORY= and RESPONSE= options creates a
computed line chart with vertices representing the summarized values of the
RESPONSE values that are categorized by unique CATEGORY values.
LINECHART Statement 623
Tips: The line segments in the chart always join the categorical values in the order in
which they appear on the axis. By default, the vertices in the line chart appear in
the order in which the X values occur in the input data. To change the categorical
axis tick value order, use the SORTORDER= or TICKVALUELIST= suboption of the
DISCRETEOPTS= option for the X axis. For example:
XAXISOPTS=(DISCRETEOPTS=(SORTORDER=ASCENDINGFORMATTED))
The response axis of the line chart includes the zero value by default. You can use
the BASELINEINTERCEPT= to change the Y intercept.
By default, missing category values are ignored. To treat missing category values as
a category, include the INCLUDEMISSINGDISCRETE=TRUE option in the
BEGINGRAPH statement.
Starting with SAS 9.4M3, subpixel rendering is enabled by default. To disable
subpixel rendering, specify SUBPIXEL=OFF in the BEGINGRAPH statement or in an
ODS GRAPHICS statement. For information about the BEGINGRAPH statement
SUBPIXEL= option, see SUBPIXEL= on page 39. For information about the ODS
GRAPHICS statement SUBPIXEL= option, see “ODS GRAPHICS Statement” on
page 1561.
See: “LAYOUT DATALATTICE Statement” on page 51
“LAYOUT DATAPANEL Statement” on page 79
“Axis Options in Layouts” on page 1055
“BEGINGRAPH Statement” on page 25
Syntax
LINECHART CATEGORY=column | expression < /options > ;
Axes options
BASELINEINTERCEPT=number | AUTO | AXISMIN | AXISMINEXTEND |
AXISMAX | AXISMAXEXTEND
specifies the Y-intercept for the baseline.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
VERTEXLABEL=TRUE | FALSE
specifies whether to label the vertices with their response value (or
statistic).
VERTEXLABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the vertex labels.
VERTEXLABELFORMAT=format
specifies the format used to display the vertex label response or statistic.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a separate line for each unique group value in the specified
column.
GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
specifies the ordering of the groups within a category.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
ODS options
URL=string-column
specifies an HTML page to display when a line segment, marker, or fill
area is selected.
Statistics options
STAT=FREQ | PCT | PROPORTION | SUM | MEAN
specifies the statistic to be computed for the Y axis.
Required Argument
CATEGORY=column | expression
specifies the column or expression for the category values. Duplicated category
values are summarized into a unique value. All values are treated as discrete.
626 Chapter 6 / Plot Statements
Optional Arguments
BASELINEINTERCEPT=number | AUTO | AXISMIN | AXISMINEXTEND |
AXISMAX | AXISMAXEXTEND
specifies the Y-intercept for the baseline.
number
specifies the Y coordinate of the baseline.
This value is included in the data range that is reported by the line chart.
AUTO
bases the intercept on the response axis range.
AXISMIN
places the baseline at the minimum value of the axis range.
AXISMINEXTEND
places the baseline at the start of the minimum offset in the wall.
This location corresponds to the bottom edge of the wall when there is no
inner margin plot and the axis is not reversed. If there is an inner margin plot
at the bottom, then the baseline is placed at the boundary of the inner
margin and the minimum offset.
AXISMAX
places the baseline at the maximum value of the axis range.
AXISMAXEXTEND
places the baseline at the start of the maximum offset in the wall.
This location corresponds to the top edge of the wall when there is no inner
margin plot, and the axis is not reversed. If there is an inner margin plot at
the top, then the baseline is placed at the boundary of the inner margin and
the maximum offset.
Default AUTO
When DISPLAY= includes FILL, the fill extends to the baseline that
is specified by the BASELINEINTERCEPT= option.
BREAK=TRUE | FALSE
breaks the line at missing values of the RESPONSE variable.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
Restriction Starting with SAS 9.4M1, the maximum number of skinned graphical
elements is limited to 200 per plot in an OVERLAY or PROTOTYPE
layout. When this limit is exceeded for a plot, the specified data
skin is not applied to that plot. In that case, use the
DATASKINMAX= option in your ODS GRAPHICS statement to
increase the maximum limit.
The skin appearance is based on the color that is in effect for the
lines and markers.
DATATRANSPARENCY=number
specifies the degree of the transparency of the line, markers, and vertex labels,
if displayed.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
fills. You can combine this option with FILLATTRS= to set one
transparency for the lines but a different transparency for the fills. For
example:
datatransparency=0.2 fillattrs=(transparency=0.6)
(display-options)
a space-separated list of one or more display options enclosed in
parentheses.
FILL
displays a filled area between the line and the baseline
LINE
displays line segments that join the vertices
MARKERS
displays markers at each vertex
STANDARD
specifies LINE only
ALL
specifies all features: FILL, LINE, and MARKERS
Default STANDARD
FILLATTRS=style-element | (fill-options)
specifies the appearance of the filled area.
Interactions For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
FILLEDOUTLINEDMARKERS=TRUE | FALSE
specifies whether markers are drawn with both fill and an outline.
LINECHART Statement 631
TRUE
draws filled markers (marker symbols with the suffix FILLED) using both fill
and an outline.
When this option is TRUE, the fill color and outline color for filled markers
are determined in the following ways:
n If the GROUP= option is specified, then by default, the fill color is derived
from the GraphData1–GraphDataN style elements Color attribute, and
the marker outlined color is derived from the GraphData1–GraphDataN
style elements ContrastColor attribute.
n If the GROUP= option is not specified, then by default, the fill color is
derived from the GraphDataDefault style elements Color attribute, and
the marker outlined color is derived from the GraphOutline style
elements ContrastColor attribute.
FALSE
draws the markers using fill or an outline, but not both.
Default FALSE
Tip To specify the marker fill and outline colors for a non-grouped plot, set
this option to TRUE, and then use the MARKERFILLATTRS= and
MARKEROUTLINEATTRS= options to specify the colors.
“boolean ” on page xii for other Boolean values that you can use.
discrete-attr-var
specifies a discrete attribute map variable.
Tips The representations that are used to identify the groups can be
overridden individually. For example, each distinct group value is
represented by a different line pattern for the lines, but you can use
the PATTERN= suboption of the LINEATTRS= option to assign the
same line pattern to all lines.
GROUPDISPLAY=OVERLAY | STACK
specifies how to display grouped lines.
OVERLAY
displays group values overlaid on top of each other.
STACK
displays group values as stacked lines.
Default OVERLAY
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Tip This option is useful when you want to reverse the category axis.
LINECHART Statement 633
ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.
Interactions This option is ignored if the GROUP= option is not also specified.
By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.
Notes When plotting a SAS data set, attributes such as color, symbol, and
pattern are assigned to each group in DATA order by default. When
plotting a CAS in-memory table, attributes are assigned in
ascending order of the group column character values or
unformatted numeric values by default.
In SAS 9.4M6 and earlier releases, when data stored in a CAS in-
memory table is used and DATA or REVERSEDATA is specified,
unpredictable results might occur. To generate consistent graphs in
that case, specify ASCENDING or DESCENDING. Starting with SAS
Viya 3.5 and SAS Studio 5.2, when data stored in a CAS in-memory
table is used and DATA or REVERSEDATA is specified, it is ignored,
and ASCENDING is used instead.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
634 Chapter 6 / Plot Statements
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color, marker symbol, and line
pattern) and fill attributes to one of the GraphData1–GraphDataN style
elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
LINEATTRS=style-element | (line-options)
specifies the appearance of the line.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
MARKERFILLATTRS=style-element | (fill-options)
specifies the appearance of the filled markers.
636 Chapter 6 / Plot Statements
MARKEROUTLINEATTRS=style-element | (line-options)
specifies the appearance of the marker outlines.
Interaction This option is ignored when a data skin is applied by the current
style or by the DATASKIN= option. In the latter case, the outline is
set by the data skin.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. This option is used mostly in the CONTINUOUSLEGEND on page
1291 statement in order to coordinate the use of colors and line patterns
between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
LINECHART Statement 637
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the Y axis.
Default VERTICAL
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles CATEGORY, RESPONSE, DATALABEL, and
GROUP.
Note The column values for a custom tip are not summarized using the
STAT= statistic. For a given category value, the custom tip column
values for that category value should be the same. Otherwise,
unexpected results might occur.
SMOOTHCONNECT=TRUE | FALSE
specifies that a smoothed line passes through all vertices.
638 Chapter 6 / Plot Statements
Default FALSE. Straight line segments are used if the vertices are to be
connected.
See “boolean ” on page xii for other Boolean values that you can use.
SUM
MEAN
Defaults SUM for line charts that specify the RESPONSE= argument.
FREQ for line charts that do not specify the RESPONSE= argument.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a line. If
this option is used, then the information specified replaces all of the information
that is displayed by default. You can specify roles for columns that do not
contribute to the line chart along with roles that do.
(role-list)
an ordered, space-separated list of unique LINECHART roles and user-
defined roles.
NONE
suppresses data tips and URLs (if requested) from the plot.
Restriction Data tips are available only for graphs that are written to the ODS
HTML destination.
Note The RESPONSE role represents the computed values for the
CATEGORY role (and RESPONSE= role), based on the STAT=
option.
Tip You can control the labels and formats for the TIP roles with the
TIPLABEL= and TIPFORMAT= options.
Example To display data tips for the columns assigned to the roles X and Y
as well as the user-defined role TIP1:
ROLENAME=(TIP1=OBS)
TIP=(TIP1 X Y)
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
640 Chapter 6 / Plot Statements
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
URL=string-column
specifies an HTML page to display when a line segment, marker, or fill area is
selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each line that is to have an active link.
Example http://www.sas.com
Requirement To generate selectable line segments, markers, and fill areas, you
must include an ODS GRAPHICS ON statement that specifies the
IMAGEMAP option, and you must write the output to the ODS
HTML destination.
Notes For non-grouped data, the values of the column are expected to be
same for each unique X value. If they are not, then the results
might be unpredictable.
For grouped data, the values of the column are expected to be the
same for each unique X and GROUP combination.
Tips The URL value can be blank for some X values, meaning that no
action is taken when the line segments for those X values are
selected.
The URL value can be the same for different X values, meaning
that the same action is taken when the line segments for those X
values are selected.
VERTEXLABEL=TRUE | FALSE
specifies whether to label the vertices with their response value (or statistic).
Default FALSE
Note By default, the vertex-label format is derived from the format that is
assigned to the response column or from BEST6 if no format is
assigned. The derived format retains the precision of the response-
column format and, if necessary, increases the format width to
accommodate the summarized value on the response axis.
Tips You can modify the visual attributes for the label by using the
VERTEXLABELATTRS= option.
See “boolean ” on page xii for other Boolean values that you can use.
Interaction If one or more text options are specified and they do not include all
the font properties (color, family, size, weight, style), then non-
specified properties are derived from the GraphDataText style
element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
VERTEXLABELFORMAT=format
specifies the format used to display the vertex label response or statistic.
Default The vertex label format is derived from the format that is applied
to the response column or from BEST6 if no format is assigned.
The derived format retains the precision of the response-column
format and, if necessary, increases the format width to
accommodate the summarized value on the response axis.
Note When a vertex-label format is specified with this option, the vertex
labels are formatted as specified by format. The specified format is
not automatically expanded to accommodate values that are too
wide.
642 Chapter 6 / Plot Statements
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
A line chart shows the relationship of one variable to another as trends in the data
over a period of time. The trends are shown by connecting the successive data
points with a line. Typically, a line chart is used to chart a response value against a
discrete categorical value where each value on the horizontal axis has only one
corresponding value on the vertical axis. A grouping variable can be used to show
multiple trends based on the group values.
In a line chart, the category axis (X) is always discrete, and the response axis (Y) is
always linear. The line segments in the chart always join the categorical values in
the order in which they appear on the axis. The vertices in the line chart appear in
the order in which the categorical values appear in the input data.
LINECHART Statement 643
Examples
The following graph was generated by the “Example Program” on page 643. It
shows the trend of the average closing price of the IBM, Intel, and Microsoft stocks
from 1995 through 2005.
Example Program
Here is the SAS code for this example.
/* Extract per-year data for 1995 through 2005 from SASHELP.STOCKS */
data linechartdata;
set sashelp.stocks(where=(year(date) between 1995 and 2005));
year=year(date);
label year="Year";
run;
/* Add a grid */
xaxisopts=(griddisplay=on gridattrs=(pattern=dot
color=lightgray))
yaxisopts=(griddisplay=on gridattrs=(pattern=dot
color=lightgray));
/* Add a legend */
discretelegend "linechart";
endlayout;
endgraph;
end;
run;
The following graph was generated by the “Example Program” on page 645. It
shows the trend of the average monthly closing price of the IBM, Intel, and
Microsoft stocks for 2001.
LINECHART Statement 645
Example Program
Here is the SAS code for this example.
/* Define the line chart template */
proc template;
define statgraph linechart;
begingraph;
/* Create a dynamic variable for the year */
dynamic year;
/* Add a legend */
discretelegend "linechart";
endlayout;
endgraph;
end;
run;
LINEPARM Statement
Creates a straight line specified by a point and a slope.
Requirement: A LINEPARM statement can be used only within a 2-D layout (OVERLAY,
OVERLAYEQUATED, DATALATTICE, or DATAPANEL). Another plot statement that
LINEPARM Statement 647
is derived from data values that provide boundaries for the axis area must be
included.
Syntax
LINEPARM X=number | numeric-column | expression
Y=number | numeric-column | expression
SLOPE=number | numeric-column | expression < /options >;
Axes options
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
CURVELABEL="string" | column | expression
specifies a label for the line.
CURVELABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the line label.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the line label relative to the plot area.
CURVELABELPOSITION=AUTO | MAX | MIN
specifies the position of the line label relative to the line end points.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the line label at the specified split characters.
648 Chapter 6 / Plot Statements
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the line label can be split if
needed.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the line label text.
CURVELABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the line label
block.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a separate parameterized line plot for each unique group value of
the specified column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Required Arguments
X=number | numeric-column | expression
specifies the X coordinate of a point. By default, if the specified value is outside
of the data range, then the data range is extended to include the specified
intercept. This behavior can be changed with the CLIP= option. If a numeric-
column is specified and the column contains missing values, then no line is
drawn for the missing values.
Optional Arguments
CLIP=TRUE | FALSE
specifies whether the data for the line is considered when the data ranges are
determined for the axes.
FALSE
specifies that the data for the line contributes to the data range for each
axis.
Each axis might be extended in order to force the display of the line. When
CLIP=FALSE, the SLOPE= option determines how the X= and Y= values
contribute to the axis data range in the following ways:
n If SLOPE=0, then only the Y= values contribute to the axis data range.
n If SLOPE=. (missing), then only the X= values contribute to the axis data
range.
n If SLOPE= is neither 0 nor missing, then the X= and Y= values contribute
to the axis data range.
TRUE
specifies that the data for the line is ignored when axis scales are being
established.
Each axis scale is determined by the other plots in the layout. In this case,
the line might not be displayed if its data range is not within the data ranges
of the other plots.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Restrictions When the GROUP= option is specified, "string" and expression are
not valid. Use column in that case.
When the GROUP= option is not specified, column is not valid. Use
"string" or expression in that case.
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
Interactions For this option to take effect, the CURVELABEL= option must also
be used.
Tip When the GROUP= option is used, each distinct group value might
be represented by a different color. The line label that is associated
with the group is assigned the group color. This option can be used
to specify a single color for all line labels in a plot, without affecting
the line colors.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the line label relative to the plot area.
INSIDE
locates the labels inside the plot area
OUTSIDE
locates the labels outside the plot area
Default INSIDE
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
AUTO
automatically positions the line label near the line boundary along unused
axes whenever possible (typically Y2 and X2) in order to avoid collision with
tick values.
LINEPARM Statement 651
MAX
forces the line label to appear near maximum line values (typically, upper
right).
MIN
forces the line label to appear near minimum line values (typically, lower
left).
Interaction For this option to take effect, the CURVELABEL= option must also
be specified.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the line label at the specified split characters. When a
line label is split, the label is split on each occurrence of the specified split
characters.
See “boolean ” on page xii for other Boolean values that you can use.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the line label can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the line label. In that case, all of the specified split characters
together are treated as a single split character.
characters. If the line label does not contain any of the specified characters,
then the label is not split.
"character-list"
one or more characters with no delimiter between each character and
enclosed in quotation marks.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the line label text.
TRUE
drops the split characters from the line label text.
FALSE
includes the split characters in the line label text.
The following figure shows an example of a line label with the following
specifications:
n CURVELABELPOSITION=MAX
n CURVELABEL="Product*Group*A"
n CURVELABELSPLIT=TRUE
n CURVELABELSPLITCHARDROP=TRUE | FALSE
n CURVELABELSPLITCHAR="*"
LINEPARM Statement 653
Note: The horizontal line to the left of the label represents the maximum end of
the line for reference.
Default TRUE. The split characters are dropped from the line label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the CURVELABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The horizontal line to the left of each label represents the maximum end
of the line for reference.
654 Chapter 6 / Plot Statements
Default AUTO
DATATRANSPARENCY=number
specifies the degree of the transparency of the line.
Default 0
EXTEND=TRUE | FALSE
specifies whether the line is to be drawn to the area bounded by the axes.
Default FALSE
Note If this option is not specified, then there can be a small gap between
the line and the axis. The gap is controlled by the axis offset. If the
offset is set to 0, then there is no gap.
See “boolean ” on page xii for other Boolean values that you can use.
discrete-attr-var
specifies a discrete attribute map variable.
Restriction When this option is used, the X, Y, and SLOPE arguments must
specify numeric columns.
Interactions The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of line colors
and line patterns
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color and line pattern) to one of
the GraphData1–GraphDataN style elements.
656 Chapter 6 / Plot Statements
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
LINEPARM Statement 657
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Restriction Another plot that establishes a data range for the designed axis
must be included.
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Restriction Another plot that establishes a data range for the designed axis
must be included.
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
The LINEPARM statement creates a straight line. You can generate a single line by
specifying a constant for each required argument. You can generate multiple lines
by specifying a numeric column for any or all required arguments. If any of the X= or
Y= columns contains a missing value, then no line is drawn. To request a vertical
line, specify SLOPE=. (specify a missing value as a constant or column value).
Example Program
The LINEPARM statement draws a line based on a point and the slope of the line
that passes through that point. You can use this statement to create a reference
line with any slope or, in this example, to draw a fit from a linear regression. Many
SAS/STAT procedures create output data sets containing a Y-intercept and slope
and coefficient for the linear regression equation.
proc template;
define statgraph lineparm;
begingraph;
entrytitle "Robust Fit of Height and Weight by Sex ";
layout overlay / xaxisopts=(offsetmax=0.35);
scatterplot x=height y=weight / group=sex
markercharacter=eval(substr(sex,1,1))
markercharacterattrs=(size=5pt) datatransparency=0.7;
lineparm x=0 y=intercept slope=slope /
name="Line" group=sex clip=true
curvelabel=eval("Weight = "||put(slope,5.3)||
" * Height + "||put(intercept,6.1))
curvelabellocation=inside
curvelabelattrs=(size=8pt);
discretelegend "Line";
endlayout;
endgraph;
LOESSPLOT Statement 659
end;
run;
data all;
merge heart stats(keep=intercept slope sex);
run;
LOESSPLOT Statement
Creates a fitted loess curve computed from input data.
Restriction: The LOESSPLOT statement supports only models of one independent and one
dependent variable.
Note: If the input data contains a large number of observations, then it might take several
minutes to generate the plot.
Tips: By default, the LOESSPLOT statement will process up to 5000 observations. If the
input data exceeds 5000 observations, then the plot is not generated. In that case,
you can use the ODS GRAPHICS statement LOESSMAXOBS= option to extend the
limit. See “Details” on page 671.
Starting with SAS 9.4M3, subpixel rendering is enabled by default. To disable
subpixel rendering, specify SUBPIXEL=OFF in the BEGINGRAPH statement or in an
ODS GRAPHICS statement. For information about the BEGINGRAPH statement
SUBPIXEL= option, see SUBPIXEL= on page 39. For information about the ODS
GRAPHICS statement SUBPIXEL= option, see “ODS GRAPHICS Statement” on
page 1561.
Syntax
LOESSPLOT X=numeric-column | expression
Y=numeric-column | expression </<regression-options> <options>>;
660 Chapter 6 / Plot Statements
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
CURVELABEL="string"
specifies a label for the loess curve.
CURVELABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the curve labels.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the curve label relative to the plot area.
CURVELABELPOSITION=AUTO | MAX | MIN | START | END
specifies the position of the curve label relative to the curve line.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the curve label at the specified split characters.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the curve label can be split if
needed.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the curve label text.
CURVELABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the curve label
block.
LOESSPLOT Statement 661
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a distinct set of curves from just the observations that
correspond to each unique group value of the specified column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Required Arguments
X=numeric-column | expression
specifies the column for the X values.
Y=numeric-column | expression
specifies the column for the Y values.
Optional Arguments
CURVELABEL="string"
specifies a label for the loess curve.
Interaction This option is not valid when the GROUP= option is specified.
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the curve label relative to the plot area.
662 Chapter 6 / Plot Statements
INSIDE
locates the labels inside the plot area
OUTSIDE
locates the labels outside the plot area
Default INSIDE
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
AUTO
automatically positions the curve label near the curve boundary along
unused axes whenever possible (typically Y2 and X2) in order to avoid
collision with tick values.
MAX
forces the curve label to appear near maximum curve values (typically,
upper right).
MIN
forces the curve label to appear near minimum curve values (typically, lower
left).
START
forces the curve label to appear near the beginning of the curve.
Tip This option is particularly useful when the curve line has a spiral
shape.
END
forces the curve label to appear near the end of the curve.
Tip This option is particularly useful when the curve line has a spiral
shape.
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the curve label at the specified split characters. When
a curve label is split, the label is split on each occurrence of the specified split
characters.
See “boolean ” on page xii for other Boolean values that you can use.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the curve label can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the curve label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no delimiter between each character and
enclosed in quotation marks.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the curve label text.
TRUE
drops the split characters from the curve label text.
FALSE
includes the split characters in the curve label text.
The following figure shows an example of a curve label with the following
specifications:
n CURVELABELPOSITION=MAX
n CURVELABEL="Product*Group*A"
n CURVELABELSPLIT=TRUE
n CURVELABELSPLITCHARDROP=TRUE | FALSE
n CURVELABELSPLITCHAR="*"
LOESSPLOT Statement 665
Note: The horizontal line to the left of the label represents the maximum end of
the curve for reference.
Default TRUE. The split characters are dropped from the curve label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the CURVELABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The horizontal line to the left of each label represents the maximum end
of the curve for reference.
666 Chapter 6 / Plot Statements
Default AUTO
DATATRANSPARENCY=number
specifies the degree of the transparency of the loess curve.
Default 0
discrete-attr-var
specifies a discrete attribute map variable.
Interactions The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of line colors
and line patterns.
pattern to all of the loess curves, letting the line color distinguish
group values. Likewise, LINEATTRS=(COLOR=BLACK) can be used
to assign the same color to all of the curves, letting the line pattern
distinguish group values.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color and line pattern) to one of
the GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
668 Chapter 6 / Plot Statements
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example TIPFORMAT=(Y=6.2)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Requirement To enable data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Note The columns assigned to the X, Y, and GROUP (if assigned) roles
are automatically included in the data tip information.
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example TIPLABEL=(Y="Curve")
Default The column label or column name of the column assigned to the role.
Note The columns assigned to the X, Y, and GROUP (if assigned) roles are
automatically included in the data tip information.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
670 Chapter 6 / Plot Statements
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Default 0.05
CLM="name"
produces confidence limits for a mean predicted value for each observation. The
confidence level is set by the ALPHA= option.
Interaction "name" is a unique name within the template that is case sensitive
and cannot contain spaces. It must be assigned in order for the
confidence limits to be computed. To display confidence limits, you
must use this name as the required argument of a MODELBAND
statement.
DEGREE=1 | 2
specifies the degree of the local polynomials to use for each local regression.
The valid values are 1 for local linear fitting or 2 for local quadratic fitting.
Default 1
INTERPOLATION=LINEAR | CUBIC
specifies the degree of the interpolating polynomials used for blending local
polynomial fits at the kd tree vertices.
CUBIC
cubic polynomials
LINEAR
linear polynomials
Default LINEAR
MAXPOINTS=positive-integer
specifies the maximum number of predicted points generated for the loess
curve as well as confidence limits.
Default 201
SMOOTH=AUTO | positive-number
specifies a smoothing parameter value. The value represents the proportion of
observations that are used for local regression.
AUTO
automatically selects a smoothing parameter value.
LOESSPLOT Statement 671
positive-number
specifies a smoothing parameter value.
Range (0,1]
Default AUTO
REWEIGHT=NONE | positive-integer
specifies the number of iterative re-weighting steps to be done. Such iterations
are appropriate when there are outliers in the data or when the error distribution
is a symmetric long-tailed distribution.
Default NONE
WEIGHT=numeric-column
specifies a column in the input data set that contains values to be used as a
priori weights for a loess fit. The values of the weight column must be
nonnegative. If an observation’s weight is zero, negative, or missing, then the
observation is deleted from the analysis.
Details
The LOESSPLOT statement supports only statistical models of one independent
and one dependent variable. For more information about the fitting methodology,
see The LOESS Procedure in SAS/STAT User’s Guide.
In addition to the loess curve, the LOESSPLOT statement can compute confidence
levels for the fitted line. To display the confidence levels:
1 Use the CLM= option to declare a name for the confidence level of the mean .
NOTE: The number of observations of the LOESS plot (nnnn) exceeds the
limit of 5000. Specify the LOESSMAXOBS option of the ODS GRAPHICS statement to
override the limit.
In that case, you can use the following statement to extend the limit:
ods graphics / loessmaxobs=nnnn
672 Chapter 6 / Plot Statements
Note: When the input data contains a large number of observations, it might take
several minutes to generate the plot.
For more information about the LOESSMAXOBS= option, see “ODS GRAPHICS
Statement” on page 1561.
Example Program
proc template;
define statgraph loessplot;
begingraph;
entrytitle "Loess Fit Plot";
layout overlay;
scatterplot x=weight y=mpg_highway /
datatransparency=0.7;
loessplot x=weight y=mpg_highway / name="fitline"
alpha=0.05 legendlabel="Loess Fit";
discretelegend "fitline";
endlayout;
endgraph;
MODELBAND Statement 673
end;
run;
MODELBAND Statement
Creates a band showing confidence limits for an associated smoother plot.
Syntax
MODELBAND "confidence-name" </options>;
Axes options
XAXIS=X | X2
674 Chapter 6 / Plot Statements
Label options
CURVELABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the upper and lower band labels.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the band labels relative to the plot area.
CURVELABELLOWER="string"
specifies a label for the lower band limit.
CURVELABELPOSITION=AUTO | MAX | MIN | START | END
specifies the position of the band label relative to the band line.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the curve labels at the specified split
characters.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the curve labels can be split if
needed.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the curve label text.
CURVELABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the curve label
blocks.
CURVELABELUPPER="string"
specifies a label for the upper band limit.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Required Argument
"confidence-name"
specifies the case-sensitive name assigned to a confidence option in a smoother
plot statement.
MODELBAND Statement 675
Optional Arguments
ANTIALIAS=AUTO | OFF
specifies whether anti-aliasing is turned off for this plot.
AUTO
specifies that anti-aliasing is controlled by the ANTIALIAS= option in the
ODS GRAPHICS statement.
OFF
specifies that anti-aliasing is always disabled for this plot.
Default AUTO
Interaction This option overrides the ANTIALIAS= option in the ODS GRAPHICS
statement.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CURVELABELLOWER="string"
specifies a label for the lower band limit.
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
CURVELABELUPPER="string"
specifies a label for the upper band limit.
676 Chapter 6 / Plot Statements
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the band labels relative to the plot area.
INSIDE
locates the labels inside the plot area
OUTSIDE
locates the labels outside the plot area
Default INSIDE
AUTO
automatically positions the band labels near the band boundary along
unused axes whenever possible (typically Y2 and X2).
MAX
forces the band label to appear near maximum band values (typically, upper
right)
MIN
forces the band label to appear near minimum band values (typically, lower
left)
START
forces the band label to appear near the beginning of the band.
Tip This option is particularly useful when the curve line has a spiral
shape.
END
forces the band label to appear near the end of the band.
Tip This option is particularly useful when the curve line has a spiral
shape.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the curve labels at the specified split characters.
When a curve label is split, the label is split on each occurrence of the specified
split characters.
See “boolean ” on page xii for other Boolean values that you can use.
678 Chapter 6 / Plot Statements
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the curve labels can be split if
needed. When multiple split characters are specified, each character in the list
is treated as a separate split character unless the specified characters appear
consecutively in the curve label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no delimiter between each character and
enclosed in quotation marks.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the curve label text.
TRUE
drops the split characters from the curve label text.
FALSE
includes the split characters in the curve label text.
The following figure shows an example of a curve label with the following
specifications:
n CURVELABELPOSITION=MAX
n CURVELABEL="Product*Group*A"
n CURVELABELSPLIT=TRUE
n CURVELABELSPLITCHARDROP=TRUE | FALSE
n CURVELABELSPLITCHAR="*"
Note: The horizontal line to the left of the label represents the maximum end of
the series line for reference.
Default TRUE. The split characters are dropped from the curve labels.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the CURVELABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
680 Chapter 6 / Plot Statements
Note: The horizontal line to the left of each label represents the maximum end
of the band for reference.
Default AUTO
DATATRANSPARENCY=number
specifies the degree of the transparency of the band fill and the band outline.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
filled band area. You can combine this option with FILLATTRS= to set
one transparency for the band outline but a different transparency for
the band fill. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
FILL
displays the band fill color
OUTLINE
displays the band outline
STANDARD
specifies FILL only
ALL
specifies all features: FILL and OUTLINE
MODELBAND Statement 681
Interaction For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
Interaction For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS styles
such as HTMLBlue that use color-priority attribute rotation, specify
ATTRPRIORITY=NONE in an ODS GRAPHICS statement or in the
BEGINGRAPH statement in your graph template. For more
682 Chapter 6 / Plot Statements
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
MODELBAND Statement 683
(role-format-list)
a space-separated list of role-name = format pairs. The role-names X,
LIMITLOWER, LIMITUPPER, GROUP, and INDEX are available to indicate
which data tip values to format.
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Requirement To enable data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs. The role-names X,
LIMITLOWER, LIMITUPPER, GROUP, and INDEX are available to indicate
which data tip values to label.
Example TIP=(X)
TIPLABEL=(X="Type")
Default The column label or column name of the column assigned to the role.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Requirement The setting for this option should be the same as for the smoother
statement referenced by the confidence-name .
Interaction The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Requirement The setting for this option should be the same as for the smoother
statement referenced by the confidence-name .
Interaction The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
684 Chapter 6 / Plot Statements
Example Program
proc template;
define statgraph modelband;
begingraph / attrpriority=none;
entrytitle "Spline Fit with Confidence Bands";
layout overlay / cycleattrs=true;
modelband "cliband" / name="confband1" display=all
legendlabel="90% CLI" datatransparency=0.4;
modelband "clmband" / name="confband2" display=all
legendlabel="90% CLM" datatransparency=0.4;
scatterplot x=weight y=mpg_highway /
markerattrs=(size=4pt symbol=circle)
datatransparency=0.3;
pbsplineplot x=weight y=mpg_highway / name="fitline"
clm="clmband" cli="cliband"
alpha=0.1 legendlabel="Spline Fit"
lineattrs=(pattern=solid thickness=2px);
discretelegend "fitline" "confband1" "confband2";
endlayout;
endgraph;
end;
run;
run;
MOSAICPLOTPARM Statement
Creates a mosaic plot from pre-summarized categorical data.
Restriction: You can use the MOSAICPLOTPARM statement in GRIDDED, LATTICE, and
REGION layouts only.
Note: On z/OS hosts, the mosaic plot categories might appear in an order other than data
order.
Syntax
MOSAICPLOTPARM CATEGORY=(column-list)
COUNT=non-negative-numeric-column | expression < /options >;
Label options
INSIDEVALUEATTRS=style-element | style-element (text-options ) | (text-
options )
specifies the color and font attributes of the category values when they
are located inside a tile.
LABELATTRS=style-element | style-element (text-options ) | (text-options )
specifies the color and font attributes of the category labels.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
VALUEATTRS=style-element | style-element (text-options ) | (text-options )
specifies the color and font attributes of the category values that are
located outside of the tiles.
VALUELOCATION=AUTO | INSIDE | OUTSIDE
specifies the location of the category column values in a two-way plot.
XVALUEFITPOLICY=ROTATE | NONE
specifies a policy for avoiding collisions along the width of the plot
among category values that are outside of the tiles.
YVALUEFITPOLICY=NONE | ROTATEALWAYS
specifies a policy for avoiding collisions along the height of the plot
among category values that are outside of the tiles.
ODS options
URL=string-column
specifies the URL of an HTML page to display when a tile is selected.
Required Arguments
CATEGORY=(column-list)
specifies a list of columns of category (classification) values.
Note When a SAS data set is plotted, the category values are arranged in
data order. When a CAS in-memory table is plotted, the category
values are arranged in ascending order of the formatted character
values or the unformatted numeric values of the category column or
columns.
COUNT=non-negative-numeric-column | expression
specifies the column of counts (pre-summarized) for each of the category value
combinations.
Tip You need to provide only the category crossings with nonzero
counts.
Optional Arguments
COLORGROUP=column | discrete-attr-var
specifies the category column to use for discrete fill colors for the tiles.
discrete-attr-var
specifies a discrete attribute map variable.
Each unique value of this column is mapped to the Color attribute of the
GraphData1–GraphDataN style elements that are in effect. If a discrete attribute
map variable is specified, the color mapping from its associated
DISCRETEATTRMAP statement is used.
Restriction This column or the associated column in the discrete attribute map
variable must be one of the columns in the category column list.
Note If you specify a column in a SAS data set, colors are mapped to
group values in data order. If you specify a column in a CAS in-
memory table, colors are mapped to group values in ascending
order of the group column character values or unformatted numeric
values.
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.
Tip To reverse the start and end colors of the ramp that is assigned to
the color model, use the REVERSECOLORMODEL= option.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
DATATRANSPARENCY=number
specifies the degree of the transparency of the tile fill, outlines, and the values
that are located inside the tiles if those values are displayed.
Default 0
display-options
a space-separated list of one or more display options, enclosed in
parentheses.
FILL
displays filled tiles
OUTLINE
displays the tile outline
LABELS
displays the category column labels
TICKS
displays the category ticks
VALUES
displays the category values
STANDARD
specifies FILL, OUTLINE, LABELS, and VALUES
ALL
specifies all features: FILL, OUTLINE, LABELS, TICKS, and VALUES
Default STANDARD
Interactions If neither FILL nor OUTLINE are present in the display-options list,
then filled and outlined tiles are displayed.
FILLATTRS=style-element | (fill-options )
specifies the appearance of the tile fill areas. See “General Syntax for Attribute
Options” on page 1599 for the syntax on using a style element. See “Fill Color
Options” on page 1600 for the available fill options.
GUTTER=dimension | (dimension-list )
specifies the gutter (gap) between the splits. The splits occur in the following
way:
n When a single dimension is specified, the dimension applies to the gap for
the last split, which has the smallest gap. From the next-to-last last split to
the first split, the gutter is doubled on each split. A single dimension has the
effect of setting a minimum gap for the plot. The following figure shows an
example in which GUTTER=10.
Note: The plot contains equally sized tiles for demonstration purposes.
In this case, the gaps are 30 pixels for the first split, 20 pixels for the second
split, and 10 pixels for the third split (minimum gap).
n When a list of dimension values is used, the values apply to each split in the
order in which they are specified. The following figure shows an example in
which GUTTER=(10 20 30).
MOSAICPLOTPARM Statement 691
In this case, the gaps are 10 pixels for the first split, 20 pixels for the second
split, and 30 pixels for the third split.
Interaction If one or more text options are specified and they do not include all
the font properties such as color, family, size, weight, and style, then
the non-specified properties are derived from the GraphValueText
style element.
Tip You can use the VALUEATTRS= option to change the text attributes
for the values that are located outside the plot area.
Interaction If one or more text options are specified and they do not include all
the font properties such as color, family, size, weight, and style, then
the non-specified properties are derived from the GraphLabelText
style element.
692 Chapter 6 / Plot Statements
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
OUTLINEATTRS=style-element | (line-options )
specifies the appearance of the tile outlines. See “General Syntax for Attribute
Options” on page 1599for the syntax on using a style element. See “Line Options”
on page 1602 for the available line options.
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by either
the ODS style that is in effect or by the COLORMODEL= option.
Default FALSE
See COLORMODEL=
“boolean ” on page xii for other Boolean values that you can use.
MOSAICPLOTPARM Statement 693
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles. The predefined roles are CATEGORY1–
CATEGORYn (in the order in which they are specified in the
CATEGORY= option), COUNT, COLORGROUP, and
COLORRESPONSE.
SQUARED=TRUE | FALSE
specifies that a square aspect ratio be used for the plot area.
Default FALSE
Tip Setting this option to TRUE makes the height of the plot the same as
its width, which can make it easier to compare the proportions.
See “boolean ” on page xii for other Boolean values that you can use.
TIP=(role-list ) | NONE
specifies the information that is displayed when the cursor is positioned over a
tile. If this option is used, then all of the information that is displayed by default
is replaced. Roles for columns that do not contribute to the bar chart can be
specified along with roles that do.
(role-list)
an ordered, space-separated list of unique MOSAICPLOTPARM roles and
user-defined roles.
NONE
suppresses data tips and URLs (if requested) from the plot.
Default The columns that are assigned to the category columns and
COUNT roles are automatically included in the data tip
information.
694 Chapter 6 / Plot Statements
Interaction The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
Example To display data tips for the columns that are assigned to the roles
X and Y as well as the user-defined role TIP1:
ROLENAME=(TIP1=OBS)
TIP=(TIP1 X Y)
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
MOSAICPLOTPARM Statement 695
URL=string-column
specifies the URL of an HTML page to display when a tile is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each tile that is to have an active link.
Example http://www.sas.com
Tips The URL value can be blank for some tiles, which means that no
action is taken when those tiles are selected. The URL value can be
the same for different tiles, which means that the same action is
taken when those tiles are selected.
Interaction If one or more text options are specified and they do not include all
the font properties such as color, family, size, weight, and style, then
the non-specified properties are derived from the GraphValueText
style element.
AUTO
locates the values for the second category in the CATEGORY= list that are
outside of the tiles.
If the first category in the CATEGORY= list has any missing crossings with
the second category, or if any of the second category values collide, then the
values are located inside the tiles per the default fit policy.
696 Chapter 6 / Plot Statements
INSIDE
for each category value, locates the values inside the largest tile.
OUTSIDE
locates the values outside of the tiles, in the plot area.
Default AUTO
XVALUEFITPOLICY=ROTATE | NONE
specifies a policy for avoiding collisions along the width of the plot among
category values that are outside of the tiles.
ROTATE
rotates the values if any of the values collide.
NONE
does not attempt to fit values that collide.
Default ROTATE
YVALUEFITPOLICY=NONE | ROTATEALWAYS
specifies a policy for avoiding collisions along the height of the plot among
category values that are outside of the tiles.
NONE
does not attempt to fit values that collide.
ROTATEALWAYS
rotates the values regardless of whether any of the values collide.
Default NONE
Details
A mosaic plot displays relative frequencies for categorical variables. Each crossing
of the categorical values is represented by a tile. The area of each tile is
proportional to the frequency of that crossing. The plot is the result of an iterative
process. The first iteration splits the plot area into tiles along the width according
to the relative frequency of the first category column values. Subsequent iterations
split the tiles from the previous iteration in the direction orthogonal to the previous
split by using the relative frequencies of each category column's values. By default,
the gap (or gutter) for each split gets progressively smaller, with a minimum gap of
3 pixels. You can use the GUTTER= option to specify a different gap for each split.
The following figure provides an example of a three-way mosaic plot, which has
three categories.
MOSAICPLOTPARM Statement 697
Note: The plot contains equally sized tiles for demonstration purposes.
In the example plot, the first split is along the width for CATEGORY 1. The second
split is along the height for CATEGORY 2. Finally, the third split is along the width
for CATEGORY 3. Notice how the gaps between the tiles get progressively smaller
from the first split to the last split.
Example Program
/* Summarize the SASHELP.CARS data for ORIGIN and TYPE */
proc summary data=sashelp.cars nway;
class origin type;
var mpg_highway;
output out=mileage mean=avgMpg N=count / noinherit;
run;
NEEDLEPLOT Statement
Creates a plot of observations as points connected to a baseline by vertical line segments.
Syntax
NEEDLEPLOT X=column | expression
Y=numeric-column | expression </options>;
Axes options
BASELINEINTERCEPT=number | RELATIVE
specifies the Y-intercept for the baseline.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
700 Chapter 6 / Plot Statements
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
DATALABEL=column
specifies labels at the data points.
DATALABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the data labels.
DATALABELPOSITION=AUTO | TOPRIGHT | TOP | TOPLEFT | LEFT | CENTER |
RIGHT | BOTTOMLEFT | BOTTOM | BOTTOMRIGHT
specifies the location of the data labels relative to the end of the needle
lines and markers, if displayed.
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if
needed.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
DATALABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the data label
blocks.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
DISCRETEOFFSET=number
specifies an amount to offset all needle lines and markers from discrete X
values when graphing multiple response variables side by side on a
common axis.
GROUP=column | discrete-attr-var | expression
NEEDLEPLOT Statement 701
creates a distinct set of needle lines, markers, and data labels for each
unique group value of the specified column.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies whether grouped needle lines are overlaid or clustered around
the category midpoints on a discrete axis or around the intervals on an
interval axis.
GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
specifies the ordering of the groups within a category.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
ODS options
URL=string-column
specifies an HTML page to display when a needle or marker is selected.
Required Arguments
X=column | expression
specifies a column or expression for the X values.
Y=numeric-column | expression
specifies a numeric column or numeric expression for the Y values.
Optional Arguments
BASELINEATTRS=style-element | (line-options)
specifies the appearance of the baseline.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
BASELINEINTERCEPT=number | RELATIVE
specifies the Y-intercept for the baseline. Prior to SAS 9.4M5, the baseline is
always displayed in the chart, whether for a specified value or for the default
702 Chapter 6 / Plot Statements
value. Starting with SAS 9.4M5, the baseline display is controlled by the
DISPLAYBASELINE= option, which is ON by default.
number
specifies the Y-intercept value to use for the baseline.
Tips The baseline does not add a tick or a tick value to the axis. To
label the baseline, you can overlay a REFERENCELINE
statement with the same Y value and use its CURVELABEL
option.
RELATIVE
places the baseline at the Y-axis tick mark closest to the minimum of the
range for the needle data points.
Default 0
CLUSTERWIDTH=number
specifies the width of the group clusters as a fraction of the midpoint spacing or
bin width.
Default 0.85
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
Requirement For this option to take effect, the GROUP= option must also be
specified, and the GROUPDISPLAY= option must be set to
CLUSTER.
DATALABEL=column
specifies labels at the data points.
Note The position of the labels is adjusted to prevent the labels from
overlapping.
Interactions For this option to have any effect, the DATALABEL= option must
also be specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO
uses a data-label collision avoidance algorithm to position the labels.
Note When AUTO is in effect, in some cases, the data label font size might
be reduced in order to avoid overlapping labels and markers.
TOPRIGHT
TOP
TOPLEFT
LEFT
CENTER
RIGHT
BOTTOMLEFT
BOTTOM
BOTTOMRIGHT
specifies a location for all of the data labels.
704 Chapter 6 / Plot Statements
Default AUTO
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters. When
set to TRUE, the data label is split unconditionally at each occurrence of any of
the specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the data label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
TRUE
drops the split characters from the data label.
FALSE
includes the split characters in the data label.
The following figure shows an example of a data label with the following
specifications:
n the data label text for this label is Product*Group*A
n DATALABELSPLIT=TRUE
n DATALABELSPLITCHARDROP=TRUE | FALSE
n DATALABELSPLITCHAR="*"
Default TRUE. The split characters are dropped from the data label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the DATALABELPOSITION= option.
706 Chapter 6 / Plot Statements
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The gray vertical line at the bottom of each label represents the
horizontal center of the text box for reference.
Default AUTO
Restriction Starting with SAS 9.4M1, the maximum number of skinned graphical
elements is limited to 200 per plot in an OVERLAY or PROTOTYPE
layout. When this limit is exceeded for a plot, the specified data skin
is not applied to that plot. In that case, use the DATASKINMAX=
option in your ODS GRAPHICS statement to increase the maximum
limit.
DATATRANSPARENCY=number
specifies the degree of the transparency of the needle lines, markers, and data
labels, if displayed.
Default 0
DISCRETEOFFSET=number
specifies an amount to offset all needle lines and markers from discrete X
values when graphing multiple response variables side by side on a common
axis.
Default 0 (no offset, all needle lines and markers are centered on the
discrete X values)
Range -0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. A positive offset is to the right. If the parent layout’s
axis options set REVERSE=TRUE, then the offset direction is also
reversed.
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
708 Chapter 6 / Plot Statements
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
(display-options)
a space-separated list of one or more options enclosed in parentheses.
STANDARD
displays needle lines without markers
ALL
displays needle lines with markers
Default STANDARD
ON
always displays the baseline.
OFF
does not display the baseline.
AUTO
displays the baseline if the baseline intercept is within the response-axis
range, excluding the minimum and maximum axis values.
This is the typical case when the needle plot contains both positive and
negative needles, and the default baseline intercept of 0 is used. If the
baseline intercept is equal to the minimum or maximum value of the
response-axis range, the baseline is not displayed.
Default ON
discrete-attr-var
specifies a discrete attribute map variable.
Interactions The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of marker
symbols, colors, and line patterns.
Notes The representations that are used to identify the groups can be
overridden. For example, each distinct group value might be
represented by a different line pattern, but the
LINEATTRS=(PATTERN=pattern) option could be used to assign
the same line pattern to all of the plot’s line patterns, letting line
color indicate group values. Likewise, LINEATTRS=(COLOR=color)
could be used to assign the same color to all lines, letting line
pattern indicate group values.
If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies whether grouped needle lines are overlaid or clustered around the
category midpoints on a discrete axis or around the intervals on an interval axis.
OVERLAY
centers the needle lines for matching category values on the midpoints.
The needle lines in each set of group values are superimposed on each other.
710 Chapter 6 / Plot Statements
CLUSTER
clusters the needle lines for matching category values around the midpoints.
Each cluster of group values is centered at the midpoint for the category.
Default OVERLAY
Interaction For this option to take effect, the GROUP= option must also be
specified.
Note When you plot a SAS data set, the items for each group value are
drawn in data order. When you plot a CAS in-memory table, they are
drawn in ascending order of the group column character values or
unformatted numeric values.
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Tip This option is useful when you want to reverse the category axis.
ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.
Interactions This option is ignored if the GROUP= option is not also specified.
By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.
Notes When plotting a SAS data set, attributes such as color, symbol, and
pattern are assigned to each group in DATA order by default. When
plotting a CAS in-memory table, attributes are assigned in
ascending order of the group column character values or
unformatted numeric values by default.
formatted values. The data order of the observations and the visual
attributes that are assigned to the group values remain unchanged.
In SAS 9.4M6 and earlier releases, when data stored in a CAS in-
memory table is used and DATA or REVERSEDATA is specified,
unpredictable results might occur. To generate consistent graphs in
that case, specify ASCENDING or DESCENDING. Starting with SAS
Viya 3.5 and SAS Studio 5.2, when data stored in a CAS in-memory
table is used and DATA or REVERSEDATA is specified, it is ignored,
and ASCENDING is used instead.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color, marker symbol, and line
pattern) to one of the GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
712 Chapter 6 / Plot Statements
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Default The Y-column label. If a label is not defined, then the Y-column
name is used.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
Interactions This option’s COLOR= suboption overrides the default behavior for
grouped data. When the COLOR= suboption is specified in that
case, all markers have the same color, and the marker symbol alone
distinguishes the markers.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
714 Chapter 6 / Plot Statements
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles X. Y, DATALABEL, INDEX, and GROUP.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a needle
line or marker. If this option is used, then it replaces all of the information that is
displayed by default. Roles for columns that do not contribute to the needle
plot can be specified along with roles that do.
(role-list)
an ordered, space-separated list of unique NEEDLEPLOT and user-defined
roles.
Example The following example displays data tips for the columns assigned
to the roles X and Y as well as the column Obs, which is not
assigned to any pre-defined NEEDLEPLOT role. The Obs column
must first be assigned a role.
ROLENAME=(TIP1=OBS)
TIP=(TIP1 X Y)
NONE
suppresses data tips and URLs (if requested) from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
NEEDLEPLOT Statement 715
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
URL=string-column
specifies an HTML page to display when a needle or marker is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each needle that is to have an active link.
Example http://www.sas.com
Tips The URL value can be blank for some X and Y pairs, meaning that
no action is taken when the corresponding needle or marker is
selected.
The URL value can be the same for any X and Y pairs. In that case,
the same action is taken when the needle or marker is selected for
those X and Y pairs.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
In the NEEDLEPLOT statement, the X column can specify character or numeric
values. The Y column must specify numeric values. For character columns, the X
axis is always of TYPE=DISCRETE. For numeric columns, the X axis is of
TYPE=LINEAR by default.
Example Program
proc template;
define statgraph needleplot;
begingraph;
entrytitle "IBM Stock Trend";
layout overlay;
needleplot x=date y=close /
baselineintercept=80 lineattrs=(color=blue);
endlayout;
endgraph;
end;
run;
PBSPLINEPLOT Statement
Creates a fitted penalized B-spline curve computed from input data.
Restriction: The PBSPLINEPLOT statement supports only models of one independent and one
dependent variable.
Tip: Starting with SAS 9.4M3, subpixel rendering is enabled by default. To disable
subpixel rendering, specify SUBPIXEL=OFF in the BEGINGRAPH statement or in an
718 Chapter 6 / Plot Statements
Syntax
PBSPLINEPLOT X=numeric-column | expression
Y=numeric-column | expression </<regression-options> <options>>;
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
CURVELABEL="string"
specifies a label for the spline curve.
CURVELABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the spline curve labels.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the spline curve label relative to the plot area.
PBSPLINEPLOT Statement 719
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a distinct set of curves from just the observations that
correspond to each unique group value of the specified column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Required Arguments
X=numeric-column | expression
specifies the column for the X values.
Y=numeric-column | expression
specifies the column for the Y values.
Optional Arguments
CURVELABEL="string"
specifies a label for the spline curve.
Interaction This option is not valid when the GROUP= option is specified.
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the spline curve label relative to the plot area.
INSIDE
locates the labels inside the plot area
OUTSIDE
locates the labels outside the plot area
Default INSIDE
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
AUTO
automatically positions the spline curve label near the curve boundary along
unused axes whenever possible (typically Y2 and X2) in order to avoid
collision with tick values.
MAX
forces the spline curve label to appear near maximum curve values
(typically, upper right)
MIN
forces the spline curve label to appear near minimum curve values (typically,
lower left)
START
forces the spline curve label to appear near the beginning of the curve.
PBSPLINEPLOT Statement 721
Tip This option is particularly useful when the curve line has a spiral
shape.
END
forces the spline curve label to appear near the end of the curve.
Tip This option is particularly useful when the curve line has a spiral
shape.
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the curve label at the specified split characters. When
a curve label is split, the label is split on each occurrence of the specified split
characters.
See “boolean ” on page xii for other Boolean values that you can use.
722 Chapter 6 / Plot Statements
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the curve label can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the curve label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no delimiter between each character and
enclosed in quotation marks.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the curve label text.
TRUE
drops the split characters from the curve label text.
FALSE
includes the split characters in the curve label text.
The following figure shows an example of a curve label with the following
specifications:
n CURVELABELPOSITION=MAX
n CURVELABEL="Product*Group*A"
n CURVELABELSPLIT=TRUE
n CURVELABELSPLITCHARDROP=TRUE | FALSE
n CURVELABELSPLITCHAR="*"
Note: The horizontal line to the left of the label represents the maximum end of
the curve for reference.
Default TRUE. The split characters are dropped from the curve label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the CURVELABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
724 Chapter 6 / Plot Statements
Note: The horizontal line to the left of each label represents the maximum end
of the curve for reference.
Default AUTO
DATATRANSPARENCY=number
specifies the degree of the transparency of the curve and curve label.
Default 0
discrete-attr-var
specifies a discrete attribute map variable.
Restriction Starting with SAS 9.4M5, the number of vertices for a patterned
line cannot exceed the maximum specified by the ODS GRAPHICS
statement option LINEPATTERNOBSMAX=. The default is 10,000.
If the limit is exceeded, the plot is not drawn and a note is written
to the SAS log stating that the limit has been exceeded. In that
PBSPLINEPLOT Statement 725
Requirement You must sort the data in ascending order by the specified group
column before you plot the data. If the plot data is a CAS in-
memory table, you must download the in-memory table to your
SAS client, and then sort it locally before you plot it.
Interactions The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of line colors
and line patterns.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a
column in a CAS in-memory table, the visual attributes for each
group value are assigned in ascending order of the group column
character values or of unformatted numeric values.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
726 Chapter 6 / Plot Statements
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color and line pattern) to one of
the GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Restriction Starting with SAS 9.4M5, the number of vertices for a patterned line
cannot exceed the maximum specified by the ODS GRAPHICS
statement option LINEPATTERNOBSMAX=. The default is 10,000. If
the limit is exceeded, the plot is not drawn and a note is written to
the SAS log stating that the limit has been exceeded. In that case,
increase LINEPATTERNOBSMAX= to the value suggested in the
note or change the line pattern to SOLID.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
PBSPLINEPLOT Statement 727
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example TIPFORMAT=(Y=6.2)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Requirement To enable data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
728 Chapter 6 / Plot Statements
Note The columns assigned to the X, Y, and GROUP (if assigned) roles
are automatically included in the data tip information.
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example TIPLABEL=(Y="Curve")
Default The column label or column name of the column assigned to the role.
Note The columns assigned to the X, Y, and GROUP (if assigned) roles are
automatically included in the data tip information.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Default 0.05
CLI="name"
produces confidence limits for individual predicted values for each observation.
Interaction name is a unique name within the template that is case sensitive and
cannot contain spaces. It must be assigned in order for the
confidence limits to be computed. To display confidence limits, you
PBSPLINEPLOT Statement 729
CLM="name"
produces confidence limits for a mean predicted value for each observation.
Interaction name is a unique name within the template that is case sensitive and
cannot contain spaces. It must be assigned in order for the
confidence limits to be computed. To display confidence limits, you
must use this name as the required argument of a MODELBAND
statement. See the example in the section “Example:
PBSPLINEPLOT Statement” on page 731 .
DEGREE=non-negative-integer
specifies the degree of B-spline.
Default 3
Restriction Starting with SAS 9.4M2, DEGREE= and NKNOTS= cannot be set to
0 simultaneously. When both are set to 0, an error results.
FREQ=numeric-column
specifies a column in the input data set that represents the frequency of
occurrence of the current observation, essentially treating the data set as if
each observation appeared n times, where n is the value of the FREQ column for
the observation. Noninteger values of the FREQ column are truncated to the
largest integer less than the FREQ value. The observation is used in the analysis
only if the value of the FREQ column is greater than or equal to 1.
MAXPOINTS=positive-integer
specifies the maximum number of predicted points generated for the spline
curve as well as any confidence limits.
Default 201
NKNOTS=non-negative-integer
specifies the number of evenly spaced internal knots. By default, a large number
of knots (100) is specified, which allows for an extreme lack of smoothness in
the results. However, the final function is typically much smoother due to the
penalty. When SMOOTH=0 is specified, you should typically ask for many fewer
knots than the default, since there is no penalty for lack of smoothness. For
example, ten or fewer knots is usually enough to follow the functional form
found in most data.
Default 100
Restriction Starting with SAS 9.4M2, MKNOTS= and DEGREE= cannot be set to
0 simultaneously. When both are set to 0, an error results.
730 Chapter 6 / Plot Statements
SMOOTH=AUTO | non-negative-number
specifies a smoothing parameter value.
AUTO
automatically selects a smoothing parameter value that minimizes a lack-of-
smoothness penalty.
non-negative-number
specifies a smoothing parameter value.
Range [0,1]
Default AUTO
WEIGHT=numeric-column
specifies a column in the input data set that contains values to be used as a
priori weights for a penalized B-spline fit. If an observation’s weight is zero,
negative, or missing, then the observation is deleted from the analysis.
Interaction Starting with SAS 9.4M2, when the CLI= option is used with this
option, the confidence band for individual predicted values is
displayed as a high-low chart instead of a band.
Details
The PBSPLINEPLOT statement supports only models of one independent and one
dependent variable. For more information about the fitting methodology, see The
TRANSREG Procedure in SAS/STAT User’s Guide.
1 use the CLI= or CLM= option to declare a name for the confidence level
Example Program
proc template;
define statgraph pbsplineplot;
begingraph;
entrytitle "Spline Fit";
layout overlay;
scatterplot x=weight y=mpg_highway /
datatransparency=0.7;
pbsplineplot x=weight y=mpg_highway / name="fitline"
alpha=0.05 legendlabel="Spline Fit";
discretelegend "fitline";
endlayout;
endgraph;
end;
run;
PIECHART Statement
Creates a pie chart that is computed from input data.
Syntax
PIECHART CATEGORY=column | discrete-attr-var | expression </options>;
specifies which degree between 0 and 360 serves as the starting position
for the first pie slice.
Grouping options
GROUP=column | expression
creates a separate concentric annulus (or stacked cylinders) for each
unique group value of the specified column.
GROUPGAP=dimension
specifies a dimension for the optional gap that can be displayed between
each annulus of a grouped pie.
GROUPLABELOPTS=(grouplabel-options)
specifies text attributes, location, and other options for displaying group
labels.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the Group column are included in the
pie.
OTHERSLICE=TRUE | FALSE
specifies whether to consolidate smaller pie slices into a single slice that
represents “other” values that are in the data, or whether to display those
smaller slices as separate pie slices.
Label options
DATALABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the slice labels.
DATALABELCONTENT=ALL | STANDARD | NONE | (content-options)
specifies the information to display in the slice labels.
DATALABELLOCATION=AUTO | INSIDE | OUTSIDE | CALLOUT
specifies whether to display the slice labels within the pie slices or
outside of the pie circumference.
LABELFITPOLICY=NONE | DROP
specifies the label fitting policy to be used if a particular label does not
fit within the pie slice.
ODS options
URL=string-column
specifies an HTML page to display when a pie slice is selected.
Statistics options
STAT=FREQ | PCT | SUM | MEAN
specifies the statistic to be computed.
Required Argument
CATEGORY=column | discrete-attr-var | expression
specifies the column for the category values. Duplicated values of CATEGORY
are summarized into a unique value. All values are treated as discrete.
discrete-attr-var
specifies a discrete attribute map variable.
Optional Arguments
CATEGORYDIRECTION=COUNTERCLOCKWISE | CLOCKWISE
specifies whether to display the pie slices in counterclockwise or clockwise
sequence.
Default COUNTERCLOCKWISE
Tip The START= option controls the starting angle for the first pie slice.
CENTERFIRSTSLICE=TRUE | FALSE
specifies whether the first pie slice is centered on the starting angle or starts on
the starting angle.
The following figure shows the effect of this option on a pie chart in which Asia
is the first category slice, the starting angle is 0 degrees, and the category
direction is counterclockwise.
PIECHART Statement 735
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
ALL
displays all available information
STANDARD
equivalent to specifying the two content-options CATEGORY and
RESPONSE
NONE
does not display slice labels
(content-options)
a space-separated list of one or more of the following options enclosed in
parentheses:
CATEGORY
displays the CATEGORY value
PERCENT
displays the PERCENT value when STAT=FREQ or STAT=PCT. When
STAT=MEAN or STAT=SUM, it displays nothing
736 Chapter 6 / Plot Statements
RESPONSE
displays the statistic that is requested in the STAT= option.
Note The position of the labels is adjusted to prevent the labels from
overlapping.
AUTO
automatically selects either INSIDE, OUTSIDE, or CALLOUT to optimize the
label position
INSIDE
locates the slice labels inside the pie slices.
Note: If a particular label does not fit within the pie slice, then the fit policy
takes effect (set by the LABELFITPOLICY= option).
OUTSIDE
locates the slice labels outside of the pie circumference.
CALLOUT
locates the slice labels outside of the pie circumference and draws a line
from the label to its slice.
Default AUTO
Note When OUTSIDE or CALLOUT is specified and there is not enough space
to display one or more of the labels, the labels are suppressed.
PIECHART Statement 737
Requirement For this option to have any effect, DISPLAY= FILL must be in
effect. Otherwise, this option is ignored.
When a data skin is applied, all slice outlines are set by the skin,
and the OUTLINEATTRS= option is ignored.
DATATRANSPARENCY=number
specifies the degree of the transparency of all pie slices, outlines, and text.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the pie
slices. The OTHERSLICEOPTS= option can be used to specify
transparency for the “other” slice. You can combine this option with
FILLATTRS= and with OTHERSLICEOPTS= to set one transparency for
738 Chapter 6 / Plot Statements
the outlines and text but a different transparency for the pie slices.
Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
DISPLAY=(display-options) | STANDARD
specifies which pie-slice options to display.
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
OUTLINE
displays the pie-slice outline.
The default outline properties are set by the GraphOutline style element.
FILL
displays the pie-slice fill color.
The default colors are set by the Color attribute of the GraphData1–
GraphDataN style elements. The fill color of the “other” slice (if shown) is
from the Color attribute of the GraphOther style element. If FILL is not
specified, then an opaque pie is drawn using the background color of the
containing layout.
STANDARD
specifies OUTLINE and FILL
Default STANDARD
Interaction For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element value.
GROUP=column | expression
creates a separate concentric annulus (or stacked cylinders) for each unique
group value of the specified column. The grouped rings are displayed in data
order.
Restriction The PIECHART GROUP= option does not honor the ODS
GRAPHICS statement GROUPMAX= option.
Interactions When this option is used, the unique column values are found and
then the slice colors are taken from the GraphData1–GraphDataN
style elements.
Missing values in the data can affect the group order. You can use
the INCLUDEMISSINGGROUP= option to manage missing group
values. In addition, you can use
INCLUDEMISSINGDISCRETE=TRUE in the BEGINGRAPH
statement to create pie slices for missing CATEGORY values.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
Tips This option creates only rings of pies. To create a grid of pies,
specify the PIECHART statement within a LAYOUT LATTICE,
LAYOUT DATALATTICE, or LAYOUT DATAPANEL statements.
740 Chapter 6 / Plot Statements
See FILLATTRS=
GROUPGAP=
GROUPLABELOPTS=
GROUPGAP=dimension
specifies a dimension for the optional gap that can be displayed between each
annulus of a grouped pie.
Default 0
Restriction For this option to take effect, the GROUP= option must also be
specified.
Interaction If the specified dimension is too large for the area that is available to
the pie chart, then the results might be unexpected.
Note The size of the inner pie remains the same regardless of the
GROUPGAP= value.
GROUPLABELOPTS=(grouplabel-options)
specifies text attributes, location, and other options for displaying group labels.
The following grouplabel-options are available. One or more options can be
specified as space-separated name = value pairs.
AUTO
specifies the column label of the GROUP= column or the column name of
the GROUP= column, if no column label exists.
NONE
specifies that no label is displayed
"string"
specifies a string to use as the label
Default AUTO
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
PIECHART Statement 741
LOCATION=RIGHT | LEFT
specifies whether the block of text for group labeling appears to the right or
left of the pie.
Default RIGHT
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Default The group label and values are shown as a block of text to the right
or left of the pie. Slice labels are moved to the inside of the pie
slices. A line is drawn from each group value to its annulus (or
cylinder).
Restriction For this option to take effect, the GROUP= option must also be
specified.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the Group column are included in the pie.
Default TRUE
Restriction For this option to take effect, the GROUP= option must also be
specified.
See “boolean ” on page xii for other Boolean values that you can use.
LABELFITPOLICY=NONE | DROP
specifies the label fitting policy to be used if a particular label does not fit
within the pie slice.
NONE
draws each label regardless of whether it fits within the slice region.
DROP
drops labels that do not fit within the slice region, but draws labels that do
fit.
Default NONE
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
OTHERSLICE=TRUE | FALSE
specifies whether to consolidate smaller pie slices into a single slice that
represents “other” values that are in the data, or whether to display those
smaller slices as separate pie slices. If this option is set to FALSE, then all
unique category values appear as slices. If this option is set to TRUE, then some
of the smaller slices might be combined into a single slice, referred to as the
Other slice.
Default TRUE
Tip To set the properties of the “other” slice, use the OTHERSLICEOPTS=
option.
See “boolean ” on page xii for other Boolean values that you can use.
OTHERSLICEOPTS=(other-slice-options)
specifies the properties of the Other slice. Example:
piechart category=region / name="p"
datalabelcontent=(percent) datalabellocation=inside
otherslice=true
othersliceopts=(type=percent percent=11 label="Other Regions") ;
PIECHART Statement 743
The following other-slice-options values are available. You can specify one or
more options as space-separated name = value pairs.
TYPE=PERCENT | MAXSLICES
specifies which method to use to determine the size of the Other slice.
PERCENT
uses the percentage that is set by the PERCENT= suboption.
MAXSLICES
uses the count that is set by the MAXSLICES= suboption.
Default PERCENT
MAXSLICES=positive-integer
specifies the maximum number of category values to represent with pie
slices.
Default 10
Interactions For this option to have any effect, TYPE=MAXSLICES must also
be specified among the suboptions for OTHERSLICEOPTS=.
The slices are counted in the order in which they are displayed.
This order is affected by the CATEGORYDIRECTION= option.
PERCENT=percent-of-total
collects all category values with response values less than or equal to the
specified percent-of-total value into the Other slice.
Default 4. Any original slice that represents 4% or less of the total is put
in the Other category.
Range 0–100
Interaction For this option to have any effect, TYPE=PERCENT must also be
specified among the suboptions for OTHERSLICEOPTS=.
LABEL="string"
specifies a label for the Other slice.
Default "OTHER"
This option does not affect the appearance of the area fill for the remaining
slices.
See “General Syntax for Attribute Options” on page 1599 for the
syntax for using a style-element value.
Interactions For this option to have any effect, outlines must be enabled by the
ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
START=degrees
specifies which degree between 0 and 360 serves as the starting position for
the first pie slice. A value of 0 degrees corresponds to the three o'clock position.
Degrees can be either positive or negative. Positive values move the starting
position counterclockwise, and negative values move the starting position
clockwise. From the starting point specified by this option, the slices are drawn
in the direction specified by the CATEGORYDIRECTION= option.
Default 0
Range 0 to 360
SUM
MEAN
Defaults SUM for pie charts that specify the RESPONSE= argument
PIECHART Statement 745
FREQ for pie charts that do not specify the RESPONSE= argument
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a pie
slice. If this option is used, then it replaces all of the information that is
displayed by default.
(role-list)
an ordered, space-separated list of unique PIECHART roles.
Example The following example displays data tips for the columns assigned
to the roles CATEGORY and RESPONSE.
TIP=(CATEGORY RESPONSE)
NONE
suppresses data tips and URLs (if requested) from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example TIP=(RESPONSE)
TIPFORMAT=(RESPONSE=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
746 Chapter 6 / Plot Statements
Example TIP=(RESPONSE)
TIPLABEL=(RESPONSE="Average Sales")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
URL=string-column
specifies an HTML page to display when a pie slice is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each pie slice that is to have an active link.
Example http://www.sas.com
Restriction A generated Other slice does not have a URL. See OTHERSLICE=.
Requirement To generate a plot with selectable pie slices, you must include an
ODS GRAPHICS ON statement that specifies the IMAGEMAP
option, and you must write the output to the ODS HTML
destination.
Tips The URL value can be blank for some pie slices, meaning that no
action is taken when the corresponding slice is selected.
The URL value can be the same for any CATEGORY and
RESPONSE pairs. In that case, the same action is taken when the
pie slices for those pairs are selected.
Details
The input data for the PIECHART statement is raw, unsummarized input data. The
PIECHART performs discrete binning for the Category column and calculates
PIECHART Statement 747
appropriate summarization statistics (sum, mean, and so on) based on the setting
for the STAT= option.
The fill color of each pie slice is derived from the Color attribute of the
GraphData1–GraphDataN style elements as described in “Attribute Rotation
Patterns” in SAS Graph Template Language: User’s Guide. The default order of the
pie slices depends on the data type of the CATEGORY values:
n For numeric data, the slices appear in the ascending order of the unformatted
data values.
n For discrete data, the slices appear in data order.
You can use the START= and CATEGORYDIRECTION= options to control the pie
slice positions and display order.
By default, the pie slices are labeled with the CATEGORY and RESPONSE values,
which are displayed inside the slices. You can use the DATALABELLOCATION= and
DATALABELCONTENT= options to control where the pie slices are labeled and the
label content.
By default, if two or more slices take up less than 4% of a pie, then an “other” slice
is created by consolidating those small slices. To change the default criteria, use
the OTHERSLICE= and OTHERSLICEOPTS= options. The calculated “other” slice is
displayed as the last slice in the pie, and as the last legend entry for the pie. If a
category value is the same as the “other” slice label, then two slices might be
displayed with the same label ("Other" by default) and different fill attributes. In
that case, both slices are represented in the pie legend.
Note: The PIECHART statement does not honor the MISSING= system option.
Regardless of the MISSING= system option value, unless a user-defined format is
applied to the value, the default missing-numeric-value character (.) is used to
depict missing numeric values.
Example Program
proc template;
define statgraph simplepie;
begingraph;
entrytitle "Car Models by Origin";
layout region;
piechart category=origin / datalabellocation=outside;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.cars
template=simplepie;
run;
POLYGONPLOT Statement
Draws a polygon from data that is stored in a data set.
Restriction: The POLYGONPLOT statement does not support CAS in-memory tables. If the
polygon plot data is stored in a CAS table, the polygon plot is not drawn.
Note: This statement is valid starting in SAS 9.4M1.
Tip: Starting with SAS 9.4M3, you can use subpixel rendering with this statement. It is
enabled by default. To disable subpixel rendering, specify SUBPIXEL=OFF in the
POLYGONPLOT Statement 749
Syntax
POLYGONPLOT X=column | expression Y=column | expression
ID=column | expression< /options(s) >
Axes options
750 Chapter 6 / Plot Statements
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
LABEL=column | expression
specifies the label for the polygon.
LABELATTRS=style-element | style-element (text-options ) | (text-options )
specifies the color and font attributes of the polygon label.
LABELLOCATION=INSIDEBBOX | OUTSIDEBBOX | OUTSIDE
specifies the location of the polygon label.
LABELPOSITION=CENTER | XMIN | XMAX | YMIN | YMAX
specifies the position of the polygon label with respect to the label
location.
LABELSPLIT=TRUE | FALSE
specifies whether to split the polygon label at the specified split
characters.
LABELSPLITCHAR="character-list"
specifies one or more characters on which the polygon label can be split
if needed.
LABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the polygon label.
LABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the polygon label
blocks.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
GROUP=column | discrete-attr-var | expression
POLYGONPLOT Statement 751
ODS options
URL=string-column
specifies an HTML page that is displayed when the polygon is selected.
Required Arguments
X=column | expression
specifies the column for the X values.
Note A missing value in the X column signals the start of the data for a hole in
the polygon. See “Drawing Holes in a Polygon” on page 773.
Y=column | expression
specifies the column for the Y values.
Note A missing value in the Y column signals the start of the data for a hole in
the polygon. See “Drawing Holes in a Polygon” on page 773.
ID=column | expression
specifies the column that contains the ID value that is associated with each
polygon.
Requirements All of the observations for a single polygon must have the same
ID value.
When multiple polygons are defined in the same data set, all of
the observations for a given ID must be defined contiguously.
Interspersing the ID observations in the data set can produce
unexpected results.
Optional Arguments
ANTIALIAS=AUTO | OFF
specifies whether anti-aliasing is turned off for this plot.
AUTO
specifies that anti-aliasing is controlled by the ANTIALIAS= option in the
ODS GRAPHICS statement.
OFF
specifies that anti-aliasing is always disabled for this plot.
Default AUTO
Interaction This option overrides the ANTIALIAS= option in the ODS GRAPHICS
statement.
BACKLIGHT=number | AUTO
specifies a back-light effect for the polygon label text.
number
specifies the degree of the back-light effect.
AUTO
the system selects an appropriate level for the back-light effect.
The following figure shows the effect on a polygon label located inside the
polygon bounding box.
The back light is based on text color. For dark colors, a contrasting white back-
light effect is used. For lighter colors, a contrasting black back-light effect is
used. The following figure shows the two back-light types when BACKLIGHT=1.
POLYGONPLOT Statement 753
Interaction The LABEL= option must be specified for this option to have any
effect.
Note If the background color is white, the white backlight effect for dark
text colors is not visible. Conversely, if the background color is
black, the black backlight effect for light text colors is not visible.
Tip The BACKLIGHT= option is most effective when the text color has a
low level of contrast with the background or when the background is
cluttered.
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.
Tip To reverse the start and end colors of the ramp that is assigned to
the color model, use the REVERSECOLORMODEL= option.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
Interactions Prior to SAS 9.4M5, when the GROUP= option is specified with the
COLORRESPONSE= option, the GROUP= option is ignored.
Starting with SAS 9.4M5, the COLORRESPONSE= option controls
the color of the group fill patterns when the fill patterns are
displayed.
Requirement For this option to have any effect, the DISPLAY= option must
include FILL.
When a data skin is applied, all polygon outlines are set by the skin
and the OUTLINEATTRS= option is ignored.
DATATRANSPARENCY=number
specifies the degree of the transparency of the polygon fill, outline, and label,
when these attributes are displayed.
Default 0
Tip You can use the FILLATTRS= option to set transparency for just the
filled polygon areas. You can combine this option with FILLATTRS=
to set one transparency for the polygon outline and label and a
different transparency for the polygon fill. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
756 Chapter 6 / Plot Statements
(display-options)
specifies a space-separated list of one or more display options enclosed in
parentheses.
FILL
displays the polygon fill
FILLPATTERN
displays a pattern-filled polygon
Tip By default, this option has no effect if the active ODS style does
not specify a fill pattern. To display a fill pattern in that case,
select an ODS style that supports fill patterns or use the
FILLPATTERNATTRS= option to specify a fill pattern for the
polygon.
OUTLINE
displays the polygon outline
STANDARD
specifies OUTLINE only
ALL
specifies all features: FILL, FILLPATTERN, and OUTLINE
Interactions For this option to have any effect, the fill must be enabled by the
ODS style or by the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLPATTERNATTRS=style-element | (fill-pattern-options)
specifies the appearance of the pattern-filled areas.
Interactions For this option to take effect, the DISPLAY= option must include
FILLPATTERN among the display options.
Tip In order to change the fill pattern for each group value in ODS
styles such as HTMLBlue that use color-priority attribute rotation,
specify ATTRPRIORITY=NONE in an ODS GRAPHICS statement or
in the BEGINGRAPH statement in your graph template. For more
information, see “Attribute Rotation Patterns” in SAS Graph
Template Language: User’s Guide.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
discrete-attr-var
specifies a discrete attribute map variable.
A distinct polygon is created for each group value by varying the visual
attributes of the polygon display features. The display features are controlled
by the current ODS style or by the DISPLAY= option. The default group
appearance for each display feature is shown in the following table.
Display
Feature 1 Style Attributes That Control Default Group Appearance
Requirement The group value must remain constant for the same ID value.
Otherwise, the results are unpredictable.
Note The group values should remain constant for the same ID value.
POLYGONPLOT Statement 759
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Restriction This option is ignored and missing group values are not displayed
when ID= and GROUP= specify the same values.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
LABEL=column | expression
specifies the label for the polygon.
Note The label text should be the same for all of the observations for a
polygon ID. When different labels are specified for the same ID, the
label that is specified in the first observation for that ID is used.
Tips The default label text color is based on the use of polygon fill and
outline colors, and on whether the GROUP= or COLORRESPONSE=
option is specified. To change the label text color and font, use the
LABELATTRS= option.
Interaction If one or more text options are specified and they do not include all
of the font properties (such as color, family, size, weight, and style),
then the non-specified properties are derived from the
GraphLabelText style element or from a GraphData1–GraphDataN
style element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
INSIDEBBOX
locates the label inside the bounding box of the polygon.
OUTSIDEBBOX
locates the label outside the bounding box of the polygon but inside the plot
area.
OUTSIDE
locates the label outside the plot area.
Default INSIDEBBOX
Interaction The LABEL= option must be specified for this option to have any
effect.
Tip The label's exact position is relative to the polygon's X and Y data
ranges and is determined by the combination of this option and the
LABELPOSITION= option.
CENTER
centers the label in the polygon’s bounding box
XMIN
positions the label at the polygon's minimum X value and centers it in the Y-
value range
XMAX
positions the label at the maximum X value and centers it in the Y-value
range
POLYGONPLOT Statement 761
YMIN
positions the label at the minimum Y value and centers it in the X-value
range
YMAX
positions the label at the maximum Y value and centers it in the X-value
range
The following figure shows the label positions for each of the label locations
that are specified by the LABELLOCATION= option.
LABELSPLIT=TRUE | FALSE
specifies whether to split the polygon label at the specified split characters.
When this option is set to TRUE, the polygon label is split unconditionally at
each occurrence of any of the specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
LABELSPLITCHAR="character-list"
specifies one or more characters on which the polygon label can be split if
needed. When multiple split characters are specified, each character in the list
is treated as a separate split character unless the specified characters appear
consecutively in the polygon label. In that case, all of the specified split
characters together are treated as a single split character.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
LABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the polygon label.
POLYGONPLOT Statement 763
TRUE
drops the split characters from the polygon label.
FALSE
includes the split characters in the polygon label.
Default TRUE. The split characters are dropped from the polygon label.
Requirement The LABEL= option and the LABELSPLIT=TRUE option must also
be specified.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the LABELPOSITION= option.
XMIN RIGHT
XMAX LEFT
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The gray vertical line at the bottom of each label represents the
horizontal center of the text box for reference.
Default AUTO
Requirement The LABEL= option and the LABELSPLIT=TRUE option must also
be specified.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
Interactions For this option to have any effect, outlines must be enabled by the
ODS style or by the DISPLAY= option.
POLYGONPLOT Statement 765
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by either
the ODS style that is in effect or by the COLORMODEL= option.
Default FALSE
See COLORMODEL=
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
766 Chapter 6 / Plot Statements
Requirement The role names that you choose must be unique and different from
the predefined roles ID, COLORRESPONSE, GROUP, LABEL, and
URL.
Rotating a polygon does not change data ranges that are reported to
the axes. As a result, clipping might occur in some cases.
AUTO
rotates the label with the rotation of the polygon.
NONE
does not rotate the label with the rotation of the polygon.
VERTICAL
rotates the label to a vertical position.
Default AUTO
Interaction The LABEL= option must be specified for this option to have any
effect.
TIP=(role-list ) | NONE
specifies the information to display when the cursor is positioned over the
polygon. If you use this option, it replaces all of the information that is displayed
by default. You can specify roles for columns that do not contribute to the
polygon plot along with roles that do.
POLYGONPLOT Statement 767
(role-list)
an ordered, space-separated list of unique POLYGONPLOT and user-defined
roles.
Example The following example displays the columns that are assigned to
the roles ID and URL, and the columns XOffset and YOffset in the
data tips. The XOffset and YOffset columns are not assigned to
any predefined POLYGONPLOT role, so they must first be assigned
a role:
ROLENAME=(TIP1=XOFFSET TIP2=YOFFSET)
TIP=(ID TIP1 TIP2 URL)
NONE
suppresses data tips and URLs (if requested) from the plot.
Default The columns that are assigned to the following roles are
automatically included in the data tip information: ID,
COLORRESPONSE or GROUP, LABEL, and URL.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip You can control the labels and formats for the TIP roles with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
768 Chapter 6 / Plot Statements
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
URL=string-column
specifies an HTML page that is displayed when the polygon is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each polygon that is to have an active link.
Example http://www.sas.com
Note The URL values should remain constant for the same ID value.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
POLYGONPLOT Statement 769
XOFFSET=numeric-column | expression
specifies an individual offset from the discrete X value on each vertex of the
polygon.
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. A positive offset is to the right on discrete X values. If
option REVERSE=TRUE is specified in the layout's X-axis options,
then the offset direction is also reversed.
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum offset and maximum offset. In some cases, setting a
discrete offset can cause clipping at each end of the axis. In those
cases, use the OFFSETMIN= and OFFSETMAX= axis options to
increase the axis minimum and maximum offsets in order to
accommodate the discrete offset.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YOFFSET=numeric-column | expression
specifies an individual offset from the discrete Y value on each vertex of the
polygon.
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. A positive offset is up on discrete Y values. If option
REVERSE=TRUE is specified in the layout's Y-axis options, then the
offset direction is also reversed.
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum offset and maximum offset. In some cases, setting a
discrete offset can cause clipping at each end of the axis. In those
cases, use the OFFSETMIN= and OFFSETMAX= axis options to
increase the axis minimum and maximum offsets in order to
accommodate the discrete offset.
770 Chapter 6 / Plot Statements
Details
Overview
The POLYGONPLOT statement draws a polygon from a series of X-Y value pairs
that are stored in a SAS data set. The first X-Y value pair defines the starting point
of the polygon. The next X-Y pair in the data specifies the coordinates of the first
vertex. A line segment is drawn from the starting point to the first vertex. For
subsequent X-Y pairs, a line segment is drawn from the previous vertex to the
current vertex. This pattern repeats until all of the segments have been drawn. If
the last segment does not close the polygon, then the POLYGONPLOT statement
automatically draws a segment from the last vertex back to the starting point in
order to close the polygon.
Using the POLYGONPLOT statement, you can draw any data-driven shape on your
graph, which enables you to highlight data features, outline data boundaries, and so
on. Unlike DRAW statements in a BEGINPLOYGON block, the following conditions
apply to the POLYGONPLOT statement:
n you need to modify only the polygon data in the graph data set to modify the
polygon. You do not need to modify the template code. (See “BEGINPOLYGON
Statement” on page 1405.)
n you can draw polygons between plots. The BEGINPOLYGON block and DRAW
statements can draw polygons only on top of or behind the graph.
If you want to draw multiple polygons, then your ID column must specify a unique
identifier value for each polygon. The identifier value associates the observations in
the data set with a specific polygon. All of the observations for each individual
polygon must be grouped together by ID and must be arranged in the order in which
the polygon segments are to be drawn.
The following table shows additional columns that you can use to customize your
polygon plot.
LABEL (p. 759) Numeric or Specifies the label for the polygon.
character
1 You can specify any valid column name for these columns in your data set.
Here is example data for a simple four-sided polygon that is identified as P1 and
that starts at point X=40, Y=100.
Polygon Data
Obs id x y
1 P1 40 100
2 P1 20 220
3 P1 160 200
4 P1 180 80
5 P1 40 100
The following figure shows how the polygon is drawn. Grid lines are provided to
help you locate the polygon vertices in the output.
772 Chapter 6 / Plot Statements
The polygon starting point is X=40, Y=100 (shown in red). From the starting point,
the segments are drawn in data order. Data order is in a clockwise direction, as
indicated by the gray arrow. Although the last observation (X=40, Y=100) is
provided in this example, it is not required. If the last observation is not provided in
the data, then the POLYGONPLOT statement draws the last segment automatically
in order to close the polygon.
For an example, see “Example 1: Drawing a Simple Polygon That Highlights Data” on
page 775.
Obs id x y label
1 1 0 0 ID=1
2 1 20 0
3 1 20 30
4 1 0 30
5 1 0 0
6 2 30 0 ID=2
7 2 50 0
8 2 40 30
9 2 30 0
10 3 60 0 ID=3
POLYGONPLOT Statement 773
11 3 80 5
12 3 80 15
13 3 70 30
14 3 60 30
15 3 60 0
In addition to the ID column, X column, and Y column, the Label column is added to
label the polygons in the output. Notice that the observations for each ID value are
grouped together in the data set. The observations for each ID must occur
contiguously in the data. Otherwise, unexpected results might occur.
The following figure shows how the polygons are drawn from this data. Grid lines
are provided to help you locate the polygon vertices in the output.
The polygons are drawn in the order in which they appear in the data: rectangle
(ID=1), triangle (ID=2), and polygon (ID=3). The red dot on each shape indicates the
starting point for that shape. The gray arrow indicates the direction in which the
segments are drawn for each shape.
2 To start the data for a hole, add an observation that has missing X and Y values.
The missing X and Y values signal the POLYGONPLOT statement that the
observations that follow define the data for a hole.
Here is example data for a simple polygon that has two holes.
Polygon Data
774 Chapter 6 / Plot Statements
Obs id x y
1 1 1 1
2 1 9 1
3 1 7 5
4 1 9 9
5 1 1 9
6 1 3 5
7 1 1 1
8 1 . .
9 1 3 8
10 1 7 8
11 1 6 6
12 1 4 6
13 1 3 8
14 1 . .
15 1 3 2
16 1 7 2
17 1 6 4
18 1 4 4
19 1 3 2
Observations 1–7 specify the data for the outer polygon. In observation 8, the X and
Y values are missing, which indicates the start of the data for the first hole.
Observations 9–13 define the data for the first hole polygon. Observation 14
indicates the start of the data for the second hole, which is defined by observations
15–19.
The following figure shows how the polygon is drawn from this data. Grid lines are
provided to help you locate the polygon vertices in the output.
The outer polygon is drawn first, starting at point X=1, Y=1. The segments are drawn
in data order, which is in a counterclockwise direction as indicated by the gray
arrow. The first hole is drawn next, starting at point X=3, Y=8. Its segments are
POLYGONPLOT Statement 775
drawn in a clockwise direction. The second hole is drawn last, starting at point X=3,
Y=2. Its segments are drawn in a counterclockwise direction.
Examples
1 11 0
;
run;
Details
To draw a single polygon, the data set must provide an X column, a Y column, and
an ID column. The data specifies the polygon vertices around the Setosa data in a
clockwise direction. A Label column is added to provide a label for the polygon in
the plot output. Concatenation of the Polydata and Sashelp.Iris data sets results in
missing values for the SCATTERPLOT statement grouping variable in the Iris data
set. By default, the SCATTERPLOT statement includes missing group values. To
exclude the missing group values, the INCLUDEMISSINGGROUP=FALSE option is
added to the SCATTERPLOT statement.
In the POLYGONPLOT statement, the DISPLAY= option specifies the polygon fill
only. The FILLATTRS= option specifies the fill color as yellow and a fill
transparency of 0.75. Rather than using draw statements to draw an annotation for
the polygon, this example uses the POLYGONPLOT statement label feature to
POLYGONPLOT Statement 777
label the polygon. The LABEL= option specifies the column in the data set that
contains the polygon label text. The LABELLOCATION= and LABELPOSITION=
options place the polygon label outside of and above the polygon’s bounding box.
To draw the polygon, the POLYGONPLOT statement starts at X=9, Y=2, and draws
a segment between each vertex in data order. The last vertex, X=11, Y=0, does not
close the polygon. To close the polygon, the POLYGONPLOT statement draws a
segment between X=11, Y=0 and X=9, Y=2 automatically.
If you want to highlight the Versicolor data instead of the Setosa data, then you
need only modify the data in the Polydata data set to draw a polygon around the
Versicolor data instead. You do not have to make any changes to the template
code.
REFERENCELINE Statement
Creates a horizontal or vertical reference line.
Syntax
REFERENCELINE X=x-axis-value | column | expression </options>;
Axes options
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
CURVELABEL="string" | column | expression
specifies a label for the reference line or lines.
CURVELABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the reference line label(s).
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the reference line label relative to the plot area.
CURVELABELPOSITION=AUTO | MAX | MIN
specifies the position of the reference line label relative to the reference
line.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the reference line label at the specified split
characters.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the reference line label can be
split if needed.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the reference line
label text.
CURVELABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the reference line
label block.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
DISCRETEOFFSET=number
780 Chapter 6 / Plot Statements
specifies an amount to offset all reference lines from the specified values
when the X or Y axis is discrete.
Required Arguments
You must use either the X= or the Y= argument in the REFERENCELINE statement.
X=x-axis-value | column | expression
specifies the X intercept of the reference line or lines.
Values must be the same type as the data type of the X axis. For
example, you should use numeric SAS date or time values (or SAS
date/time constants) for a time axis.
Values must be the same type as the data type of the Y axis.
Optional Arguments
CLIP=TRUE | FALSE
specifies whether the reference line data is to be considered when determining
the data range for the axis.
FALSE
specifies that the reference line values are to be considered when the axis
range is determined. The reference lines are drawn as follows based on the
axis type:
n For a discrete axis, the reference line values that are not already on the
axis are added to the end of the axis data list. When applicable, the axis
values are then sorted:
o If the axis values are numeric values, then they are sorted ordinally.
o If the axis values are character values and a sorting option is applied to
the axis, then they are sorted as specified by the sorting option.
Reference lines are then drawn at the specified locations.
n For a linear, log, or time axis, a new axis data list is created by performing
a mathematical union of the data values and the reference line values.
The reference lines are then drawn at the locations specified.
TRUE
specifies that the reference line values are not to be considered when the
axis range is determined. The reference lines are drawn as follows based on
the axis type:
n For a discrete axis, if the reference line value exactly matches a value on
the axis, a reference line is drawn at that location. Otherwise, the
reference line is not drawn.
Note: If the axis values are formatted, then the reference line value must
exactly match the formatted axis value in order for the line to be drawn.
n For a linear, log, or time axis, if the reference line value is within the axis
data range, then the reference line is drawn at the specified location.
Otherwise, the reference line is not drawn.
782 Chapter 6 / Plot Statements
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
Interaction For this option to take effect, the CURVELABEL= option must also
be used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the reference line label relative to the plot area.
Default OUTSIDE
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
AUTO
automatically positions the line label near the line boundary along unused
axes whenever possible (typically Y2 and X2) in order to avoid collision with
tick values.
MAX
forces the line label to appear near maximum line values (typically, the top
or right).
MIN
forces the line label to appear near minimum line values (typically, the
bottom or left).
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the reference line label at the specified split
characters. When a reference line label is split, the label is split on each
occurrence of the specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the reference line label can be split if
needed. When multiple split characters are specified, each character in the list
is treated as a separate split character unless the specified characters appear
consecutively in the reference line label. In that case, all of the specified split
characters together are treated as a single split character.
"character-list"
a list of one or more characters with no spaces between them enclosed in
quotation marks.
Notes When multiple characters are specified, the order of the characters
in the list is not significant.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the reference line label
text.
TRUE
drops the split characters from the reference line label text.
FALSE
includes the split characters in the reference line label text. When
CURVELABELSPLIT=TRUE and CURVELABELSPLITCHARDROP=FALSE,
each split character remains as the last character in the current line. The
characters that follow the split character, up to and including the next split
character, are then wrapped to the next line.
REFERENCELINE Statement 785
The following figure shows an example of a Y-axis reference line label with the
following specifications:
n CURVELABELPOSITION=MAX
n CURVELABEL="Product*Group*A"
n CURVELABELSPLIT=TRUE
n CURVELABELSPLITCHARDROP=TRUE | FALSE
n CURVELABELSPLITCHAR="*"
Note: The horizontal line to the left of the label represents the maximum end of
the reference line for reference.
Default TRUE. The split characters are dropped from the reference line
label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the CURVELABELPOSITION= option, as shown
in the following table.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The horizontal line to the left of each label represents the maximum end
of the reference line for reference.
Default AUTO
Restriction Starting with SAS 9.4M1, the maximum number of skinned graphical
elements is limited to 200 per plot in an OVERLAY or PROTOTYPE
layout. When this limit is exceeded for a plot, the specified data
skin is not applied to that plot. In that case, use the
REFERENCELINE Statement 787
DATATRANSPARENCY=number
specifies the degree of the transparency of the reference line.
Default 0
Note This option does not affect the reference line label.
DISCRETELINETHICKNESS=number
specifies the line thickness as a fraction of the midpoint spacing.
Default 1 (100%)
Range 0–1
DISCRETEOFFSET=number
specifies an amount to offset all reference lines from the specified values when
the X or Y axis is discrete.
Range -0.5 to +0.5 where 0.5 represents half the distance between discrete
ticks. A positive offset is to the right for a vertical reference line and
up for a horizontal reference line. If the layout's axis options set
REVERSE=TRUE, then the offset direction is also reversed.
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
788 Chapter 6 / Plot Statements
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
USEDISCRETETHICKNESS=TRUE | FALSE
specifies that the line thickness should be based on a fraction of the midpoint
spacing that is set by the DISCRETELINETHICKNESS= option.
Default FALSE
Requirement The axis type must be discrete. Otherwise, this option is ignored.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Restriction Another plot that establishes a data range for the designed axis
must be included.
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Restriction Another plot that establishes a data range for the designed axis
must be included.
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
Reference lines are always drawn perpendicular to the axes. They are drawn from
one axis boundary to the companion boundary (X to X2 or Y to Y2). Axis offsets do
not apply to reference lines.
If a column is used to generate multiple reference lines, then the column type
(numeric or string) must agree with the type of data presented on the axis.
790 Chapter 6 / Plot Statements
Examples
Example Program
Here is the SAS code for this example.
/* Create the template for the graph */
proc template;
define statgraph referenceline;
begingraph;
entrytitle "Line of Symmetry";
layout overlay / yaxisopts=(linearopts=(viewmin=0));
seriesplot x=x y=y;
referenceline x=3 /
lineattrs=(color=blue) curvelabel="X=3";
endlayout;
endgraph;
end;
run;
output;
end;
run;
Example Program
Here is the SAS code for this example.
/* Define the template for the graph */
proc template;
define statgraph referenceline;
begingraph;
entrytitle "Line of Symmetry";
layout overlay / yaxisopts=(linearopts=(viewmin=0));
seriesplot x=x y=y;
referenceline y=yR / curvelabel=label
lineattrs=(color=gray pattern=dot);
792 Chapter 6 / Plot Statements
endlayout;
endgraph;
end;
run;
Example Program
Here is the SAS code for this example.
/* Create the template for the graph */
proc template;
define statgraph referencelines;
begingraph;
entrytitle "Line of Symmetry";
layout overlay / yaxisopts=(linearopts=(viewmin=0));
seriesplot x=x y=y;
/* Use COLN() to specify the intercept values */
referenceline y=eval(coln(14, 5)) /
/* Use COLC() to specify a label for each reference line */
curvelabel=eval(colc("Y=14", "Y=5"))
lineattrs=(color=gray pattern=dot);
endlayout;
endgraph;
end;
run;
do X=0 to 8 by 0.25;
Y=(x-3)*(x-3) + 5;
output;
end;
run;
REGRESSIONPLOT Statement
Creates a fitted regression line or curve computed from input data.
Restriction: The REGRESSIONPLOT statement supports only models of one independent and
one dependent variable.
Tip: Starting with SAS 9.4M3, subpixel rendering is enabled by default. To disable
subpixel rendering, specify SUBPIXEL=OFF in the BEGINGRAPH statement or in an
ODS GRAPHICS statement. For information about the BEGINGRAPH statement
SUBPIXEL= option, see SUBPIXEL= on page 39. For information about the ODS
GRAPHICS statement SUBPIXEL= option, see “ODS GRAPHICS Statement” on
page 1561.
Syntax
REGRESSIONPLOT X=numeric-column | expression
Y=numeric-column | expression </<regression-options> <options>>;
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
794 Chapter 6 / Plot Statements
Label options
CURVELABEL="string"
specifies a label for the regression line.
CURVELABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the regression line labels.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the regression line label relative to the plot area.
CURVELABELPOSITION=AUTO | MAX | MIN | START | END
specifies the position of the regression line label relative to the
regression line.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the regression line label at the specified split
characters.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the regression line label can be
split if needed.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the regression line
label text.
CURVELABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the regression line
label block.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a distinct set of regression lines from just the observations that
correspond to each unique group value of the specified column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Required Arguments
X=numeric-column | expression
specifies the column for the X values.
Y=numeric-column | expression
specifies the column for the Y values.
Optional Arguments
CURVELABEL="string"
specifies a label for the regression line.
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
Interactions For this option to take effect, the CURVELABEL= option must also
be used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the regression line label relative to the plot area.
INSIDE
locates the labels inside the plot area
OUTSIDE
locates the labels outside the plot area
Default INSIDE
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
796 Chapter 6 / Plot Statements
AUTO
automatically positions the line label near the line boundary along unused
axes whenever possible (typically Y2 and X2) in order to avoid collision with
tick values.
MAX
forces the line label to appear near maximum line values (typically, upper
right).
MIN
forces the line label to appear near minimum line values (typically, lower
left).
START
forces the line label to appear near the beginning of the regression line.
Tip This option is particularly useful when the regression line has a
spiral shape.
END
forces the line label to appear near the end of the regression line.
Tip This option is particularly useful when the regression line has a
spiral shape.
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the regression line label at the specified split
characters. When a regression line label is split, the label is split on each
occurrence of the specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the regression line label can be split if
needed. When multiple split characters are specified, each character in the list
is treated as a separate split character unless the specified characters appear
consecutively in the regression line label. In that case, all of the specified split
characters together are treated as a single split character.
"character-list"
one or more characters with no delimiter between each character and
enclosed in quotation marks.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the regression line label
text.
TRUE
drops the split characters from the regression line label text.
FALSE
includes the split characters in the regression line label text. When
CURVELABELSPLIT=TRUE and CURVELABELSPLITCHARDROP=FALSE,
each split character remains as the last character in the current line. The
characters that follow the split character, up to and including the next split
character, are then wrapped to the next line.
The following figure shows an example of a regression line label with the
following specifications:
n CURVELABELPOSITION=MAX
n CURVELABEL="Product*Group*A"
n CURVELABELSPLIT=TRUE
n CURVELABELSPLITCHARDROP=TRUE | FALSE
n CURVELABELSPLITCHAR="*"
Note: The horizontal line to the left of the label represents the maximum end of
the regression line for reference.
Default TRUE. The split characters are dropped from the regression line
label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the CURVELABELPOSITION= option, as shown
in the following table.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The horizontal line to the left of each label represents the maximum end
of the regression line for reference.
Default AUTO
DATATRANSPARENCY=number
specifies the degree of the transparency of the regression line and line label.
Default 0
discrete-attr-var
specifies a discrete attribute map variable.
Requirement You must sort the data in ascending order by the specified group
column before you plot the data. If the plot data is a CAS in-
memory table, you must download the in-memory table to your
SAS client, and then sort it locally before you plot it.
Interactions The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of line colors
and line patterns.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a
column in a CAS in-memory table, the visual attributes for each
group value are assigned in ascending order of the group column
character values or of unformatted numeric values.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color and line pattern) to one of
the GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
802 Chapter 6 / Plot Statements
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
REGRESSIONPLOT Statement 803
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example TIPFORMAT=(Y=6.2)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Requirement To enable data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Note The columns assigned to the X, Y, and GROUP (if assigned) roles
are automatically included in the data tip information.
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example TIPLABEL=(Y="Curve")
Default The column label or column name of the column assigned to the role.
Note The columns assigned to the X, Y, and GROUP (if assigned) roles are
automatically included in the data tip information.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
804 Chapter 6 / Plot Statements
Regression Options
ALPHA=positive-number
specifies the confidence level to compute.
Default 0.05
CLI="name"
produces confidence limits for individual predicted values for each observation.
The confidence level is set by the ALPHA= option.
Interaction name is a unique name within the template that is case sensitive and
cannot contain spaces. It must be assigned in order for the
confidence limits to be computed. To display confidence limits, you
must use this name as the required argument of a MODELBAND
statement. See the example in “Example: REGRESSIONPLOT
Statement” on page 805 .
CLM="name"
produces confidence limits for a mean predicted value for each observation. The
confidence level is set by the ALPHA= option.
Interaction name is a unique name within the template that is case sensitive and
cannot contain spaces. It must be assigned in order for the
confidence limits to be computed. To display confidence limits, you
must use this name as the required argument of a MODELBAND
statement. See the example in “Example: REGRESSIONPLOT
Statement” on page 805 .
DEGREE=non-negative-integer
specifies the degree of the polynomial.
Default 1
FREQ=numeric-column
specifies a column in the input data set that represents the frequency of
occurrence of the current observation, essentially treating the data set as if
each observation appeared n times, where n is the value of the FREQ column for
the observation. Noninteger values of the FREQ column are truncated to the
REGRESSIONPLOT Statement 805
largest integer less than the FREQ value. The observation is used in the analysis
only if the value of the FREQ column is greater than or equal to 1.
MAXPOINTS=positive-integer
specifies the maximum number of predicted points generated for the regression
curve as well as any confidence limits.
Default 201
WEIGHT=numeric-column
specifies a column in the input data set that contains values to be used as a
priori weights for a regression fit. If an observation’s weight is zero, negative, or
missing, then the observation is deleted from the analysis.
Interaction Starting with SAS 9.4M2, when the CLI= option is used with this
option, the confidence band for individual predicted values is
displayed as a high-low chart instead of a band.
Details
The REGRESSIONPLOT statement creates a fitted regression line or curve
computed from input data. It supports only models of one independent and one
dependent variable. Information about the fitting methodology that the
REGRESSIONPLOT statement uses can be found in The TRANSREG Procedure in
SAS/STAT User’s Guide.
1 Use the CLI= or CLM= regression option(s) to declare a name for each
confidence level.
Example Program
proc template;
define statgraph regressionplot;
begingraph;
entrytitle "Regression Fit Plot";
layout overlay;
scatterplot x=weight y=mpg_highway /
datatransparency=0.7;
regressionplot x=weight y=mpg_highway /
name="fitline"
alpha=0.05 legendlabel="Regression Fit";
discretelegend "fitline";
endlayout;
endgraph;
end;
run;
SCATTERPLOT Statement
Creates a scatter plot of input data.
SCATTERPLOT Statement 807
Syntax
SCATTERPLOT X=column | expression
Y=column | expression < /options >;
specifies that the marker size should be based on fraction of the midpoint
spacing that is set by the DISCRETEMARKERSIZE= option.
XERRORLOWER=numeric-column | expression
specifies values for the lower endpoints on the X error bars. The error
bars are drawn from the markers to the endpoints.
XERRORUPPER=numeric-column | expression
specifies values for the upper endpoints on the X error bars.
YERRORLOWER=numeric-column | expression
specifies values for the lower endpoints on the Y error bars.
YERRORUPPER=numeric-column | expression
specifies values for the upper endpoints on the Y error bars.
Axes options
CLUSTERAXIS=AUTO | X | Y
specifies the axis to use for clustering groups when
GROUPDISPLAY=CLUSTER.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
DATALABEL=column | expression
specifies a column for marker labels. The label positions are adjusted to
prevent them from overlapping.
DATALABELATTRS=style-element | style-element (text-options ) | (text-
options )
specifies the color and font attributes of the data labels.
DATALABELPOSITION=AUTO | TOPRIGHT | TOP | TOPLEFT | LEFT | CENTER |
RIGHT | BOTTOMLEFT | BOTTOM | BOTTOMRIGHT
specifies the location of the data labels relative to the markers.
DATALABELSPLIT=TRUE | FALSE
810 Chapter 6 / Plot Statements
specifies whether to split the data labels at the specified split characters.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if
needed.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
DATALABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the data label
blocks.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
DISCRETEOFFSET=number
specifies an amount to offset all markers from discrete X values, or
discrete Y values, or both.
GROUP=column | discrete-attr-var | expression
creates a separate marker type for each unique group value of the
specified column.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies how marker groups are positioned for the coordinate pairs.
GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
specifies the ordering of the groups within a category.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
JITTER=NONE | AUTO
specifies whether to jitter data markers.
JITTEROPTS=(jitter-options)
specifies options for managing jittering.
ODS options
URL=string-column
specifies an HTML page to display when a point is selected.
Statistics options
FREQ=numeric-column | expression
specifies a numeric column that provides frequencies for each
observation that is read.
Required Arguments
X=column | expression
specifies the column for the X values.
SCATTERPLOT Statement 811
Y=column | expression
specifies the column for the Y values.
Optional Arguments
CLUSTERAXIS=AUTO | X | Y
specifies the axis to use for clustering groups when GROUPDISPLAY=CLUSTER.
AUTO
uses the discrete axis for clustering groups when only one axis is discrete.
Uses the X axis for clustering if both axes are discrete or interval.
X
Y
uses the X or Y axis for clustering groups.
Default AUTO
CLUSTERWIDTH=number
on a discrete axis, specifies the width of the group clusters as a fraction of the
midpoint spacing. On an interval axis, specifies the width of the group clusters
as a fraction of the minimum interval between adjacent data values.
Default 0.85
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
Interactions For this option to take effect, the GROUP= option must also be
specified, and the GROUPDISPLAY= option must be set to
CLUSTER.
COLORMODEL=style-element | (color-list )
specifies a color ramp that is to be used with the COLORRESPONSE= or
MARKERCOLORGRADIENT= option.
style-element
specifies the name of a style element.
STARTCOLOR specifies the color for the smallest data value of the
COLORRESPONSE= or
MARKERCOLORGRADIENT= column.
NEUTRALCOLOR specifies the color for the midpoint of the range of
the COLORRESPONSE= or
MARKERCOLORGRADIENT= column.
ENDCOLOR specifies the color for the highest data value of the
COLORRESPONSE= or
MARKERCOLORGRADIENT= column.
(color-list)
specifies a space-separated list of colors to use in the color ramp.
Note: Starting with SAS 9.4M2, the COLORRESPONSE= option replaces the
MARKERCOLORGRADIENT= option. The syntax and functionality are the same.
The MARKERCOLORGRADIENT= option is still honored, but the
COLORRESPONSE= option is preferred.
SCATTERPLOT Statement 813
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
You can use this option to add a second response variable to an analysis. For
example, in an analysis of weight by height, you can specify an age column by
using the COLORRESPONSE= or MARKERCOLORGRADIENT= option so that
the change in the gradient color of the markers reflects the change in age.
Starting with SAS 9.4M2, when this option is in effect and error
bars are displayed, the error bars derive their color from the
markers. To set a fixed color for the error bars, use the
ERRORBARATTRS= option.
This plot’s layout container queries each of its plots for a preferred offset and
includes all of the offsets in the axis offset calculations. If the DATALABEL= or
MARKERCHARACTER= option is specified for this plot, this plot might request
a preferred offset that prevents the clipping of any data labels or marker
character strings that appear at the ends of the axes. The requested offset is
based on the longest string. If the label or marker character lengths vary
significantly, the result is wasted space when the shorter strings appear near the
ends of the axes. In that case, you can use the CONTRIBUTEOFFSETS= option
to modify or eliminate this plot’s contribution to the offset calculations in order
to reclaim that space.
ALL
the space requirements for this plot are contributed to the axis offset
calculations.
NONE
the space requirements for this plot are not contributed to the axis offset
calculations.
(axis-offset-list)
a space-delimited list of specific contributions that this plot makes to the
axis offset calculations.
XMAX
the space requirements for this plot are contributed to the X-axis offset
calculation for the maximum end.
XMIN
the space requirements for this plot are contributed to the X-axis offset
calculation for the minimum end.
YMAX
the space requirements for this plot are contributed to the Y-axis offset
calculation for the maximum end.
YMIN
the space requirements for this plot are contributed to the Y-axis offset
calculation for the minimum end.
Default ALL
Interaction Offsets that are set in the layout axis options are always honored,
regardless of the setting on this option.
Note This option does not affect offset requests from other plots.
DATALABEL=column | expression
specifies a column for marker labels. The label positions are adjusted to prevent
them from overlapping.
Interactions If a numeric column is specified and the column has no format, then
a BEST6 format is applied.
Tip Use this option to display labels for the markers. The position of
the labels is adjusted to prevent the labels from overlapping. If you
want labels displayed instead of markers, then use the
MARKERCHARACTER= option.
816 Chapter 6 / Plot Statements
Interactions For this option to take effect, the DATALABEL= option must also
be specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element
AUTO
uses a data-label collision avoidance algorithm to position the labels.
Note When AUTO is in effect, in some cases, the data label font size might
be reduced in order to avoid overlapping labels and markers.
TOPRIGHT
TOP
TOPLEFT
LEFT
CENTER
RIGHT
BOTTOMLEFT
BOTTOM
BOTTOMRIGHT
specifies a location for all of the data labels.
Default AUTO
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the data label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels. The split
characters are specified by the DATALABELSPLITCHAR= option.
TRUE
drops the split characters from the data label.
FALSE
includes the split characters in the data label.
characters that follow the split character, up to and including the next split
character, are then wrapped to the next line.
The following figure shows an example of a data label with the following
specifications:
n the data label text for this label is Product*Group*A
n DATALABELSPLIT=TRUE
n DATALABELSPLITCHARDROP=TRUE | FALSE
n DATALABELSPLITCHAR="*"
Default TRUE. The split characters are dropped from the data label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the DATALABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The gray vertical line at the bottom of each label represents the
horizontal center of the text box for reference.
Default AUTO
Restriction Starting with SAS 9.4M1, the maximum number of skinned graphical
elements is limited to 200 per plot in an OVERLAY or PROTOTYPE
layout. When this limit is exceeded for a plot, the specified data
skin is not applied to that plot. In that case, use the
DATASKINMAX= option in your ODS GRAPHICS statement to
increase the maximum limit.
When a data skin is applied, all marker outlines are set by the skin,
and the outline settings are ignored from the ODS style or from
MARKERATTRS= option.
DATATRANSPARENCY=number
specifies the degree of the transparency of the markers, data labels, and error
bars, when displayed.
Default 0
DISCRETEMARKERSIZE=number
specifies the size of a marker as a fraction of the tick spacing.
Default 0.5
Range 0 to 1
Requirement For this option to take effect, at least one of the axes must be
discrete.
Interactions If both of the axes are discrete, then the marker size is a fraction of
the smaller tick spacing.
DISCRETEOFFSET=number
specifies an amount to offset all markers from discrete X values, or discrete Y
values, or both. This feature is useful for graphing multiple response variables
side by side on a common axis. By default within an overlay-type layout, if a
SCATTERPLOT is used with other plots with a discrete axis, then the markers
are centered on the discrete X values, or discrete Y values, or both. Depending
on the data, the markers might be superimposed over other graph data. The
following code fragment shows the default positioning when a SCATTERPLOT
is used with a BOXPLOT:
layout overlay / cycleattrs=true
xaxisopts=(type=discrete);
endlayout;
SCATTERPLOT Statement 821
To avoid superimposed plots, you can assign a different offset to each plot
statement:
layout overlay / cycleattrs=true
xaxisopts=(type=discrete);
scatterplot x=age y=weight /
discreteoffset=0.2;
boxplot x=age y=weight /
discreteoffset=-0.2;
endlayout;
Default 0 (no offset, all markers are centered on the discrete X values, or
discrete Y values, or both)
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. A positive offset is to the right on discrete X values
and up on discrete Y values. If the layout’s axis options set
REVERSE=TRUE, then the offset direction is also reversed.
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
822 Chapter 6 / Plot Statements
Interaction For this option to take effect, error bars must be displayed by the
XERRORLOWER= , XERRORUPPER= , YERRORLOWER= , or
YERRORUPPER= options.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
ERRORBARCAPSCALE=positive-number
specifies a positive number to use as a multiplier for determining the default
width of the error-bar caps.
Default 1
ERRORBARCAPSHAPE=SERIF | NONE
specifies whether the error bars have a serif cap.
FILLEDOUTLINEDMARKERS=TRUE | FALSE
specifies whether markers are drawn with both fill and an outline.
TRUE
draws filled markers (marker symbols with the suffix FILLED) using both fill
and an outline.
When this option is TRUE, the fill color and outline color for filled markers
are determined in the following ways:
n If the GROUP= option is specified, then by default, the fill color is derived
from the GraphData1–GraphDataN style elements Color attribute, and
the marker outlined color is derived from the GraphData1–GraphDataN
style elements ContrastColor attribute.
n If the GROUP= option is not specified, then by default, the fill color is
derived from the GraphDataDefault style elements Color attribute, and
the marker outlined color is derived from the GraphOutline style
elements ContrastColor attribute.
n If the COLORRESPONSE= MARKERCOLORGRADIENT= option is
specified, then the marker fill is drawn by using the mapped color that is
computed from the value of the COLORRESPONSE= or
MARKERCOLORGRADIENT= option for that observation. The marker
outline is drawn by using the MARKEROUTLINEATTRS= specification.
FALSE
draws the markers using fill or an outline, but not both.
Default FALSE
Tip To specify the marker fill and outline colors for a non-grouped plot, set
this option to TRUE, and then use the MARKERFILLATTRS= and
MARKEROUTLINEATTRS= options to specify the colors.
“boolean ” on page xii for other Boolean values that you can use.
824 Chapter 6 / Plot Statements
FREQ=numeric-column | expression
specifies a numeric column that provides frequencies for each observation that
is read.
Note If n is the value of the numeric column for a given observation, then
that observation is used n times for the purposes of any statistical
computation. The marker for that observation is drawn n times,
which increases the marker weight slightly with frequency.
discrete-attr-var
specifies a discrete attribute map variable.
Interactions The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of markers and
colors.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
SCATTERPLOT Statement 825
Tips The representations that are used to identify the groups can be
overridden. For example, each distinct group value is represented
by a different marker symbol, but the
MARKERATTRS=(SYMBOL=marker) option could be used to assign
the same symbol to all of the plot’s marker symbols, letting marker
color indicate group values. Likewise,
MARKERATTRS=(COLOR=color) could be used to assign the same
color to all markers, letting marker symbol indicate group values.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies how marker groups are positioned for the coordinate pairs.
OVERLAY
draws markers for a given group value at the exact coordinate.
CLUSTER
draws markers for a given group value adjacent to each other.
Default OVERLAY
Note When you plot a SAS data set, the items for each group value are
drawn in data order. When you plot a CAS in-memory table, they are
drawn in ascending order of the group column character values or
unformatted numeric values.
Tip Use the CLUSTERWIDTH= option to control the width of the clusters
when CLUSTER is in effect.
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Tip This option is useful when you want to reverse the category axis.
ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.
826 Chapter 6 / Plot Statements
Interactions This option is ignored if the GROUP= option is not also specified.
By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.
Notes When plotting a SAS data set, attributes such as color, symbol, and
pattern are assigned to each group in DATA order by default. When
plotting a CAS in-memory table, attributes are assigned in
ascending order of the group column character values or
unformatted numeric values by default.
In SAS 9.4M6 and earlier releases, when data stored in a CAS in-
memory table is used and DATA or REVERSEDATA is specified,
unpredictable results might occur. To generate consistent graphs in
that case, specify ASCENDING or DESCENDING. Starting with SAS
Viya 3.5 and SAS Studio 5.2, when data stored in a CAS in-memory
table is used and DATA or REVERSEDATA is specified, it is ignored,
and ASCENDING is used instead.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
SCATTERPLOT Statement 827
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping marker attributes (color and symbol) to one of the
GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interactions For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
JITTER=NONE | AUTO
specifies whether to jitter data markers.
NONE
does not offset the data markers.
AUTO
the system determines the best way to display the data markers, based on
the settings specified by the JITTEROPTS= option.
The next figure shows the case in which both axes are linear.
Default NONE
If this option is set to AUTO and both axes are discrete, then one-
dimensional systematic jittering occurs along the X axis.
Notes Jittering changes the default axis offsets, but it does not change
the axis data range.
You should not overlay a jittered scatter plot and a box plot with
outliers because their jittering offsets differ. A scatterplot's points
are jittered when the numeric values are close enough whereas a
box plot's points are jittered only when the numeric values are
identical.
JITTEROPTS=(jitter-options)
specifies options for managing jittering. The jitter options can be one or more of
the following values, separated by a space:
AXIS=AUTO | X | Y | BOTH
specifies the axis to use for jittering the data markers.
AUTO
the system determines the axis.
X
jittering is on the X axis.
Note If both the X and Y axes are discrete, then specifying BOTH is
equivalent to specifying X.
Y
jittering is applied on the Y axis.
BOTH
specifies that random jittering is applied on both the X and Y axes.
This option applies only when both the X and Y axes are interval.
Default AUTO
UNIFORM=TRUE | FALSE
specifies whether the jitter offsets are uniform across all category values or
are varied as needed.
When the markers for a category value do not fit the jittering space, the
jittering offsets are reduced in order to fit the markers for that category
value within the jittering space.
TRUE
uses a uniform jittering offset across all category values. The offset used
is the minimum offset that is required across all of the category values.
FALSE
varies the jittering offset only when the markers for a category value do
not fit the jittering space. The offset is varied as needed to fit the
markers for each case individually.
Default FALSE
WIDTH=positive-number
specifies the width of the jittering space as a fraction of either the midpoint
spacing or of the minimal interval width.
Note For a discrete axis, this option takes effect only if the jittered
markers still overlap. Setting WIDTH= to a higher value increases
the jittering space up to the specified width or to a width sufficient
to eliminate overlap if it is less than the specified width. In the
latter case, increasing the value further has no effect.
LABELSTRIP=TRUE | FALSE
specifies whether leading and trailing blanks are stripped from marker
characters or data labels that have a fixed position before they are displayed in
the plot. The MARKERCHARACTER= option specifies the column that provides
the marker strings that are to be used in place of marker symbols.
Default FALSE
Tip Stripping the blanks from the numeric value strings helps center
each string relative to its data point. Stripping is useful when you
want to overlay the data values near or inside the markers for a
plot.
See “boolean ” on page xii for other Boolean values that you can use.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Default The Y-column label. If a label is not defined, then the Y-column
name is used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
MARKERCHARACTER=column | expression
specifies a column that defines strings that are to be used instead of marker
symbols.
SCATTERPLOT Statement 833
Each string is centered horizontally and vertically at the data point. The data
point positions are not adjusted to prevent text overlap.
Note If a numeric column is used, then its values are converted to strings
using the format associated with the column or using BEST6 if no
format is defined.
You can use the LABELSTRIP= option to strip the leading and
trailing blanks from numeric value strings in order to center each
string on its data point.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Note: The red dots represent the center in each case for reference.
Default CENTER
Tip You can use the LABELSTRIP= option to strip the leading and
trailing blanks from value strings in order to properly justify each
string on its data point.
SCATTERPLOT Statement 835
MARKERFILLATTRS=style-element | (fill-options)
specifies the appearance of the filled markers.
MARKEROUTLINEATTRS=style-element | (line-options)
specifies the appearance of the marker outlines.
Interaction This option is ignored when a data skin is applied by the current
style or by the DATASKIN= option. In the latter case, the outline is
set by the data skin.
MARKERSIZEMAX=dimension
for SAS 9.4M1 and for earlier releases, specifies a drawing size for the largest
marker when the marker size represents response values.
Note: Starting with SAS 9.4M2, the SIZEMAX= option replaces the
MARKERSIZEMAX= option. The syntax and functionality are the same. The
MARKERSIZEMAX= option is still honored, but the SIZEMAX= option is
preferred.
MARKERSIZEMIN=dimension
for SAS 9.4M1 and for earlier releases, specifies a drawing size for the smallest
marker when the marker size represents response values.
Note: Starting with SAS 9.4M2, the SIZEMIN= option replaces the
MARKERSIZEMIN= option. The syntax and functionality are the same. The
MARKERSIZEMIN= option is still honored, but the SIZEMIN= option is
preferred.
MARKERSIZERESPONSE=numeric-column | expression
for SAS 9.4M1 and for earlier releases, specifies a column that is used to map
the drawing size of the markers.
Note: Starting with SAS 9.4M2, the SIZERESPONSE= option replaces the
MARKERSIZERESPONSE= option. The syntax and functionality are the same.
The MARKERSIZERESPONSE= option is still honored, but the SIZERESPONSE=
option is preferred.
in effect and both the X and Y axes are interval axes. See JITTER=
on page 827.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
OUTLINEDMARKERCHARACTERS=TRUE | FALSE
specifies whether the characters that are used as marker symbols are outlined
in order to enhance their appearance in the graph.
The following figure shows the marker characters M and F displayed when
OUTLINEDMARKERCHARACTERS=FALSE (default) and when
OUTLINEDMARKERCHARACTERS=TRUE.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by either
the ODS style that is in effect or by the COLORMODEL= option.
Default FALSE
See COLORMODEL=
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles X, Y, DATALABEL, MARKERCHARACTER,
COLORRESPONSE or MARKERCOLORGRADIENT,
XERRORLOWER, XERRORUPPER, YERRORLOWER,
YERRORUPPER, GROUP, and INDEX.
SCATTERPLOT Statement 839
SIZEMAX=dimension
starting with SAS 9.4M2, specifies a drawing size for the largest marker when
the marker size represents response values.
Note: Starting with SAS 9.4M2, the SIZEMAX= option replaces the
MARKERSIZEMAX= option. The syntax and functionality are the same. The
MARKERSIZEMAX= option is still honored, but the SIZEMAX= option is
preferred.
Tip If you specify this size as a percent, then the specified value is
interpreted as a percent of the graph’s height. You can control the
height by using the DESIGNHEIGHT= option of the BEGINGRAPH
statement, or by using the HEIGHT= option of the ODS GRAPHICS
statement. For a standard 640px by 480px output size, a
percentage value of 4.5% sets a maximum size of about 21px, which
is approximately the same marker size that would result from this
option’s typical default setting.
SIZEMIN=dimension
starting with SAS 9.4M2, specifies a drawing size for the smallest marker when
the marker size represents response values.
Note: Starting with SAS 9.4M2, the SIZEMIN= option replaces the
MARKERSIZEMIN= option. The syntax and functionality are the same. The
MARKERSIZEMIN= option is still honored, but the SIZEMIN= option is
preferred.
Interactions For this option to take effect, you must also specify the
SIZERESPONSE= or MARKERSIZERESPONSE= option.
840 Chapter 6 / Plot Statements
Tip If you specify this size as a percent, then the specified value is
interpreted as a percent of the graph’s height. You can control the
height by using the DESIGNHEIGHT= option of the BEGINGRAPH
statement, or by using the HEIGHT= option of the ODS GRAPHICS
statement. For a standard 640px by 480px output size, a
percentage value of 1.5% sets a minimum size of about 7px, which is
approximately the same marker size that would result from this
option’s typical default setting.
SIZERESPONSE=numeric-column | expression
starting with SAS 9.4M2, specifies a column that is used to map the drawing size
of the markers.
Note: Starting with SAS 9.4M2, the SIZERESPONSE= option replaces the
MARKERSIZERESPONSE= option. The syntax and functionality are the same.
The MARKERSIZERESPONSE= option is still honored, but the SIZERESPONSE=
option is preferred.
By default, the minimum and maximum values of this column establish a range
over which the marker sizes vary in linear proportion. The actual drawing size of
the smallest marker and the largest marker is set automatically.
Tip You can adjust the smallest and largest marker size with the
SIZEMIN= and SIZEMAX= options, or with the MARKERSIZEMIN=
and MARKERSIZEMAX= options.
SUBPIXEL=AUTO | OFF
specifies whether subpixel rendering is used for image output when the scatter
plot is rendered.
AUTO
sets subpixel rendering OFF, unless SUBPIXEL=ON is specified in the
BEGINGRAPH statement or in an ODS GRAPHICS statement. In that case,
subpixel rendering is ON.
SCATTERPLOT Statement 841
OFF
disables subpixel rendering for image output only for this scatter plot.
Default AUTO
Requirement Anti-aliasing must be enabled for this option to have any effect.
Notes This option affects subpixel rendering only for this plot. Subpixel
rendering for other plots in the graph is not affected.
When subpixel rendering is used for the graph but is turned OFF
for this scatter plot, some elements in the scatter plot such as the
plot markers might be offset a half pixel. This can make the plot
markers appear blurry in the image output.
TIP=(role-list ) | NONE
specifies the information to display when the cursor is positioned over the
scatter points. If this option is used, then it replaces all of the information that is
displayed by default. Roles for columns that do not contribute to the scatter
plot can be specified along with roles that do.
(role-list)
an ordered, space-separated list of unique SCATTERPLOT and user-defined
roles.
Requirement If you use the COLORRESPONSE= option, you must specify the
COLORRESPONSE role for the color values. Likewise, if you
use the MARKERCOLORGRADIENT= option, you must specify
the MARKERCOLORGRADIENT role for the color values.
842 Chapter 6 / Plot Statements
Although they are functionally the same, you cannot mix the
COLORRESPONSE= and MARKERCOLORGRADIENT= options,
and their corresponding roles.
Example The following example displays data tips for the columns
assigned to the roles X, XERRORUPPER, and XERRORLOWER,
as well as the column Obs, which is not assigned to any pre-
defined SCATTERPLOT role. The Obs column must first be
assigned a role.
ROLENAME=(TIP1=OBS)
TIP=(TIP1 X XERRORUPPER XERRORLOWER)
NONE
suppresses data tips and URLs (if requested) from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
SCATTERPLOT Statement 843
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
URL=string-column
specifies an HTML page to display when a point is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each marker that is to have an active link.
Example http://www.sas.com
Tips The URL value can be blank for some X and Y pairs, meaning that
no action is taken when the corresponding point is selected.
The URL value can be the same for any X and Y pairs. In that case,
the same action is taken when the points for those X and Y pairs
are selected.
USEDISCRETESIZE=TRUE | FALSE
specifies that the marker size should be based on fraction of the midpoint
spacing that is set by the DISCRETEMARKERSIZE= option.
844 Chapter 6 / Plot Statements
Default FALSE
See DISCRETEMARKERSIZE=
“boolean ” on page xii for other Boolean values that you can use.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
XERRORLOWER=numeric-column | expression
specifies values for the lower endpoints on the X error bars. The error bars are
drawn from the markers to the endpoints.
If markers are displayed in the plot, then the markers overlay the error
bars. Large filled markers can obscure short error bars. To enable the
error bars to show through the markers in that case, you can use the
MARKERATTRS= option to specify a degree of transparency for the
filled markers.
XERRORUPPER=numeric-column | expression
specifies values for the upper endpoints on the X error bars. The error bars are
drawn from the markers to the endpoints.
If markers are displayed in the plot, then the markers overlay the error
bars. Large filled markers can obscure short error bars. To enable the
error bars to show through the markers in that case, you can use the
MARKERATTRS= option to specify a degree of transparency for the
filled markers.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
SCATTERPLOT Statement 845
Default Y
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
YERRORLOWER=numeric-column | expression
specifies values for the lower endpoints on the Y error bars. The error bars are
drawn from the markers to the endpoints.
If markers are displayed in the plot, then the markers overlay the error
bars. Large filled markers can obscure short error bars. To enable the
error bars to show through the markers in that case, you can use the
MARKERATTRS= option to specify a degree of transparency for the
filled markers.
YERRORUPPER=numeric-column | expression
specifies values for the upper endpoints on the Y error bars. The error bars are
drawn from the markers to the endpoints.
If markers are displayed in the plot, then the markers overlay the error
bars. Large filled markers can obscure short error bars. To enable the
error bars to show through the markers in that case, you can use the
MARKERATTRS= option to specify a degree of transparency for the
filled markers.
Examples
Example Program
proc template;
define statgraph scatterplot;
begingraph;
entrytitle "Height and Weight by Sex";
layout overlay;
scatterplot x=height y=weight /
group=sex name="scatter" datalabel=name;
discretelegend "scatter";
endlayout;
endgraph;
end;
run;
Example Program
/* Summarize SASHELP.CARS for mean MPG_HIGHWAY */
proc summary data=sashelp.cars nway;
class type;
var mpg_highway;
output out=mileage mean=mean;
run;
/* Sort by mileage */
proc sort data=mileage;
by mean;
run;
end;
run;
Details
This example creates a scatter plot of average highway mileage by vehicle type.
The SUMMARY procedure is used to compute the mean highway mileage for each
vehicle type. The SORT procedure is then used to sort the data by mileage in
ascending order. Normally, when you plot discrete values using the SCATTERPLOT
statement, the values at each end of the category axis are offset to accommodate
the width of the largest marker. When a small symbol is used, this can result in the
minimum and maximum symbols being placed very close to the edge of the axis.
You can use the OFFSETMAX= and OFFSETMIN= axis options to specify offsets
for each end of the category axis. However, you have to determine an appropriate
offset value.
In this example, the GROUP= and GROUPDISPLAY= options are used to create
offsets automatically. The GROUP= option creates a group for each category value.
The GROUPDISPLAY=CLUSTER option displays the group values in a cluster and
automatically offsets the end values by one-half of the available midpoint spacing,
which is similar to the offsets that are used in bar charts. To restore the default
colors and symbols that are used for ungrouped data, the MARKERATTRS= option
is used to set the marker attributes to the graphDataDefault style element.
Example Program
proc summary data=sashelp.class nway;
var height;
class age;
output out=classSum mean=mean std=std;
run;
proc template;
define statgraph dotplot;
begingraph;
entrytitle "Mean Height by Age";
layout overlay /
xaxisopts=(label="Height (Mean)")
yaxisopts=(griddisplay=on
gridattrs=(color=lightgray pattern=dot)
reverse=true);
scatterplot x=mean y=age / name="scatter"
markerattrs=(symbol=circlefilled)
xerrorupper=eval(mean + std)
xerrorlower=eval(mean - std)
legendlabel="Height (Mean), 1 Standard Deviation";
discretelegend "scatter";
endlayout;
endgraph;
end;
run;
Details
This example uses the SCATTERPLOT statement to create a dot plot from data
computed by the SUMMARY procedure. The SUMMARY procedure computes the
mean and standard deviation for variable Height by variable Age in data set
Sashelp.Class, and stores the results in data set Work.classSum. In the graph
template code, the SCATTERPLOT statement plots variables Mean and Age in data
set Work.classSum. The MARKERATTRS= option specified filled circles as the plot
dots. The XERRORUPPER= and XERRORLOWER= options specify the statistic
limits. The EVAL function computes the limits from variables Mean and Std.
SCATTERPLOTMATRIX Statement
Creates a matrix of all pairwise scatter plots of the specified columns.
Syntax
SCATTERPLOTMATRIX numeric-column-list </options>;
specifies indices for mapping marker attributes (color and symbol) to one
of the GraphData1–GraphDataN style elements.
LABELSTRIP=TRUE | FALSE
specifies whether leading and trailing blanks are stripped from marker
characters or data labels that have a fixed position before they are
displayed in the plot.
MARKERATTRS=style-element | style-element (marker-options) | (marker-
options)
specifies the attributes of the data markers.
MARKERCHARACTER=column | expression
specifies a column that defines strings that are to be used instead of
marker symbols.
MARKERCHARACTERATTRS=style-element | style-element (text-options) |
(text-options)
specifies the color and font attributes of the marker character specified
on the MARKERCHARACTER= option.
MARKERCHARACTERPOSITION=CENTER | TOP | BOTTOM | LEFT | RIGHT |
TOPLEFT | TOPRIGHT | BOTTOMLEFT | BOTTOMRIGHT
specifies the justification of the marker characters.
MARKERCOLORGRADIENT=numeric-column | range-attr-var | expression
in SAS 9.4M1 and earlier releases, specifies the column or range attribute
map variable that is used to determine the marker colors.
MATRIXTYPE=FULL | UPPERTRIANGLE | LOWERTRIANGLE
specifies whether to display the full matrix, or just the upper or lower
triangle of the matrix.
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by
either the ODS style that is in effect or by the COLORMODEL= option.
START=TOPLEFT | BOTTOMLEFT
specifies whether to start populating the matrix from the top left or
bottom left corner.
SUBPIXEL=AUTO | OFF
specifies whether subpixel rendering is used for image output when the
scatter plots are rendered.
WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
WALLDISPLAY=STANDARD | ALL | NONE | (display-options)
specifies whether the plot’s wall and wall outline are displayed.
Confidence options
ELLIPSE=(<ellipse-suboptions>)
specifies that a confidence ellipse be included in each cell containing a
scatter plot.
Inset options
INSET=(info-options)
specifies what information is displayed in an inset.
INSETOPTS=(appearance-options)
specifies location and appearance options for the inset information.
Label options
DATALABEL=column
specifies a column for marker labels.
DATALABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the data labels.
DATALABELPOSITION=AUTO | TOPRIGHT | TOP | TOPLEFT | LEFT | CENTER |
RIGHT | BOTTOMLEFT | BOTTOM | BOTTOMRIGHT
specifies the location of the data labels relative to the markers.
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if
needed.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
DATALABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the data label
blocks.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a distinct set of scatter markers, error bars, and data labels for
each unique group value of the specified column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Statistics options
CORROPTS=(correlation-options)
SCATTERPLOTMATRIX Statement 853
Required Argument
numeric-column-list
specifies a list of numeric columns to plot.
Note The default width is 640px, and the default height is 480px. The
graph size is not automatically adjusted to accommodate a large
number of columns.
Tips To change the graph size for the current template, use the
DESIGNHEIGHT= and DESIGNWIDTH= options in the
BEGINGRAPH statement.
To change the graph size for all templates in the current SAS
session, use the HEIGHT= and WIDTH= options in the ODS
GRAPHICS statement. Size settings in the ODS GRAPHICS
statement override size settings in the BEGINGRAPH statement.
You can also limit the number of columns in the matrix (perhaps
to seven in each dimension, for example) so that the resulting
graphs are not too small to be useful.
Optional Arguments
COLORMODEL=style-element | (color-list)
specifies a color ramp that is to be used with the COLORRESPONSE= or
MARKERCOLORGRADIENT= option.
style-element
specifies the name of a style element.
(color-list)
specifies a space-separated list of colors to use in the color ramp.
Note: Starting with SAS 9.4M2, the COLORRESPONSE= option replaces the
MARKERCOLORGRADIENT= option. The syntax and functionality are the same.
The MARKERCOLORGRADIENT= option is still honored, but the
COLORRESPONSE= option is preferred.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
You can use this option to add a second response variable to an analysis. For
example, in an analysis of weight by height, you can specify an age column by
using the COLORRESPONSE= or MARKERCOLORGRADIENT= option so that
the change in the gradient color of the markers reflects the change in age.
CORROPTS=(correlation-options)
specifies options for computing measures of association between pairs of
columns. The following correlation-options are available:
856 Chapter 6 / Plot Statements
EXCLNPWGT=TRUE | FALSE
specifies whether observations with non-positive weight values are
excluded (TRUE) from the analysis.
Default FALSE (observations with negative weights are treated like those
with zero weights and counted in the total number of observations).
See “boolean ” on page xii for other Boolean values that you can use.
NOMISS=TRUE | FALSE
specifies whether observations with missing values are excluded (TRUE)
from the analysis.
See “boolean ” on page xii for other Boolean values that you can use.
WEIGHT=numeric-column
specifies a weighting column to use in the calculation of Pearson weighted
product-moment correlation.
The observations with missing weights are excluded from the analysis. If you
use this WEIGHT correlation option, then consider which value of the
VARDEF=correlation option is appropriate.
Default For observations with non-positive weights, the weights are set to
zero and the observations are included in the analysis.
DF
Degrees of Freedom (N – 1)
N
number of observations
WDF
sum of weights minus 1 (WEIGHT – 1)
WEIGHT
sum of weights
Default DF
Interaction This option has effect only when the INSET= option is also used.
DATALABEL=column
specifies a column for marker labels. The label positions are adjusted to prevent
the labels from overlapping.
Interactions If a numeric column is specified and the column has no format, then
a BEST6 format is applied.
Note The position of the labels are adjusted to prevent the labels from
overlapping.
Interactions For this option to take effect, the DATALABEL= option must also
be specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO
uses a data-label collision avoidance algorithm to position the labels.
Note When AUTO is in effect, in some cases, the data label font size might
be reduced in order to avoid overlapping labels and markers.
TOPRIGHT
TOP
TOPLEFT
LEFT
CENTER
RIGHT
BOTTOMLEFT
BOTTOM
BOTTOMRIGHT
specifies a location for all of the data labels.
Default AUTO
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the data label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
TRUE
drops the split characters from the data label.
FALSE
includes the split characters in the data label.
The following figure shows an example of a data label with the following
specifications:
n the data label text for this label is Product*Group*A
n DATALABELSPLIT=TRUE
n DATALABELSPLITCHARDROP=TRUE | FALSE
n DATALABELSPLITCHAR="*"
Default TRUE. The split characters are dropped from the data label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the DATALABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The gray vertical line at the bottom of each label represents the
horizontal center of the text box for reference.
Default AUTO
Restriction Starting with SAS 9.4M1, the maximum number of skinned graphical
elements is limited to 200 per plot in an OVERLAY or PROTOTYPE
layout. When this limit is exceeded for a plot, the specified data
skin is not applied to that plot. In that case, use the
DATASKINMAX= option in your ODS GRAPHICS statement to
increase the maximum limit.
When a data skin is applied, all marker outlines are set by the skin,
and the outline settings from the ODS style or from the
MARKERATTRS= option are ignored.
DATATRANSPARENCY=number
specifies the degree of the transparency of the markers and data labels.
Default 0
Note This option does not apply to the HISTOGRAM, DENSITY, and
NORMAL plots in the scatter-plot matrix.
DIAGONAL=LABEL | (graph-list)
specifies whether the diagonal cells of the matrix are labeled with the labels
(names) of the required arguments, or with a plot. The plot for each diagonal
cell consists of an overlay combination of a histogram, normal, or kernel curves.
LABEL
labels the diagonal cells of the matrix with the names of the required
arguments.
862 Chapter 6 / Plot Statements
(graph-list)
specifies the plots that are displayed in the diagonal cells of the matrix.
HISTOGRAM
specifies a histogram.
NORMAL
specifies a normal density curve.
KERNEL
specifies a kernel density estimate.
Default LABEL. Column labels (or names) are displayed in the diagonal
cells.
DIAGONAL=(HISTOGRAM NORMAL)
Notes When this option is specified, the labels are drawn around the
outside of the matrix, and the matrix axes are dropped.
When NORMAL and KERNEL are specified, both curves have the
same visual attributes.
ELLIPSE=(<ellipse-suboptions>)
specifies that a confidence ellipse be included in each cell containing a scatter
plot. The ellipse is always drawn behind the scatter points. Ellipse-suboptions
can include one or more of the following:
ALPHA=positive-number
specifies the confidence level to compute for each ellipse.
Default 0.05
CLIP=TRUE | FALSE
specifies whether the X and Y values for the ellipse are considered when
determining the data ranges for the axes.
SCATTERPLOTMATRIX Statement 863
TRUE
the X and Y values for the ellipses are ignored when the axis ranges are
determined.
Clipping occurs if the X and Y values for an ellipse exceed the axis range.
FALSE
the X and Y values for the ellipses contribute to the data range for each
axis.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
TYPE=MEAN | PREDICTED
specifies the type of ellipse.
MEAN
specifies a confidence ellipse of the mean
PREDICTED
specifies a prediction ellipse of the data
Default MEAN
See “ELLIPSE Statement” on page 504 for statistical details about how
the ellipse is calculated.
Interactions The ellipse might be clipped by the data range for the scatter
points.
The ellipse is always computed on all the data for the current pair
of X and Y columns (including the FREQ= column, if used). The
GROUP= option is not considered when computed the ellipse.
Tip The display properties of each ellipse are controlled by the style
elements. The GraphDataDefault element controls the outline and
fill properties, and the GraphEllipse element controls whether the
outline, fill, or both are shown.
FREQ=numeric-column | expression
specifies a numeric column that provides frequencies for each observation that
is read.
Note If n is the value of the numeric column for a given observation, then
that observation is used n times for the purposes of any statistical
864 Chapter 6 / Plot Statements
discrete-attr-var
specifies a discrete attribute map variable.
Interactions The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of markers and
colors.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
Tips The representations that are used to identify the groups can be
overridden. For example, each distinct group value is represented
by a different marker symbol, but the
MARKERATTRS=(SYMBOL=marker) option could be used to assign
the same symbol to all of the plot’s marker symbols, letting marker
color indicate group values. Likewise,
MARKERATTRS=(COLOR=color) could be used to assign the same
color to all markers, letting marker symbol indicate group values.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping marker attributes (color and symbol) to one of the
GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interactions For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
866 Chapter 6 / Plot Statements
INSET=(info-options)
specifies what information is displayed in an inset. Insets appear in all cells of
the matrix except the diagonal and are displayed as a small table of name-value
pairs. The following info-options are available:
NOBS
displays the total number of observations where both the X and Y columns
have nonmissing values.
If the FREQ= option is used, then this number is adjusted accordingly. The
value of NOBS can be further adjusted by the use of the NOMISS=,
WEIGHT=, and EXCLNPWGT= suboptions of the CORROPTS= option.
PEARSON
displays the Pearson product-moment correlation.
PEARSONPVAL
displays the probability value for the Pearson product-moment correlation.
See PROC CORR in the documentation for Base SAS for statistical and
computational details of these options.
N 150
r 0.96287
p(r) <.0001
In this example, NOBS is represented by N, PEARSON is represented
by r, and PEARSONPVAL is represented by p(r).
INSETOPTS=(appearance-options)
specifies location and appearance options for the inset information. The
appearance options can be any one or more of the settings that follow. The
options must be enclosed in parentheses, and each option is specified as a
name=value pair.
NONE
does not automatically align the inset.
AUTO
attempts to center the inset in the area that is farthest from any
surrounding markers.
(location-list)
restricts the inset’s possible locations to those locations in the specified
location-list, and uses the location-list position that least collides with
the data cell’s other graphics features.
Default NONE
BACKGROUNDCOLOR=style-reference | color
specifies the color of the inset background
style-reference
specifies a style reference in the form style-element : style-attribute.
BORDER=TRUE | FALSE
specifies whether a border is displayed around the inset.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Default LEFT
Interaction This option is ignored when AUTOALIGN= is not NONE and the
parent layout is an overlay-type layout.
OPAQUE=TRUE | FALSE
specifies whether the inset background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not
used.
See “boolean ” on page xii for other Boolean values that you can use.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TITLE="string"
specifies a title for the inset.
The title is added at the top of the inset and spans the full inset width.
Note Space is not reserved for the title when this option is not set
Tip Text properties for the title string can be set with TITLEATTRS=.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Default TOP
Interaction This option is ignored when AUTOALIGN= is not NONE and the
parent layout is an overlay-type layout.
LABELSTRIP=TRUE | FALSE
specifies whether leading and trailing blanks are stripped from marker
characters or data labels that have a fixed position before they are displayed in
the plot. The MARKERCHARACTER= option specifies the column that provides
the marker strings that are to be used in place of marker symbols.
Default FALSE
Tip Stripping the blanks from the numeric value strings helps center
each string relative to its data point. Stripping is useful when you
want to overlay the data values near or inside the markers for a
plot.
See “boolean ” on page xii for other Boolean values that you can use.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
MARKERCHARACTER=column | expression
specifies a column that defines strings that are to be used instead of marker
symbols.
Each string is centered horizontally and vertically at the data point. The data
point positions are not adjusted to prevent text overlap.
870 Chapter 6 / Plot Statements
Note If a numeric column is used, then its values are converted to strings
using the format associated with the column or using BEST6 if no
format is defined.
You can use the LABELSTRIP= option to strip the leading and
trailing blanks from numeric value strings in order to center each
string on its data point.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Note: The red dots represent the center in each case for reference.
Default CENTER
Tip You can use the LABELSTRIP= option to strip the leading and
trailing blanks from value strings in order to properly justify each
string on its data point.
The next figure shows the effect of the START=BOTTOMLEFT option on the
previous graph.
Default FULL
The START= option specifies the corner where the matrix fill
begins.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
SCATTERPLOTMATRIX Statement 873
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by either
the ODS style that is in effect or by the COLORMODEL= option.
Default FALSE
See COLORMODEL=
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles X, Y, DATALABEL, MARKERCHARACTER,
COLORRESPONSE or MARKERCOLORGRADIENT, GROUP, and
INDEX.
ROWVARS=(numeric-column-list)
specifies a secondary list of numeric columns to be paired with the required
column list that is specified by the SCATTERPLOTMATRIX statement. The
labels for the columns appear vertically on the left side of the matrix.
START=TOPLEFT | BOTTOMLEFT
specifies whether to start populating the matrix from the top left or bottom left
corner.
Default TOPLEFT
SUBPIXEL=AUTO | OFF
specifies whether subpixel rendering is used for image output when the scatter
plots are rendered.
AUTO
sets subpixel rendering OFF, unless SUBPIXEL=ON is specified in the
BEGINGRAPH statement or in an ODS GRAPHICS statement. In that case,
subpixel rendering is ON.
OFF
disables subpixel rendering for image output only for the scatter plots in this
scatter-plot matrix.
Default AUTO
Restriction This option applies only to the scatter plots in the matrix. It does
not affect the confidence ellipses.
Requirement Anti-aliasing must be enabled for this option to have any effect.
Notes This option affects subpixel rendering for the scatter plots only in
this scatter-plot matrix. Subpixel rendering for other plots in the
graph is not affected.
When subpixel rendering is used for the graph but is turned OFF
for this scatter-plot matrix, some elements in the scatter plots
such as the plot markers might be offset a half pixel, which can
make them appear blurry in the image output.
To disable subpixel rendering for the scatter plots and the ellipses,
specify SUBPIXEL=OFF in the template’s BEGINGRAPH statement
or in an ODS GRAPHICS statement.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over the
scatter points. If this option is used, then it replaces all of the information that is
displayed by default. Roles for columns that do not contribute to the scatter
plot can be specified along with roles that do.
SCATTERPLOTMATRIX Statement 875
(role-list)
an ordered, space-separated list of unique SCATTERPLOTMATRIX and user-
defined roles.
Requirement If you use the COLORRESPONSE= option, you must specify the
COLORRESPONSE role for the color values. Likewise, if you
use the MARKERCOLORGRADIENT= option, you must specify
the MARKERCOLORGRADIENT role for the color values.
Although they are functionally the same, you cannot mix the
COLORRESPONSE= and MARKERCOLORGRADIENT= options,
and their corresponding roles.
Example The following example displays data tips for the columns
assigned to the roles TIP1, TIP2, TIP3, and TIP4:
NONE
suppresses data tips from the plot.
Requirement To enable data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
876 Chapter 6 / Plot Statements
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
WALLCOLOR=style-reference | color
specifies the fill color of the plot wall area.
style-reference
specifies a style reference in the form style-element:style-attribute.
STANDARD
displays a filled wall.
ALL
displays a filled, outlined wall.
NONE
displays no wall, no wall outline.
SCATTERPLOTMATRIX Statement 877
(display-options)
a space-separated list of one or more display options enclosed in
parentheses.
OUTLINE
displays the wall outline.
FILL
displays a filled wall area.
Default STANDARD
Tips Use the WALLCOLOR= option to control the fill color of the wall.
The appearance attributes of the wall fill and outline are set by the
GraphWalls style element.
Details
By default, the SCATTERPLOTMATRIX statement produces a symmetric scatter
plot matrix. For n columns, it produces an n columns by n rows matrix of scatter
plots. By default, the columns of the matrix are in the same left-to-right order as
the order of the numeric-column-list. The rows of the matrix are in the same
bottom-to-top order as the numeric-column-list. You can reverse the direction of
the diagonal by setting START=TOPLEFT.
If there are missing values in a column or a row, then all of the points that can be
plotted are plotted in each scatter plot.
Example Program
proc template;
define statgraph scatterplotmatrix;
begingraph;
entrytitle "Scatter Plot Matrix";
layout gridded;
scatterplotmatrix
sepallength sepalwidth petallength petalwidth /
group=species name="matrix";
discretelegend "matrix";
endlayout;
endgraph;
end;
run;
SERIESPLOT Statement
Displays a series of line segments that connect observations of input data.
Note: The SERIESPLOT statement plots data in data order. For this reason, the input data
set should be sorted by the X variable. Otherwise, unexpected results might occur.
SERIESPLOT Statement 879
Syntax
SERIESPLOT X=column | expression
Y=column | expression </options>;
specifies the attributes of the error bars that are associated with the data
points.
ERRORBARCAPSCALE=positive-number
specifies a positive number to use as a multiplier for determining the
default width of the error-bar caps.
ERRORBARCAPSHAPE=SERIF | NONE
specifies whether the error bars have a serif cap.
FILLEDOUTLINEDMARKERS=TRUE | FALSE
specifies whether markers are drawn with both fill and an outline.
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color, marker symbol, and
line pattern) to one of the GraphData1–GraphDataN style elements.
LINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the series line.
LINECOLORGROUP=column | discrete-attr-var | expression
specifies a column that determines the line colors for a grouped plot
independently of the GROUP= column.
LINEJOIN= MITER | ROUND | BEVEL
specifies how to shape the vertices of the series line.
LINEPATTERNGROUP=column | discrete-attr-var | expression
specifies a column that determines the line patterns for a grouped plot
independently of the GROUP= column.
LINETHICKNESSMAX=dimension
specifies the maximum line thickness when a response variable is used to
determine the line thickness.
LINETHICKNESSMAXRESPONSE=numeric | scalar-numeric-expression
specifies the response value that corresponds to the maximum line
thickness.
LINETHICKNESSMIN=dimension
specifies the minimum line thickness when a response variable is used to
determine the line thickness.
LINETHICKNESSRESPONSE=numeric-column | expression
specifies a response column or range attribute variable that is used to
map a line thickness to each group value.
MARKERATTRS=style-element | style-element (marker-options) | (marker-
options)
specifies the attributes of the data markers.
MARKERCOLORGROUP=column | discrete-attr-var | expression
specifies a column that determines the marker colors for a grouped plot
independently of the GROUP= column.
MARKERFILLATTRS=style-element | (fill-options)
specifies the appearance of the filled markers.
MARKEROUTLINEATTRS=style-element | (line-options)
specifies the appearance of the marker outlines.
MARKERSYMBOLGROUP=column | discrete-attr-var | expression
specifies a column that determines the marker symbols for a grouped
plot independently of the GROUP= column.
SMOOTHCONNECT=TRUE | FALSE
SERIESPLOT Statement 881
Axes options
CLUSTERAXIS=AUTO | X | Y
specifies the axis to use for clustering groups when
GROUPDISPLAY=CLUSTER.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Connect options
CONNECTORDER=XVALUES | XAXIS
specifies how to connect the data points to form the series line.
Label options
CURVELABEL="string" | column | expression
882 Chapter 6 / Plot Statements
Midpoint options
DISCRETEOFFSET=number
specifies an amount to offset all series lines and markers from discrete X
values, or discrete Y values, or both.
GROUP=column | discrete-attr-var | expression
SERIESPLOT Statement 883
creates a separate series plot for each unique group value in the specified
column.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies how marker groups are positioned for the coordinate pairs.
GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
specifies the ordering of the groups within a category.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
ODS options
URL=string-column
specifies an HTML page to display when a point or a segment of the
curve is selected.
Required Arguments
X=column | expression
specifies the column for the X values.
Y=column | expression
specifies the column for the Y values.
Optional Arguments
ARROWHEADPOSITION= NONE | START | END | BOTH | column
specifies a position for arrowheads.
NONE
no arrowheads are displayed.
START
an arrowhead is displayed at the starting point of each line.
END
an arrowhead is displayed at the ending point of each line.
BOTH
an arrowhead is displayed at each end of each line.
column
specifies a column that provides an arrowhead position for each group value.
Default NONE
884 Chapter 6 / Plot Statements
Restriction When you specify a column and the GROUP= option is in effect, the
arrowhead position values are assumed to be constant for each
group value. If the column has multiple values for a single group
value, then only one of the arrowhead position values is used for
that group.
Default 1.0
Restriction The arrowhead scale values are assumed to be constant for each
line. If a column or expression provides multiple values for a line,
only one of the values is used.
Default OPEN
Restriction When you specify a column and the GROUP= option is in effect, the
arrowhead shape values are assumed to be constant for each group
value. If the column has multiple values for a single group value,
only one of the arrowhead shape values is used for that group.
BREAK=TRUE | FALSE
breaks the plot line at missing values of the Y variable.
Default FALSE
Interaction This option is ignored when the Y axis is discrete and option
INCLUDEMISSINGDISCRETE=TRUE is specified in the
BEGINGRAPH statement. To break the line in that case, remove
INCLUDEMISSINGDISCRETE=TRUE from the BEGINGRAPH
statement.
Note When this option is set to FALSE, missing values are skipped and a
continuous line is drawn.
See “boolean ” on page xii for other Boolean values that you can use.
CLUSTERAXIS=AUTO | X | Y
specifies the axis to use for clustering groups when GROUPDISPLAY=CLUSTER.
AUTO
uses the discrete axis for clustering groups when only one axis is discrete.
Uses the X axis for clustering if both axes are discrete or interval.
X
Y
uses the X or Y axis for clustering groups.
Default AUTO
CLUSTERWIDTH=number
on a discrete axis, specifies the width of the group clusters as a fraction of the
midpoint spacing. On an interval axis, specifies the width of the group clusters
as a fraction of the minimum interval between adjacent data values.
Default 0.85
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
Interactions For this option to take effect, the GROUP= option must also be
specified, and the GROUPDISPLAY= option must be set to
CLUSTER.
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
886 Chapter 6 / Plot Statements
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
Interactions When this option is specified without the GROUP= option, only a
single line is generated for the plot, and the line color is derived
from the COLORRESPONSE= value.
CONNECTORDER=XVALUES | XAXIS
specifies how to connect the data points to form the series line.
XVALUES
connects data points in the order read from the X column.
Note In SAS 9.4M6 and earlier releases, unexpected results might occur
when XVALUES is specified and data stored in a CAS in-memory table
is used. In that case, use XAXIS instead. Starting with SAS Viya 3.5
and SAS Studio 5.2, XVALUES is ignored when data stored in a CAS in-
memory table is used.
XAXIS
connects data points as they occur min-to-max along the X axis.
Tip For certain types of series lines (for example, time series) when the
input data might not be sorted by the X column, set this option to
XAXIS to assure the expected connect order.
888 Chapter 6 / Plot Statements
Restrictions When the GROUP= option is specified, "string" and expression are
not valid. Use column in that case.
When the GROUP= option is not specified, column is not valid. Use
"string" or expression in that case.
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
Interactions For this option to take effect, the CURVELABEL= option must also
be used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the series-line label relative to the plot area.
INSIDE
locates the labels inside the plot area
OUTSIDE
locates the labels outside the plot area
Default INSIDE
SERIESPLOT Statement 889
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
AUTO
automatically locates the series-line label near the end series line along
unused axes whenever possible (typically Y2 or X2) in order to avoid
collision with tick values.
MAX
forces the series-line label to appear near maximum series values (typically,
to the right)
MIN
forces the series-line label to appear near minimum series values (typically,
to the left)
START
forces the series-line label to appear near the beginning of the series line.
Tip This option is particularly useful when the series line has a spiral
shape.
END
forces the series-line label to appear near the end of the series line.
Tip This option is particularly useful when the series line has a spiral
shape.
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the series-line label at the specified split characters.
When a series-line label is split, the label is split on each occurrence of the
specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the series-line label can be split if
needed. When multiple split characters are specified, each character in the list
is treated as a separate split character unless the specified characters appear
consecutively in the series-line label. In that case, all of the specified split
characters together are treated as a single split character.
"character-list"
one or more characters with no delimiter between each character and
enclosed in quotation marks.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the series-line label text.
TRUE
drops the split characters from the series-line label text.
FALSE
includes the split characters in the series-line label text.
The following figure shows an example of a series-line label with the following
specifications:
n CURVELABELPOSITION=MAX
n CURVELABEL="Product*Group*A"
n CURVELABELSPLIT=TRUE
n CURVELABELSPLITCHARDROP=TRUE | FALSE
n CURVELABELSPLITCHAR="*"
Note: The horizontal line to the left of the label represents the maximum end of
the series line for reference.
892 Chapter 6 / Plot Statements
Default TRUE. The split characters are dropped from the series-line label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the CURVELABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The horizontal line to the left of each label represents the maximum end
of the series line for reference.
SERIESPLOT Statement 893
Default AUTO
DATALABEL=column | expression
specifies a column that supplies values for the data point labels.
Note The label positions are adjusted to prevent the labels from overlapping.
Interactions For this option to take effect, the DATALABEL= option must also
be specified.
Tip When the GROUP= option is used, each distinct group value might
be represented by a different color. The data label that is
associated with the group is assigned the group color. This option
can be used to specify a single color for all data labels in a plot,
without affecting items that have the group color, such as error bars
and marker symbols.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO
uses a data-label collision avoidance algorithm to position the labels.
894 Chapter 6 / Plot Statements
Note When AUTO is in effect, in some cases, the data label font size might
be reduced in order to avoid overlapping labels and markers.
TOPRIGHT
TOP
TOPLEFT
LEFT
CENTER
RIGHT
BOTTOMLEFT
BOTTOM
BOTTOMRIGHT
specifies a location for all of the data labels.
Default AUTO
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the data label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
datalabelsplitchar="abc"
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
TRUE
drops the split characters from the data label.
FALSE
includes the split characters in the data label.
The following figure shows an example of a data label with the following
specifications:
n the data label text for this label is Product*Group*A
n DATALABELSPLIT=TRUE
n DATALABELSPLITCHARDROP=TRUE | FALSE
n DATALABELSPLITCHAR="*"
Default TRUE. The split characters are dropped from the data label.
896 Chapter 6 / Plot Statements
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the DATALABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The gray vertical line at the bottom of each label represents the
horizontal center of the text box for reference.
Default AUTO
Restriction Starting with SAS 9.4M1, the maximum number of skinned graphical
elements is limited to 200 per plot in an OVERLAY or PROTOTYPE
layout. When this limit is exceeded for a plot, the specified data
skin is not applied to that plot. In that case, use the
DATASKINMAX= option in your ODS GRAPHICS statement to
increase the maximum limit.
DATATRANSPARENCY=number
specifies the degree of the transparency of the line, markers, line label, and data
labels, when displayed.
Default 0
DISCRETEOFFSET=number
specifies an amount to offset all series lines and markers from discrete X values,
or discrete Y values, or both. This option is useful when graphing multiple
response variables side by side on a common axis
Default 0 (no offset, all series lines and markers are centered on the discrete
X values, or discrete Y values, or both)
898 Chapter 6 / Plot Statements
Range -0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. A positive offset is to the right on discrete X values
and up on discrete Y values. If the layout’s axis options set
REVERSE=TRUE, then the offset direction is also reversed.
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
(display-options)
a space-separated list of one or more options enclosed in parentheses.
STANDARD
displays a series line without markers.
ALL
displays a series line with markers.
Default STANDARD
ERRORBARCAPSCALE=positive-number
specifies a positive number to use as a multiplier for determining the default
width of the error-bar caps.
Default 1
Interaction For this option to take effect, error bars must be displayed by the
XERRORLOWER= , XERRORUPPER= , YERRORLOWER= , or
YERRORUPPER= options.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
ERRORBARCAPSHAPE=SERIF | NONE
specifies whether the error bars have a serif cap.
FILLEDOUTLINEDMARKERS=TRUE | FALSE
specifies whether markers are drawn with both fill and an outline.
TRUE
draws filled markers (marker symbols with the suffix FILLED) using both fill
and an outline.
900 Chapter 6 / Plot Statements
When this option is TRUE, the fill color and outline color for filled markers
are determined in the following ways:
n If the GROUP= option is specified, then by default, the fill color is derived
from the GraphData1–GraphDataN style elements Color attribute, and
the marker outlined color is derived from the GraphData1–GraphDataN
style elements ContrastColor attribute.
n If the GROUP= option is not specified, then the marker fill is drawn by
using the MARKERFILLATTRS= specification, and the outline is drawn by
using the MARKEROUTLINEATTRS= specification.
FALSE
draws the markers using fill or an outline, but not both.
Default FALSE
Tip To specify the marker fill and outline colors for a non-grouped plot, set
this option to TRUE, and then use the MARKERFILLATTRS= and
MARKEROUTLINEATTRS= options to specify the colors.
“boolean ” on page xii for other Boolean values that you can use.
discrete-attr-var
specifies a discrete attribute map variable.
Restriction Starting with SAS 9.4M5, the number of vertices for a patterned
line cannot exceed the maximum specified by the ODS GRAPHICS
statement option LINEPATTERNOBSMAX=. The default is 10,000.
If the limit is exceeded, the plot is not drawn and a note is written
to the SAS log stating that the limit has been exceeded. In that
SERIESPLOT Statement 901
Interactions The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of marker
symbols, colors, and line patterns.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
Tips The representations that are used to identify the groups can be
overridden. For example, each distinct group value is often
represented by a different line pattern, but you can use the
LINEATTRS=(PATTERN=pattern) option to assign the same line
pattern to all of the plot’s line patterns, letting line color indicate
group values. Likewise, you could use LINEATTRS=(COLOR= color)
to assign the same color to all lines, letting line pattern indicate
group values.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies how marker groups are positioned for the coordinate pairs.
OVERLAY
draws markers for a given group value at the exact coordinate.
CLUSTER
draws markers for a given group value adjacent to each other.
902 Chapter 6 / Plot Statements
Tip Use the CLUSTERWIDTH= option to control the width of the clusters
when CLUSTER is in effect.
Default OVERLAY
Interaction For this option to take effect, the GROUP= option must also be
specified.
Note When you plot a SAS data set, the items for each group value are
drawn in data order. When you plot a CAS in-memory table, they are
drawn in ascending order of the group column character values or
unformatted numeric values.
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Tip This option is useful when you want to reverse the category axis.
ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.
Interactions This option is ignored if the GROUP= option is not also specified.
By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.
Notes When plotting a SAS data set, attributes such as color, symbol, and
pattern are assigned to each group in DATA order by default. When
plotting a CAS in-memory table, attributes are assigned in
ascending order of the group column character values or
unformatted numeric values by default.
formatted values. The data order of the observations and the visual
attributes that are assigned to the group values remain unchanged.
In SAS 9.4M6 and earlier releases, when data stored in a CAS in-
memory table is used and DATA or REVERSEDATA is specified,
unpredictable results might occur. To generate consistent graphs in
that case, specify ASCENDING or DESCENDING. Starting with SAS
Viya 3.5 and SAS Studio 5.2, when data stored in a CAS in-memory
table is used and DATA or REVERSEDATA is specified, it is ignored,
and ASCENDING is used instead.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color, marker symbol, and line
pattern) to one of the GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
904 Chapter 6 / Plot Statements
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Default The Y-column label. If a label is not defined, then the Y-column
name is used.
Restriction Starting with SAS 9.4M5, the number of vertices for a patterned
line cannot exceed the maximum specified by the ODS GRAPHICS
statement option LINEPATTERNOBSMAX=. The default is 10,000.
If the limit is exceeded, the plot is not drawn and a note is written
to the SAS log stating that the limit has been exceeded. In that
case, increase LINEPATTERNOBSMAX= to the value suggested in
the note or change the line pattern to SOLID.
Interactions This option’s COLOR= suboption overrides the default behavior for
grouped data when the LINECOLORGROUP= option and the
COLORRESPONSE= option are not specified. When the COLOR=
suboption is specified without the LINECOLORGROUP= and
COLORRESPONSE= options, all lines have the same color.
Tip If you specify a thickness of 2 pixels or greater for the series line,
use the LINEJOIN= option to shape the line vertices so that the line
does not extend beyond the marker symbols.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element.
discrete-attr-var
specifies a discrete attribute map variable.
Note A discrete attribute map variable is valid for this option starting
with SAS 9.4M3.
When this option is specified with the GROUP= option, the series line colors are
selected from the GraphData1–GraphDataN style elements based on the
LINECOLORGROUP= column instead of on the GROUP= column.
Default The line colors are selected based on the GROUP= column.
Requirement The column value must be the same for all of the points that
define a series line.
Interactions The GROUP= option must be specified for this option to have any
effect.
Note If you specify a column in a SAS data set, colors are mapped to
group values in data order. If you specify a column in a CAS in-
memory table, colors are mapped to group values in ascending
order of the group column character values or unformatted
numeric values.
LINEATTRS=
MITER
joins the line vertices without adjustment.
ROUND
rounds the apex of each line vertex, effectively smoothing the apex edges.
BEVEL
bevels the apex of each line vertex, effectively trimming the apex to remove
any part of the line that extends beyond the apex point.
The following figure shows the effect each value of LINEJOIN= on the vertex of
two segments of a 10-point line. The red dot depicts the data point at the
vertex.
Default MITER
Tip Use this option when the series line thickness is 2 pixels or greater to
prevent the line from extending beyond the marker symbols at points
where large slope changes occur.
discrete-attr-var
specifies a discrete attribute map variable.
Note A discrete attribute map variable is valid for this option starting
with SAS 9.4M3.
SERIESPLOT Statement 907
When this option is specified with the GROUP= option, the series line patterns
are selected from the GraphData1–GraphDataN style elements based on the
LINECOLORGROUP= column instead of on the GROUP= column.
Default The line patterns are selected based on the GROUP= column.
Requirement The column value must be the same for all of the points that
define a series line.
Interactions The GROUP= option must be specified for this option to have any
effect.
Note If you specify a column in a SAS data set, the group-value line
patterns are assigned in data order. If you specify a column in a
CAS in-memory table, group-value line patterns are assigned in
ascending order of the group column character values or
unformatted numeric values.
LINEATTRS=
LINETHICKNESSMAX=dimension
specifies the maximum line thickness when a response variable is used to
determine the line thickness. By default, this option determines the thickness of
the line that represents the maximum response column value.
LINETHICKNESSMAXRESPONSE=numeric | scalar-numeric-expression
specifies the response value that corresponds to the maximum line thickness.
Default The maximum value in the response column that is specified in the
LINETHICKNESSRESPONSE= option.
The thickness for all lines that exceed the maximum response value
is set to the value specified in the LINETHICKNESSMAX= option.
LINETHICKNESSMIN=dimension
specifies the minimum line thickness when a response variable is used to
determine the line thickness.
LINETHICKNESSRESPONSE=numeric-column | expression
specifies a response column or range attribute variable that is used to map a
line thickness to each group value.
Interactions When the column values are all zero, all negative, or all missing,
this option is ignored. In these cases, the default line thickness is
used for all of the lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
discrete-attr-var
specifies a discrete attribute map variable.
Note A discrete attribute map variable is valid for this option starting
with SAS 9.4M3.
When this option is specified with the GROUP= option, the series line markers
are selected from the GraphData1–GraphDataN style elements based on the
MARKERCOLORGROUP= column instead of on the GROUP= column.
Default The line marker colors are selected based on the GROUP= column.
Requirement The column value must be the same for all of the points that
define a series line.
SERIESPLOT Statement 911
Interactions The DISPLAY= option must enable the display of the series line
markers for this option to have any effect.
The GROUP= option must be specified for this option to have any
effect.
Note If you specify a column in a SAS data set, the group-value marker
colors are assigned in data order. If you specify a column in a CAS
in-memory table, group-value marker colors are assigned in
ascending order of the group column character values or
unformatted numeric values.
Tip Use the MARKERATTRS= option to set the marker symbol size.
MARKERFILLATTRS=style-element | (fill-options)
specifies the appearance of the filled markers.
MARKEROUTLINEATTRS=style-element | (line-options)
specifies the appearance of the marker outlines.
Interaction This option is ignored when a data skin is applied by the current
style or by the DATASKIN= option. In the latter case, the outline is
set by the data skin.
discrete-attr-var
specifies a discrete attribute map variable.
Note A discrete attribute map variable is valid for this option starting
with SAS 9.4M3.
When this option is specified with the GROUP= option, the series line marker
symbols are selected from the GraphData1–GraphDataN style elements based
on the MARKERSYMBOLGROUP= column instead of on the GROUP= column.
Default The line marker symbols are selected based on the GROUP=
column.
Requirement The column value must be the same for all of the points that
define a series line.
Interactions The GROUP= option must be specified for this option to have any
effect.
The DISPLAY= option must enable the display of the series line
markers for this option to have any effect.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a
column in a CAS in-memory table, the visual attributes for each
SERIESPLOT Statement 913
Tip Use the MARKERATTRS= option to set the marker symbol size.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
914 Chapter 6 / Plot Statements
Requirement The role names that you choose must be unique and different from
the predefined roles X, Y, CURVELABEL, DATALABEL, GROUP,
and INDEX.
SMOOTHCONNECT=TRUE | FALSE
specifies that a smoothed line passes through all vertices.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
SPLINEPOINTS=positive-integer
specifies a multiplier to apply to the time interval that is in effect for the
INTERVAL= axis option.
Default 20
Interaction When this option is set to a non-default value, markers and data
labels, when displayed, are positioned at their original data points.
SPLINETYPE=NONE | QUADRATICBEZIER
specifies the type of spline interpolation that is used to draw the series line.
Default NONE
Note Markers and data labels, when displayed, are positioned at their
original data points as shown in Figure 6.5 on page 914.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over the
series line. If this option is used, then the information specified replaces all the
information that is displayed by default. You can specify roles for columns that
do not contribute to the series plot along with roles that do.
(role-list)
an ordered, space-separated list of unique SERIESPLOT roles and user-
defined roles.
Example The following example displays data tips for the columns assigned
to the roles X and Y as well as the column Obs, which is not
assigned to any pre-defined SERIESPLOT role. The Obs column
must first be assigned a role.
ROLENAME=(TIP1=OBS)
TIP=(TIP1 X Y)
NONE
suppresses data tips and URLs (if requested) from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip You can control the labels and formats for the TIP roles with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
916 Chapter 6 / Plot Statements
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
URL=string-column
specifies an HTML page to display when a point or a segment of the curve is
selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each series line segment that is to have an active link.
Example http://www.sas.com
Tips The URL value can be blank for some X and Y pairs, meaning that
no action is taken when the corresponding segment is selected.
The URL value can be the same for any X and Y pair, meaning that
the same action is taken when the segment for those X and Y pairs
is selected.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
XERRORLOWER=numeric-column | expression
specifies values for the lower endpoints on the X error bars. The error bars are
drawn from the markers to the endpoints.
If markers are displayed in the plot, then the markers overlay the error
bars. Large filled markers can obscure short error bars. To enable the
error bars to show through the markers in that case, you can use the
MARKERATTRS= option to specify a degree of transparency for the
filled markers.
XERRORUPPER=numeric-column | expression
specifies values for the upper endpoints on the X error bars. The error bars are
drawn from the markers to the endpoints.
If markers are displayed in the plot, then the markers overlay the error
bars. Large filled markers can obscure short error bars. To enable the
error bars to show through the markers in that case, you can use the
MARKERATTRS= option to specify a degree of transparency for the
filled markers.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YERRORLOWER=numeric-column | expression
specifies values for the lower endpoints on the Y error bars. The error bars are
drawn from the markers to the endpoints.
If markers are displayed in the plot, then the markers overlay the error
bars. Large filled markers can obscure short error bars. To enable the
error bars to show through the markers in that case, you can use the
MARKERATTRS= option to specify a degree of transparency for the
filled markers.
YERRORUPPER=numeric-column | expression
specifies values for the upper endpoints on the Y error bars. The error bars are
drawn from the markers to the endpoints.
If markers are displayed in the plot, then the markers overlay the error
bars. Large filled markers can obscure short error bars. To enable the
error bars to show through the markers in that case, you can use the
MARKERATTRS= option to specify a degree of transparency for the
filled markers.
Details
The SERIESPLOT statement is typically used to show time-dependent data.
Examples
Example Program
/* Mean temperature data for August in 2014. */
data augusttemps;
input day temp dewpoint heat_index;
label day="Day of Month" Temp="Temperature"
Dewpoint="Dew Point" Heat_Index="Heat Index";
920 Chapter 6 / Plot Statements
datalines;
1 68.74 67.96 71.14
2 66.49 66.49 68.23
3 70.05 69.41 72.70
4 73.70 70.19 76.82
5 76.09 70.89 79.89
6 78.57 70.16 81.93
7 77.10 71.02 80.98
8 74.14 70.33 77.20
9 67.16 66.66 69.01
10 70.39 68.82 72.75
11 73.75 71.53 77.40
12 74.11 72.81 78.89
13 73.36 67.32 75.66
14 70.79 61.63 71.61
15 73.40 66.76 75.61
16 76.79 70.37 80.37
17 77.64 72.23 82.17
18 76.73 74.12 81.65
19 75.44 72.92 79.85
20 78.03 73.85 83.52
21 79.32 74.57 85.02
22 78.58 75.37 84.45
23 76.80 75.15 81.79
24 73.46 67.93 75.74
25 69.71 64.37 71.18
26 70.63 65.01 72.13
27 71.98 64.41 73.45
28 76.43 70.46 81.25
29 77.17 74.14 81.68
30 78.12 73.98 83.58
31 79.77 74.46 85.64
;
run;
proc template;
define statgraph seriesoverlay;
begingraph;
entrytitle "Mean Daily Outdoor Temperatures in August";
layout overlay / cycleattrs=true
xaxisopts=(type=linear
griddisplay=on gridattrs=(color=lightgray pattern=solid)
linearopts=(minorticks=true minortickcount=9
minorgrid=true minorgridattrs=(color=lightgray
pattern=dot)))
yaxisopts=(type=linear
label="Temperature ((*ESC*){unicode '00B0'x}F)"
griddisplay=on gridattrs=(color=lightgray pattern=solid)
linearopts=(minorticks=true minortickcount=4
minorgrid=true minorgridattrs=(color=lightgray
pattern=dot)));
seriesplot x = day y = temp / name="temp"
smoothconnect=true lineattrs=(thickness=3px);
seriesplot x = day y = heat_index / name = "heat_index"
smoothconnect=true
lineattrs=(thickness=2px pattern=shortdash);
SERIESPLOT Statement 921
Example Program
proc template;
define statgraph seriesplot;
begingraph;
entrytitle "Tech Stock Trends";
layout overlay /
xaxisopts=(label="Date (mm/yy)"
griddisplay=on gridattrs=(color=lightgray pattern=dot)
timeopts=(tickvalueformat=mmyys5. minorticks=true
minortickinterval=month))
yaxisopts=(griddisplay=on gridattrs=(color=lightgray
pattern=dot)
922 Chapter 6 / Plot Statements
linearopts=(minorticks=true minortickcount=5));
seriesplot x=date y=close / group=stock name="stocks";
discretelegend "stocks";
endlayout;
endgraph;
end;
run;
Example Program
/* Extract the 2001 data from Sashelp.Stocks
and convert Volume to millions. */
data stocks;
SERIESPLOT Statement 923
set sashelp.stocks(where=
(date between "1jan02"d and "31dec02"d));
volume = volume / 1000000;
format date MONNAME3. volume 6.2;
;
Example Program
proc template;
define statgraph seriesplot;
begingraph;
entrytitle "Stock Performance in 2002";
layout overlay /
xaxisopts=(type=discrete label="Month"
discreteopts=(tickvaluefitpolicy=thin));
seriesplot x=date y=close / name="series" group=stock
splinetype=quadraticbezier;
discretelegend "series" / across=3 displayclipped=true;
endlayout;
endgraph;
end;
STEPPLOT Statement
Displays a series of horizontal and vertical line segments that connect observations of input data.
Note: The STEPPLOT statement plots data in data order. For this reason, the input data
set should be sorted by the X variable. Otherwise, unexpected results might occur.
If the data is not sorted, you can specify CONNECTORDER=XAXIS in the
STEPPLOT statement. See CONNECTORDER= on page 931.
Syntax
STEPPLOT X=column | expression
Y=numeric-column | expression </options>;
ERRORBARCAPSCALE=positive-number
specifies a positive number to use as a multiplier for determining the
default width of the error-bar caps.
ERRORBARCAPSHAPE=SERIF | NONE
specifies whether the error bars have a serif cap.
ERRORLOWER=numeric-column | expression
specifies the values of the lower endpoints on the Y error bars.
ERRORUPPER=numeric-column | expression
specifies the values of the upper endpoints on the Y error bars.
FILLEDOUTLINEDMARKERS=TRUE | FALSE
specifies whether markers are drawn with both fill and an outline.
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color, marker symbol, and
line pattern) to one of the GraphData1–GraphDataN style elements.
JUSTIFY=(LEFT | CENTER | RIGHT)
specifies the location of the data point relative to the step.
LINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the step line connecting the data points.
LINETHICKNESSMAX=dimension
specifies the maximum line thickness when a response variable is used to
determine the line thickness.
LINETHICKNESSMAXRESPONSE=numeric | scalar-numeric-expression
specifies the response value that corresponds to the maximum line
thickness.
LINETHICKNESSMIN=dimension
specifies the minimum line thickness when a response variable is used to
determine the line thickness.
LINETHICKNESSRESPONSE=numeric-column | expression
specifies a response column or range attribute variable that is used to
map a line thickness to each group value.
MARKERATTRS=style-element | style-element (marker-options) | (marker-
options)
specifies the attributes of the data markers.
MARKERFILLATTRS=style-element | (fill-options)
specifies the appearance of the filled markers.
MARKEROUTLINEATTRS=style-element | (line-options)
specifies the appearance of the marker outlines.
Axes options
CLUSTERAXIS=AUTO | X | Y
specifies the axis to use for clustering groups when
GROUPDISPLAY=CLUSTER.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
STEPPLOT Statement 927
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Connect options
CONNECTORDER=XVALUES | XAXIS
specifies how to connect the data points to form the step line.
JOIN=TRUE | FALSE
specifies whether the steps are connected.
Label options
CURVELABEL="string" | column | expression
specifies a label for the step line.
CURVELABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the step-line labels.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the step-line label relative to the plot area.
CURVELABELPOSITION=AUTO | MAX | MIN | START | END
specifies the position of the step-line labels relative to the step line.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the step-line label at the specified split
characters.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the step-line label can be split
if needed.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the step-line label
text.
CURVELABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the step-line label
block.
DATALABEL=column | expression
specifies a column that supplies values for the data point labels.
DATALABELATTRS=style-element | style-element (text-options) | (text-
options)
specifies the color and font attributes of the data labels.
928 Chapter 6 / Plot Statements
Midpoint options
DISCRETEOFFSET=number
specifies an amount to offset all step lines and markers from discrete X
values when graphing multiple response variables side by side on a
common axis.
GROUP=column | discrete-attr-var | expression
creates a distinct set of lines, markers, and data labels for each unique
group value of the specified column.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies whether grouped step lines and markers are overlaid or
clustered around the category midpoints.
GROUPORDER=DATA | REVERSEDATA | ASCENDING | DESCENDING
specifies the ordering of the groups within a category.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
ODS options
URL=string-column
specifies an HTML page to display when a step line segment is selected.
Required Arguments
X=column | expression
specifies the column of the X values.
Y=numeric-column | expression
specifies the numeric column of the Y values.
STEPPLOT Statement 929
Optional Arguments
ARROWHEADPOSITION= NONE | START | END | BOTH | column
specifies a position for arrowheads.
NONE
no arrowheads are displayed.
START
an arrowhead is displayed at the starting point of each line.
END
an arrowhead is displayed at the ending point of each line.
BOTH
an arrowhead is displayed at each end of each line.
column
specifies a column that provides an arrowhead position for each group value.
Default NONE
Restriction When you specify a column and the GROUP= option is in effect, the
arrowhead position values are assumed to be constant for each
group value. If the column has multiple values for a single group
value, then only one of the arrowhead position values is used for
that group.
Default 1.0
Restriction The arrowhead scale values are assumed to be constant for each
line. If a column or expression provides multiple values for a line,
only one of the values is used.
Default OPEN
Restriction When you specify a column and the GROUP= option is in effect, the
arrowhead shape values are assumed to be constant for each group
value. If the column has multiple values for a single group value,
only one of the arrowhead shape values is used for that group.
BREAK=TRUE | FALSE
determines whether the plot line should show breaks at occurrences of missing
values of the Y column.
Default FALSE
Note When this option is set to FALSE, missing values are skipped and the
line continues through the missing value and to the next point.
See “boolean ” on page xii for other Boolean values that you can use.
CLUSTERAXIS=AUTO | X | Y
specifies the axis to use for clustering groups when GROUPDISPLAY=CLUSTER.
AUTO
uses the discrete axis for clustering groups when only one axis is discrete.
Uses the X axis for clustering if both axes are discrete or interval.
X
Y
uses the X or Y axis for clustering groups.
Default AUTO
CLUSTERWIDTH=number
on a discrete axis, specifies the width of the group clusters as a fraction of the
midpoint spacing. On an interval axis, specifies the width of the group clusters
as a fraction of the minimum interval between adjacent data values.
STEPPLOT Statement 931
Default 0.85
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
Interactions For this option to take effect, the GROUP= option must also be
specified, and the GROUPDISPLAY= option must be set to
CLUSTER.
CONNECTORDER=XVALUES | XAXIS
specifies how to connect the data points to form the step line.
XVALUES
connects data points in the data order of the X column.
Note In SAS 9.4M6 and earlier releases, unexpected results might occur
when XVALUES is specified and data stored in a CAS in-memory table
is used. In that case, use XAXIS instead. Starting with SAS Viya 3.5
and SAS Studio 5.2, XVALUES is ignored when data stored in a CAS in-
memory table is used.
XAXIS
connects data points sorted by their X values.
Tip When the input data for the step lines is not sorted by the X column,
you can use XAXIS to assure the expected connect order.
Restrictions When the GROUP= option is specified, "string" and expression are
not valid. Use column in that case.
When the GROUP= option is not specified, column is not valid. Use
"string" or expression in that case.
Tip The font and color attributes for the label are specified by the
CURVELABELATTRS= option.
Interactions For this option to take effect, the CURVELABEL= option must also
be used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the step-line label relative to the plot area.
INSIDE
locates the labels inside the plot area
OUTSIDE
locates the labels outside the plot area
Default INSIDE
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
AUTO
automatically positions the step-line label near the step boundary along
unused axes whenever possible (typically Y2 and X2) in order to avoid
collision with tick values.
MAX
forces the step-line label to appear near maximum step values (typically,
upper right)
MIN
forces the step-line label to appear near minimum step values (typically,
lower left)
START
forces the step-line label to appear near the beginning of the steps.
Tip This option is particularly useful when the step line spirals
around.
END
forces the step-line label to appear near the end of the steps.
Tip This option is particularly useful when the step line spirals
around.
Interactions For this option to take effect, the CURVELABEL= option must also
be specified.
CURVELABELSPLIT=TRUE | FALSE
specifies whether to split the step-line label at the specified split characters.
When a step-line label is split, the label is split on each occurrence of the
specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
CURVELABELSPLITCHAR="character-list"
specifies one or more characters on which the step-line label can be split if
needed. When multiple split characters are specified, each character in the list
is treated as a separate split character unless the specified characters appear
consecutively in the step-line label. In that case, all of the specified split
characters together are treated as a single split character.
"character-list"
one or more characters with no delimiter between each character and
enclosed in quotation marks.
CURVELABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the step-line label text.
TRUE
drops the split characters from the step-line label text.
FALSE
includes the split characters in the step-line label text.
The following figure shows an example of a step-line label with the following
specifications:
n CURVELABELPOSITION=MAX
n CURVELABEL="Product*Group*A"
n CURVELABELSPLIT=TRUE
n CURVELABELSPLITCHARDROP=TRUE | FALSE
n CURVELABELSPLITCHAR="*"
Note: The horizontal line to the left of the label represents the maximum end of
the step line for reference.
Default TRUE. The split characters are dropped from the step-line label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the CURVELABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The horizontal line to the left of each label represents the maximum end
of the step line for reference.
Default AUTO
DATALABEL=column | expression
specifies a column that supplies values for the data point labels.
Note The label positions are adjusted to prevent the labels from overlapping.
Interactions For this option to take effect, the DATALABEL= option must also
be specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO
uses a data-label collision avoidance algorithm to position the labels.
Note When AUTO is in effect, in some cases, the data label font size might
be reduced in order to avoid overlapping labels and markers.
TOPRIGHT
TOP
TOPLEFT
LEFT
CENTER
RIGHT
BOTTOMLEFT
BOTTOM
BOTTOMRIGHT
specifies a location for all of the data labels.
Default AUTO
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at the specified split characters.
938 Chapter 6 / Plot Statements
See “boolean ” on page xii for other Boolean values that you can use.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the data label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
STEPPLOT Statement 939
TRUE
drops the split characters from the data label.
FALSE
includes the split characters in the data label.
The following figure shows an example of a data label with the following
specifications:
n the data label text for this label is Product*Group*A
n DATALABELSPLIT=TRUE
n DATALABELSPLITCHARDROP=TRUE | FALSE
n DATALABELSPLITCHAR="*"
Default TRUE. The split characters are dropped from the data label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the DATALABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The gray vertical line at the bottom of each label represents the
horizontal center of the text box for reference.
Default AUTO
Restriction Starting with SAS 9.4M1, the maximum number of skinned graphical
elements is limited to 200 per plot in an OVERLAY or PROTOTYPE
layout. When this limit is exceeded for a plot, the specified data skin
is not applied to that plot. In that case, use the DATASKINMAX=
option in your ODS GRAPHICS statement to increase the maximum
limit.
DATATRANSPARENCY=number
specifies the degree of the transparency of the step lines, markers, error bars,
step-line labels, and data labels, when displayed.
Default 0
DISCRETEOFFSET=number
specifies an amount to offset all step lines and markers from discrete X values
when graphing multiple response variables side by side on a common axis.
Default 0 (no offset, all step lines and markers are centered on the discrete
X values)
Range -0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. A positive offset is to the right. If the layout’s axis
options set REVERSE=TRUE, then the offset direction is also
reversed.
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
(display-options)
a space-separated list of one or more options enclosed in parentheses.
Currently, only the MARKERS option is supported, which displays a step line
with markers.
STANDARD
displays a step line without markers.
942 Chapter 6 / Plot Statements
ALL
displays a step line with markers.
Default STANDARD
Interaction For this option to take effect, error bars must be displayed by the
ERRORLOWER= , ERRORUPPER= options.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
ERRORBARCAPSCALE=positive-number
specifies a positive number to use as a multiplier for determining the default
width of the error-bar caps.
Default 1
ERRORBARCAPSHAPE=SERIF | NONE
specifies whether the error bars have a serif cap.
STEPPLOT Statement 943
ERRORLOWER=numeric-column | expression
specifies the values of the lower endpoints on the Y error bars.
Requirement The error bar values must be absolute data values, not data values
relative to the value of the bar.
Interaction When this option is specified, the DATALABEL= on page 308 and
DATALABELTYPE= on page 314 options are ignored, and data
labels are not displayed.
ERRORUPPER=numeric-column | expression
specifies the values of the upper endpoints on the Y error bars.
Requirement The error bar values must be absolute data values, not data values
relative to the value of the bar.
Interaction When this option is specified, the DATALABEL= on page 308 and
DATALABELTYPE= on page 314 options are ignored, and data
labels are not displayed.
FILLEDOUTLINEDMARKERS=TRUE | FALSE
specifies whether markers are drawn with both fill and an outline.
TRUE
draws filled markers (marker symbols with the suffix FILLED) using both fill
and an outline.
When this option is TRUE, the fill color and outline color for filled markers
are determined in the following ways:
n If the GROUP= option is specified, then by default, the fill color is derived
from the GraphData1–GraphDataN style elements Color attribute, and
944 Chapter 6 / Plot Statements
FALSE
draws the markers using fill or an outline, but not both.
Default FALSE
Tip To specify the marker fill and outline colors for a non-grouped plot, set
this option to TRUE, and then use the MARKERFILLATTRS= and
MARKEROUTLINEATTRS= options to specify the colors.
“boolean ” on page xii for other Boolean values that you can use.
discrete-attr-var
specifies a discrete attribute map variable.
Restriction Starting with SAS 9.4M5, the number of vertices for a patterned
line cannot exceed the maximum specified by the ODS GRAPHICS
statement option LINEPATTERNOBSMAX=. The default is 10,000.
If the limit is exceeded, the plot is not drawn and a note is written
to the SAS log stating that the limit has been exceeded. In that
case, increase LINEPATTERNOBSMAX= to the value suggested in
the note or change the line pattern to SOLID.
Interactions The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of marker
symbols, colors, and line patterns.
STEPPLOT Statement 945
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
Tips The representations that are used to identify the groups can be
overridden. For example, each distinct group value is often
represented by a different line pattern, but the
LINEATTRS=(PATTERN=pattern) option could be used to assign
the same line pattern to all of the plot’s line patterns, letting line
color indicate group values. Likewise, LINEATTRS=(COLOR=color)
could be used to assign the same color to all lines, letting line
pattern indicate group values.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies whether grouped step lines and markers are overlaid or clustered
around the category midpoints.
OVERLAY
centers the step lines and markers for matching category values on the
midpoints.
The step lines in each set of group values are superimposed on each other.
CLUSTER
clusters the step lines and markers for matching category values around the
midpoints on a discrete axis or around the intervals on an interval axis.
Each cluster of group values is centered at the midpoint for the category.
Default OVERLAY
Restriction For this option to take effect, the GROUP= option must also be
specified.
Note When you plot a SAS data set, the items for each group value are
drawn in data order. When you plot a CAS in-memory table, they are
drawn in ascending order of the group column character values or
unformatted numeric values.
DATA
orders the groups within a category in the group-column data order.
REVERSEDATA
orders the groups within a category in the reverse group-column data order.
Tip This option is useful when you want to reverse the category axis.
ASCENDING
orders the groups within a category in ascending order.
DESCENDING
orders the groups within a category in descending order.
Interactions This option is ignored if the GROUP= option is not also specified.
By default, the groups in the legend are shown in the order that is
specified in GROUPORDER.
Notes When plotting a SAS data set, attributes such as color, symbol, and
pattern are assigned to each group in DATA order by default. When
plotting a CAS in-memory table, attributes are assigned in
ascending order of the group column character values or
unformatted numeric values by default.
In SAS 9.4M6 and earlier releases, when data stored in a CAS in-
memory table is used and DATA or REVERSEDATA is specified,
unpredictable results might occur. To generate consistent graphs in
that case, specify ASCENDING or DESCENDING. Starting with SAS
Viya 3.5 and SAS Studio 5.2, when data stored in a CAS in-memory
table is used and DATA or REVERSEDATA is specified, it is ignored,
and ASCENDING is used instead.
Tip Use the INDEX= option to alter the default sequence of visual
attributes that is assigned to the groups.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
STEPPLOT Statement 947
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color, marker symbol, and line
pattern) to one of the GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
JOIN=TRUE | FALSE
specifies whether the steps are connected.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
Default LEFT
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Default The Y-column label. If a label is not defined, then the Y-column
name is used.
Restriction Starting with SAS 9.4M5, the number of vertices for a patterned line
cannot exceed the maximum specified by the ODS GRAPHICS
statement option LINEPATTERNOBSMAX=. The default is 10,000. If
the limit is exceeded, the plot is not drawn and a note is written to
the SAS log stating that the limit has been exceeded. In that case,
increase LINEPATTERNOBSMAX= to the value suggested in the
note or change the line pattern to SOLID.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
LINETHICKNESSMAX=dimension
specifies the maximum line thickness when a response variable is used to
determine the line thickness. By default, this option determines the thickness of
the line that represents the maximum response column value.
LINETHICKNESSMAXRESPONSE=numeric | scalar-numeric-expression
specifies the response value that corresponds to the maximum line thickness.
Default The maximum value in the response column that is specified in the
LINETHICKNESSRESPONSE= option.
The thickness for all lines that exceed the maximum response value
is set to the value specified in the LINETHICKNESSMAX= option.
LINETHICKNESSMIN=dimension
specifies the minimum line thickness when a response variable is used to
determine the line thickness.
LINETHICKNESSRESPONSE=numeric-column | expression
specifies a response column or range attribute variable that is used to map a
line thickness to each group value.
Interactions When the column values are all zero, all negative, or all missing,
this option is ignored. In these cases, the default line thickness is
used for all of the lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
MARKERFILLATTRS=style-element | (fill-options)
specifies the appearance of the filled markers.
MARKEROUTLINEATTRS=style-element | (line-options)
specifies the appearance of the marker outlines.
Interaction This option is ignored when a data skin is applied by the current
style or by the DATASKIN= option. In the latter case, the outline is
set by the data skin.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
STEPPLOT Statement 953
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles X, Y, CURVELABEL, DATALABEL,
ERRORLOWER, ERRORUPPER, GROUP, and INDEX.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over the step
line. If this option is used, then it replaces all of the information that is displayed
by default. Roles for columns that do not contribute to the step plot can be
specified along with roles that do.
(role-list)
an ordered, space-separated list of unique STEPPLOT and user-defined
roles.
Example The following example displays data tips for the columns assigned
to the roles X and Y as well as the column Obs, which is not
assigned to any pre-defined STEPPLOT role. The Obs column must
first be assigned a role.
ROLENAME=(TIP1=OBS)
TIP=(TIP1 X Y)
NONE
suppresses data tips and URLs (if requested) from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
URL=string-column
specifies an HTML page to display when a step line segment is selected.
STEPPLOT Statement 955
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each step line segment that is to have an active link.
Example http://www.sas.com
Tips The URL value can be blank for some X and Y pairs, meaning that
no action is taken when the corresponding segment is selected.
The URL value can be the same for any X and Y pairs, meaning that
the same action is taken when the segment for those X and Y pairs
are selected.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
956 Chapter 6 / Plot Statements
Details
For character columns, the X axis is always discrete. For numeric columns, both the
X and Y axes are linear by default. You can change the axis type for numeric axes
with the XAXISOPTS= and YAXISOPTS= options of the containing OVERLAY
layout.
By default, the STEPPLOT statement uses the X values in data order. You can use
the CONNECTORDER= option to change the order.
Input Data
Here is the DATA step code that generates the input data for this example.
data Study;
input Group : $10. Time Status @@;
label Time="Time (Days)";
datalines;
Low-Risk 2569 0 Low-Risk 2506 0 Low-Risk 2409 0
Low-Risk 2218 0 Low-Risk 1857 0 Low-Risk 1829 0
Low-Risk 1562 0 Low-Risk 1470 0 Low-Risk 1363 0
Low-Risk 1030 0 Low-Risk 860 0 Low-Risk 1258 0
STEPPLOT Statement 957
Example Program
Here is the program code for this example.
proc template;
define statgraph stepplot;
begingraph;
entrytitle "Kaplan-Meier Survival Plot";
layout overlay /
yaxisopts=(linearopts=(viewmin=0 viewmax=1));
stepplot x=Time y=Survival /
group=Stratum name="step";
scatterplot x=Time y=Censored / name="scat"
legendlabel="Censored" markerattrs=(symbol=plus);
discretelegend "step" / location=inside
halign=right valign=top across=1;
discretelegend "scat" /
location=inside halign=center valign=top;
endlayout;
endgraph;
end;
run;
958 Chapter 6 / Plot Statements
ods graphics;
ods exclude all;
ods output survivalplot=plotdata;
proc lifetest data=Study plots=(survival);
time Time * Status(0);
survival;
strata Group;
run;
ods select all;
SURFACEPLOTPARM Statement
Creates a three-dimensional surface representing a response variable evaluated over a grid of X and
Y values.
Syntax
SURFACEPLOTPARM X=numeric-column | expression
Y=numeric-column | expression
Z=numeric-column | expression </options>;
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by
either the ODS style that is in effect or by the COLORMODEL= option.
SURFACECOLORGRADIENT=numeric-column | range-attr-var
specifies the column or range attribute map variable that is used to
determine the surface colors (in SAS 9.4M1 and earlier releases).
SURFACETYPE=FILLGRID | FILL | WIREFRAME
specifies how the surface is displayed.
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
Label options
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Required Arguments
X=numeric-column | expression
specifies the X coordinates of the grid.
Y=numeric-column | expression
specifies the Y coordinates of the grid.
Z=numeric-column | expression
specifies the height of response values.
Note The input data should be sorted by both 1) the Y column and 2) the X
column. The sort direction for Y should be ascending. The sort direction
of X be either ascending or descending.
Optional Arguments
COLORMODEL=style-element | (color-list)
specifies a color ramp that is to be used with the COLORRESPONSE= or
SURFACECOLORGRADIENT= option.
style-element
specifies the name of a style element.
(color-list)
specifies a space-separated list of colors to use in the color ramp.
Note: Starting with SAS 9.4M2, the COLORRESPONSE= option replaces the
SURFACECOLORGRADIENT= option. The syntax and functionality are the
same. The SURFACECOLORGRADIENT= option is still honored, but the
COLORRESPONSE= option is preferred.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
You can use this option to add a second response variable to an analysis. For an
example, see “Example 1: Surface Plot” on page 963.
DATATRANSPARENCY=number
specifies the degree of the transparency of the surface.
Default 0
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Default The Z-column label. If a label is not defined, then the Z-column
name is used.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
962 Chapter 6 / Plot Statements
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an OVERLAY3D layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by either
the ODS style that is in effect or by the COLORMODEL= option.
Default FALSE
See COLORMODEL=
“boolean ” on page xii for other Boolean values that you can use.
SURFACECOLORGRADIENT=numeric-column | range-attr-var
specifies the column or range attribute map variable that is used to determine
the surface colors (in SAS 9.4M1 and earlier releases).
FILLGRID
specifies a filled surface with superimposed grid lines
FILL
specifies a filled surface without grid lines
WIREFRAME
specifies an unfilled surface with grid lines
Default FILLGRID
Details
The SURFACEPLOTPARM statement assumes that the Z response values have
been provided for a uniform X-Y grid. Missing Z values leave a “hole” in the surface.
The observations in the input data set should form an evenly spaced grid of
horizontal (X and Y) values and one vertical (Z) value for each of these
SURFACEPLOTPARM Statement 963
The KDE procedure can produce an output data set of gridded X-Y values where the
Z value is computed to be a Kernel Density Estimate of the distribution of X and Y.
For more information, see The KDE Procedure in SAS/STAT User’s Guide.
Examples
Example Program
Here is the code for this example. The COLORRESPONSE= option is valid starting
with SAS 9.4M2. For prior releases, use the SURFACECOLORGRADIENT= option
instead.
proc template;
define statgraph surfaceplotparm;
964 Chapter 6 / Plot Statements
begingraph;
entrytitle "Surface Plot of Lake Bed";
layout overlay3d / cube=false;
surfaceplotparm x=length y=width z=depth /
reversecolormodel=true
colorresponse=depth
colormodel=twocoloraltramp;
endlayout;
endgraph;
end;
Input Data
Here is the SAS code that generates the data for this example.
data nums;
do i=1 to 30;
SURFACEPLOTPARM Statement 965
X=10*ranuni(33)-5;
Y=10*ranuni(33)-5;
Z=sin(sqrt(x*x+y*y));
output;
end;
run;
proc g3grid data=nums out=gridded;
grid y*x=z / spline
axis1=-5 to 5 by 0.1
axis2=-5 to 5 by 0.1;
run;
proc sort data=gridded; by y x; run;
Example Program
proc template;
define statgraph g3grid_surface;
begingraph;
entrytitle "Spline Interpolation";
layout overlay3d;
surfaceplotparm x=x y=y z=z /
surfacetype=fill;
endlayout;
endgraph;
end;
run;
Input Data
Here is the SAS code that generates the data for this example.
data nums;
do i=1 to 30;
X=10*ranuni(33)-5;
Y=10*ranuni(33)-5;
Z=sin(sqrt(x*x+y*y));
output;
end;
run;
proc kde data=nums;
bivar x y / ngrid=100
gridl=-5 gridu=5
out=binned(rename=(value1=X value2=Y));
run;
proc sort data=binned; by y x;
label x="X" y="Y";
run;
Example Program
proc template;
define statgraph kde_surface;
begingraph;
entrytitle "Kernel Density Estimate";
TEXTPLOT Statement 967
layout overlay3d;
surfaceplotparm x=x y=y z=density /
surfacetype=fill;
endlayout;
endgraph;
end;
run;
TEXTPLOT Statement
Displays text values at specific X and Y locations in the graph.
Syntax
TEXTPLOT X=column | expression
Y=column | expression
TEXT=column | expression </options>;
Axes options
CLUSTERAXIS=AUTO | X | Y
specifies the axis to use for clustering groups when
GROUPDISPLAY=CLUSTER.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Experimental options
OUTFILE=fileref | "filename"
TEXTPLOT Statement 969
specifies a file for storing information about the text bounding-box for
each text value in the column specified in the OUTID= option.
OUTID=column | expression
specifies a column that contains text values to write to the file specified
in the OUTFILE= option.
Label options
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
DISCRETEOFFSET=number
specifies the distance to offset all text values from discrete X values,
discrete Y values, or both.
GROUP=column | discrete-attr-var | expression
creates a separate text value for each unique group value in the specified
column.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies how marker groups are positioned for the coordinate pairs.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
ODS options
URL=string-column
specifies an HTML page to display when a text value is selected.
Text options
FORMAT=format
specifies a SAS format or a user-defined format for the TEXT= column.
POSITION=BOTTOM | BOTTOMLEFT | BOTTOMRIGHT | CENTER | LEFT |
RIGHT | TOP | TOPLEFT | TOPRIGHT | keyword-column
specifies the position of the text value with respect to the location of the
data point.
POSITIONOFFSETX=number | numeric-column
specifies the positive or negative X offset for an individual text item.
POSITIONOFFSETY=number | numeric-column
specifies the positive or negative Y offset for an individual text item.
ROTATE=number | numeric-column
specifies the angle of rotation, in degrees, for the text values.
SIZEMAX=dimension
specifies the maximum font size for a text marker when a response
variable is used to size the text-marker font.
SIZEMAXRESPONSE=numeric | scalar-numeric-expression
970 Chapter 6 / Plot Statements
specifies the response value that corresponds to the maximum font size
for text markers.
SIZEMIN=dimension
specifies the minimum font size for text markers when a response
variable is used to size the font for text values.
SIZERESPONSE=numeric-column | numeric-expression
specifies a response column that is used to determine the font size for
each text value.
SPLITCHAR="character-list"
specifies one or more characters on which the text-marker text can be
split.
SPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the text-marker
text.
SPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the lines of text in the text-marker text
blocks.
SPLITPOLICY=NONE | SPLIT | SPLITALWAYS
specifies a policy for avoiding collisions among the text values.
SPLITWIDTH=AUTO | width-in-characters
specifies the maximum width of each split line.
STRIP=TRUE | FALSE
specifies whether leading and trailing blanks should be stripped from the
text-marker text before it is displayed.
VCENTER=BBOX | BASELINE
specifies whether the text is vertically centered with respect to the text
bounding box or to the text baseline.
Required Arguments
X=column
specifies the column for the X values.
Y=column
specifies the column for the Y values.
TEXT=column
specifies the column for the text values that are to be used for the markers.
Optional Arguments
BACKLIGHT=number | AUTO
specifies a back-light effect for the marker text. The effect is applied only to the
marker text.
number
specifies the degree of the back-light effect.
AUTO
the system selects an appropriate level for the back-light effect.
TEXTPLOT Statement 971
The following figure shows the effect on the text of an outlined, filled text
marker.
The back light is based on text color. For dark colors, a contrasting white back-
light effect is used. For lighter colors, a contrasting black back-light effect is
used. The following figure shows the two back-light types when BACKLIGHT=1.
Note If the background color is white, the white backlight effect for dark
text colors is not visible. Conversely, if the background color is
black, the black backlight effect for light text colors is not visible.
Tip The BACKLIGHT= option is most effective when the text color has a
low level of contrast with the background or when the background is
cluttered.
CLUSTERAXIS=AUTO | X | Y
specifies the axis to use for clustering groups when GROUPDISPLAY=CLUSTER.
AUTO
uses the discrete axis for clustering groups when only one axis is discrete.
Uses the X axis for clustering if both axes are discrete or interval.
X
Y
uses the X or Y axis for clustering groups.
Default AUTO
CLUSTERWIDTH=number
on a discrete axis, specifies the width of the group clusters as a fraction of the
midpoint spacing. On an interval axis, specifies the width of the group clusters
as a fraction of the minimum interval between adjacent data values.
Default 0.85
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is
the maximum possible width
Interaction For this option to take effect, the GROUP= option must also be
specified, and the GROUPDISPLAY= option must be set to
CLUSTER.
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.
Tip To reverse the start and end colors of the ramp that is assigned to
the color model, use the REVERSECOLORMODEL= option.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
You can use this option to add a second response variable to an analysis.
Note The gradient in a continuous legend for this plot reflects the text
colors.
Use the FILLATTRS= option to set the text bounding-box fill color
to a fixed color or to modify the fill transparency.
ALL
the space requirements for this plot are contributed to the axis offset
calculations.
NONE
the space requirements for this plot are not contributed to the axis offset
calculations.
(axis-offset-list)
a space-delimited list of specific contributions that this plot makes to the
axis offset calculations.
XMAX
the space requirements for this plot are contributed to the X-axis offset
calculation for the maximum end.
XMIN
the space requirements for this plot are contributed to the X-axis offset
calculation for the minimum end.
YMAX
the space requirements for this plot are contributed to the Y-axis offset
calculation for the maximum end.
YMIN
the space requirements for this plot are contributed to the Y-axis offset
calculation for the minimum end.
Default ALL
Interaction Offsets that are set in the layout axis options are always honored,
regardless of the setting on this option.
Note This option does not affect offset requests from other plots.
DATATRANSPARENCY=number
specifies the degree of the transparency of the text.
Default 0
DISCRETEOFFSET=number
specifies the distance to offset all text values from discrete X values, discrete Y
values, or both.
Default 0 (no offset, all text values are centered on the discrete X values, or
discrete Y values, or both)
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete tick marks. A positive offset is to the right on discrete X
values and is up on discrete Y values. If the layout’s axis options set
REVERSE=TRUE, then the offset direction is also reversed.
Restriction This option applies to discrete axes only. For nondiscrete axes, this
option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
(display-options)
a space-separated list of one or more display options, enclosed in
parentheses.
FILL
displays filled bounding boxes around the text
OUTLINE
displays outlined bounding boxes around the text
STANDARD
displays the text only
ALL
specifies FILL and OUTLINE
Default STANDARD
FILLATTRS=style-element | (fill-options)
specifies the appearance of the filled areas of the text. When fill options are
specified, only the COLOR= and TRANSPARENCY= suboptions are honored.
Interactions For this option to have any effect, the fill must be enabled by the
ODS style or by the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element.
FORMAT=format
specifies a SAS format or a user-defined format for the TEXT= column.
Default The format that is in effect for the column that is specified in the
TEXT= argument. If no format is in effect, BEST6 is used for numeric
columns.
Note Not all of the SAS formats are supported. See Appendix 4, “Format
Support in ODS Graphics,” on page 1621.
discrete-attr-var
specifies a discrete attribute map variable.
TEXTPLOT Statement 977
Tip For each value in the discrete attribute map, the VALUE
statement TEXTATTRS= option determines the text color, the
LINEATTRS= option determines the bounding-box outline color,
and the FILLATTRS= option determines the bounding-box fill
color and transparency.
Interactions The group values are mapped in the order in which they appear in
the data.
Notes The legend entries for this plot reflect the text colors.
If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
GROUPDISPLAY=OVERLAY | CLUSTER
specifies how marker groups are positioned for the coordinate pairs.
OVERLAY
draws text values for a given group value at the exact coordinate.
CLUSTER
draws text values for a given group value adjacent to each other.
Default OVERLAY
Note When you plot a SAS data set, the items for each group value are
drawn in data order. When you plot a CAS in-memory table, they are
drawn in ascending order of the group column character values or
unformatted numeric values.
Tip Use the CLUSTERWIDTH= option to control the width of the clusters
when CLUSTER is in effect.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
INDEX=positive-integer-column | expression
specifies indices for mapping marker text color to one of the GraphData1–
GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
TEXTPLOT Statement 979
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Default The TEXT-column label. If a label is not defined, then the TEXT-
column name is used.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
OUTFILE=fileref | "filename"
specifies a file for storing information about the text bounding-box for each text
value in the column specified in the OUTID= option. The information is written
in the comma-separated value (CSV) format.
CAUTION
OUTFILE= is an experimental option that is available in SAS 9.4M3. Do not
use this option in production jobs.
Interaction The OUTID= option must be specified for this option to have any
effect.
Note This option is a specialized feature for users who want to customize
the placement of the text in a text plot.
Tip Use the IMPORT procedure to import the CSV values into a SAS
data set.
OUTID=column | expression
specifies a column that contains text values to write to the file specified in the
OUTFILE= option.
980 Chapter 6 / Plot Statements
CAUTION
OUTID= is an experimental option that is available in SAS 9.4M3. Do not use
this option in production jobs.
Interaction The OUTFILE= option must be specified for this option to have any
effect.
Note This option is a specialized feature for users who want to customize
the placement of the text in a text plot.
Restriction This option uses only the color specification in the style element or
line options. The line pattern and line thickness specifications are
ignored.
Interactions For this option to have any effect, outlines must be enabled by the
ODS style or by the DISPLAY= option.
Note This plot’s legend entries reflect the marker text color.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element.
PAD=dimension | (pad-options)
specifies the amount of extra space to add inside the text-marker border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the text-marker border.
(pad-options)
a space-separated list of one or more pad options, enclosed in parentheses.
The list can include one or more of the following name-value-pair options:
LEFT=dimension TOP=dimension
RIGHT=dimension BOTTOM=dimension
TEXTPLOT Statement 981
Note Sides that are not assigned padding are padded with the default
amount.
Tips This option is meaningful only when the DISPLAY= option displays
fills, outlines, or both.
keyword-column
specifies a column that contains position options.
The VCENTER= option specifies whether the position is relative to the text
bound box or the text baseline. See the VCENTER= option. By default, the
positions are relative to the text bounding box. The following figure shows the
effect of each of these values on the position of an outlined text value when
VCENTER=BBOX is in effect. The red dot indicates the marker data-point
location.
982 Chapter 6 / Plot Statements
Default CENTER
POSITIONOFFSETX=number | numeric-column
specifies the positive or negative X offset for an individual text item.
The offset is relative to the item's data coordinate. The value can be greater
than 1. The offset unit is the font height of the current text item, which varies
according to the text's font size based on size response, and so on.
Notes A value of 1 implies an X offset that is the same distance as the current
text item's font height.
Tip This option is most useful when the text is placed around other objects
in the graph.
POSITIONOFFSETY=number | numeric-column
specifies the positive or negative Y offset for an individual text item.
The offset is relative to the item's data coordinate. The value can be greater
than 1. The offset unit is the font height of the current text item, which varies
according to the text's font size based on size response, and so on.
Notes A value of 1 implies an Y offset that is the same distance as the current
text item's font height.
Tip This option is most useful when the text is placed around other objects
in the graph.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
TEXTPLOT Statement 983
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
REVERSECOLORMODEL=TRUE | FALSE
specifies whether to reverse the gradient (color ramp) that is defined by either
the ODS style that is in effect or by the COLORMODEL= option.
Default FALSE
See COLORMODEL=
“boolean ” on page xii for other Boolean values that you can use.
ROTATE=number | numeric-column
specifies the angle of rotation, in degrees, for the text values. Positive angles
are measured in a counter-clockwise direction, and negative angles are
measured in a clockwise direction. You can use an angle that exceeds 360
degrees in absolute value.
Default 0
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles X, Y, GROUP, and COLORRESPONSE.
SIZEMAX=dimension
specifies the maximum font size for a text marker when a response variable is
used to size the text-marker font. By default, the font size of the text values
that are associated with the maximum response column value is set to the value
specified by this option.
984 Chapter 6 / Plot Statements
Default Three times the size specified in the GraphDataText style element
for the maximum response column value marker.
Use the SIZEMIN= option to specify the minimum font size for text
markers.
SIZEMAXRESPONSE=numeric | scalar-numeric-expression
specifies the response value that corresponds to the maximum font size for text
markers.
Note The font size for all text values that exceed the maximum response
value is set to the value specified in the SIZEMAX= option.
SIZEMIN=dimension
specifies the minimum font size for text markers when a response variable is
used to size the font for text values.
Default The size specified in the GraphDataText style element for the
minimum response column value marker.
Tip Use the SIZEMAX= option to specify the maximum text size.
SIZERESPONSE=numeric-column | numeric-expression
specifies a response column that is used to determine the font size for each text
value.
Default The size specified in the GraphDataText style element for all text
values.
Notes When the column value for an observation is 0, the font size for the
text value for that observation is set to the SIZEMIN= option value.
TEXTPLOT Statement 985
When all the column values are 0 or missing, this option is ignored. In
that case, the default font size is used for all of the text values.
Tip Use the SIZEMIN= and SIZEMAX= options to limit the minimum and
maximum font size for the text values.
SPLITCHAR="character-list"
specifies one or more characters on which the text-marker text can be split.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the data label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
SPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the text-marker text.
986 Chapter 6 / Plot Statements
TRUE
drops a split character from the text-marker text when a split occurs at that
character.
Split characters at which a split does not occur are left in place. The
SPLITPOLICY= option determines where the text is split. When
SPLITPOLICY=SPLIT, the text for each text value is split at a split character
only where a split is needed to fit the text in the available space. At each
split point, the split character is dropped, and the characters that follow the
split character, up to but not including the split character at the next split
point, are wrapped to the following line.
FALSE
includes the split characters in the data label display.
Default TRUE. A split character is dropped from the text-marker text when
a split occurs at that character.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the text based on the POSITION= option.
CENTER
LEFT
RIGHT
justifies the text center, left, or right, as specified.
Default AUTO
NONE
does not split the text for text values that collide.
SPLIT
splits the text-marker text at a split character only if a split is needed at that
character in order to make the text fit the available space.
No split occurs at split characters that occur where a split is not needed. If
the text does not contain any of the specified split characters, then a split
does not occur. In that case, if the text does not fit the available space, then
it might collide with the adjoining text values.
See the SPLITCHAR= option for information about specifying the split
characters
SPLITALWAYS
splits the text-marker text at every occurrence of a split character.
If the text does not contain any of the specified split characters, then a split
does not occur.
See the SPLITCHAR= option for information about specifying the split
characters
Default NONE
SPLITWIDTH=AUTO | width-in-characters
specifies the maximum width of each split line.
AUTO
uses the width of the longest inter-split-character substring.
width-in-characters
specifies a fixed width, expressed as a character count.
Note When you specify a fixed width, the text-marker text is split
unconditionally every n characters, where n is the value of width-in-
characters.
STRIP=TRUE | FALSE
specifies whether leading and trailing blanks should be stripped from the text-
marker text before it is displayed.
988 Chapter 6 / Plot Statements
Default FALSE
Tip Stripping the blanks from the numeric value strings helps center each
string relative to its data point.
See “boolean ” on page xii for other Boolean values that you can use.
Interactions When this option’s COLOR= suboption is used with the GROUP=
option, the COLOR= suboption specifies the color for all of the text
values.
Note If one or more text options are specified and they do not include all
the font properties (color, family, size, weight, and style), the
properties that are not specified are derived from the
GraphDataText style element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
for using a style-element.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over the text
values. If you use this option, it replaces all of the information that is displayed
by default. Roles for columns that do not contribute to the scatter plot can be
specified along with roles that do.
(role-list)
specifies an ordered, space-separated list of unique TEXTPLOT roles and
user-defined roles. TEXTPLOT roles include X, Y, GROUP, and
COLORRESPONSE.
Example The following example displays data tips for the columns assigned
to the roles X and Y, as well as the column Obs, which is not
assigned to any pre-defined TEXTPLOT role. The Obs column must
first be assigned a role.
ROLENAME=(TIP1=OBS)
TIP=(TIP1 X Y)
TEXTPLOT Statement 989
NONE
suppresses data tips and URLs (if requested) from the plot.
Restriction Data tips in text plots are not supported in the SVG output format.
To generate a text plot with data tips, use a bitmapped output
format such as PNG.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement with the IMAGEMAP option specified,
and you must write the output to the ODS HTML destination.
Tip You can control the labels and formats for the TIP roles with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
990 Chapter 6 / Plot Statements
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
URL=string-column
specifies an HTML page to display when a text value is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each text value that is an active link.
Example http://www.sas.com
Tips The URL value can be blank for some X and Y pairs, meaning that
no action is taken when the corresponding point is selected.
The URL value can be the same for any X and Y pair. In that case,
the same action is taken when the points for that X and Y pair are
selected.
VCENTER=BBOX | BASELINE
specifies whether the text is vertically centered with respect to the text
bounding box or to the text baseline.
BBOX
vertically centers the text with respect to its bounding box.
BASELINE
vertically centers the text with respect to the text baseline.
If the text is split into multiple lines, the text is centered on the baseline of
the last line of text.
Default BBOX
Tip Use the POSITION= option to specify the text position with respect to
the text bounding box or to the text baseline.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
Using additional options in the TEXTPLOT statement, you can rotate the text
around its anchor point to any angle, manage the text position, split the text into
multiple lines, add a back-light effect to the text, and so on. If you currently use the
SCATTERPLOT statement and the MARKERCHARACTER= option to generate text
plots, SAS recommends that you use the TEXTPLOT statement instead.
992 Chapter 6 / Plot Statements
By default, only the marker text is displayed. Use the DISPLAY= option to specify
whether the bounding-box fill, bounding-box outline, or both are displayed.
The following table lists the options that you can use to control the color
attributes.
attributes to a fixed color. However, when you specify fixed colors, the contrast
between the fixed colors and the remaining variable colors might not be sufficient
for some group values. When both the GROUP= and COLORRESPONSE= options
are in effect, the COLORRESPONSE= option controls the color attributes.
Starting with SAS 9.4M3, when the bounding-box fill and outline are displayed, the
COLORRESPONSE= option determines the color of the text and of the bounding-
box outline. The bounding-box fill color in that case is determined by suboption
COLOR= in the FILLATRS= option. You can use suboption COLOR= in the
FILLATTRS=, OUTLINEATTRS=, and TEXTATTRS= options to override the
individual attributes, depending on which bounding-box attributes are displayed.
The following table lists the results when suboption COLOR= is specified in some
common color attribute option settings and the COLORRESPONSE= option is in
effect.
n If the fill and outline are displayed, the text and fill colors are
set to their COLOR= specification. The bounding-box outline
is assigned a color from the color ramp.
n If only the fill is displayed, the text color is set to its COLOR=
specification. Suboption COLOR= in FILLATTRS= is ignored,
and the bounding-box fill is assigned a color from the color
ramp.
TEXTATTRS=, When the bounding-box fill and outline are displayed, suboption
FILLATTRS=, and COLOR= in TEXTATTRS= is ignored, and the text is assigned a
OUTLINEATTRS= color from the color ramp. The fill and outline colors are set to
their COLOR= specification.
CAUTION
OUTFILE= and OUTID= are experimental options that are available in SAS
9.4M3. Do not use these options in production jobs.
These options are for users who want to customize the placement of the text in a
text plot. After you write the attributes to a CSV file, you can import the data into a
SAS data set, and then use the data to customize the placement of the text
markers.
The following table lists the information that is written to the CSV file.
Height Numeric The height, in pixels, of the bounding box for this
observation's text string.
OutID Character The value for this observation from the column
specified in the OUTID= option in this TEXTPLOT
statement. The ID is used as a unique identifier for
this observation's text string.
Width Numeric The width, in pixels, of the bounding box for this
observation's text string.
layout overlay;
textplot x=weight y=height text=name / name="textboxdata"
outfile=csvout outid=name;
endlayout;
endgraph;
end;
After you import the CSV file into a SAS data set, you can then use the data to
position the text values as needed.
VECTORPLOT Statement
Creates a plot of vectors (directed line segments).
Syntax
VECTORPLOT X=numeric-column | expression
Y=numeric-column | expression
XORIGIN=numeric-constant | numeric-column | expression
998 Chapter 6 / Plot Statements
Axes options
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
VECTORPLOT Statement 999
Label options
DATALABEL=column | expression
specifies the labels at the ends of the vectors.
DATALABELATTRS=style-element | style-element (text-options ) | (text-
options )
specifies the color and font attributes of the data labels.
DATALABELPOSITION=AUTO | TOPRIGHT | TOP | TOPLEFT | LEFT | CENTER |
RIGHT | BOTTOMLEFT | BOTTOM | BOTTOMRIGHT
specifies the location of the data labels relative to the end points and
arrow heads.
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at specified split characters.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if
needed.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
DATALABELSPLITJUSTIFY=AUTO | CENTER | LEFT | RIGHT
specifies the justification of the strings that are inside the data label
blocks.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Midpoint options
GROUP=column | discrete-attr-var | expression
creates a distinct set of vector lines and data label colors for each unique
group value in the specified column.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the
plot.
Vector options
1000 Chapter 6 / Plot Statements
ARROWDIRECTION=OUT | IN | BOTH
specifies the placement of the arrowhead(s) at the end of the vector.
ARROWHEADS=TRUE | FALSE
specifies whether arrowheads are displayed on the vectors.
ARROWHEADSHAPE=OPEN | CLOSED | FILLED | BARBED
specifies the shape of the arrowheads.
SCALE=number
specifies the scale factor of the vector length.
Required Arguments
X=numeric-column | expression
specifies the column for the X values of the vector endpoints.
Y=numeric-column | expression
specifies the column for the Y values of the vector endpoints.
Optional Arguments
ARROWDIRECTION=OUT | IN | BOTH
specifies the placement of the arrowhead(s) at the end of the vector.
OUT
specifies a single arrowhead, pointing away from the origin, at the end of the
vector away from the origin.
IN
specifies a single arrowhead, pointing toward the origin, at the end of the
vector near the origin.
BOTH
specifies two arrowheads.
One arrowhead points away from the origin, at the end of the vector
opposite from the origin. The other arrowhead points toward the origin, at
the end of the vector near the origin.
Default OUT
ARROWHEADS=TRUE | FALSE
specifies whether arrowheads are displayed on the vectors.
Default TRUE
VECTORPLOT Statement 1001
See “boolean ” on page xii for other Boolean values that you can use.
Default OPEN
CLIP=TRUE | FALSE
specifies whether the origin is considered when determining the data ranges for
the axes.
FALSE
includes the origin when establishing the axis scales.
TRUE
ignores the origin when establishing axis scales.
Each axis scale is determined by the other plots in the overlay. This might
result in the origin not being displayed if its data range is not within the data
ranges of tips of the vectors.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
1002 Chapter 6 / Plot Statements
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interaction For this option to take effect, the COLORRESPONSE= option must
also be specified.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
DATALABEL=column | expression
specifies the labels at the ends of the vectors.
Note The label positions are automatically adjusted to prevent the labels
from colliding with other labels and other arrows.
Interaction For this option to take effect, the DATALABEL= option must also be
specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO
uses a data-label collision avoidance algorithm to position the labels.
Note When AUTO is in effect, in some cases, the data label font size might
be reduced in order to avoid overlapping labels and markers.
TOPRIGHT
TOP
TOPLEFT
LEFT
CENTER
RIGHT
BOTTOMLEFT
BOTTOM
BOTTOMRIGHT
specifies a location for all of the data labels.
Default AUTO
DATALABELSPLIT=TRUE | FALSE
specifies whether to split the data labels at specified split characters.
See “boolean ” on page xii for other Boolean values that you can use.
DATALABELSPLITCHAR="character-list"
specifies one or more characters on which the data labels can be split if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the data label. In that case, all of the specified split characters
together are treated as a single split character.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
DATALABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the data labels.
TRUE
drops the split characters from the data label.
FALSE
includes the split characters in the data label.
The following figure shows an example of a data label with the following
specifications:
n the data label text for this label is Product*Group*A
n DATALABELSPLIT=TRUE
n DATALABELSPLITCHARDROP=TRUE | FALSE
n DATALABELSPLITCHAR="*"
Default TRUE. The split characters are dropped from the data label.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
justifies the labels based on the DATALABELPOSITION= option.
CENTER
LEFT
RIGHT
justifies the labels center, left, or right, as specified.
Note: The gray vertical line at the bottom of each label represents the
horizontal center of the text box for reference.
Default AUTO
Restriction Starting with SAS 9.4M1, the maximum number of skinned graphical
elements is limited to 200 per plot in an OVERLAY or PROTOTYPE
layout. When this limit is exceeded for a plot, the specified data skin
is not applied to that plot. In that case, use the DATASKINMAX=
option in your ODS GRAPHICS statement to increase the maximum
limit.
DATATRANSPARENCY=number
specifies the degree of the transparency of the vector line and arrowhead, and
the vector labels.
Default 0
discrete-attr-var
specifies a discrete attribute map variable.
Interactions The group values are mapped in the order of the data, unless the
INDEX= option is used to alter the default sequence of line patterns
and colors.
Note If you specify a column in a SAS data set, the visual attributes for
each group value are assigned in data order. If you specify a column
in a CAS in-memory table, the visual attributes for each group value
are assigned in ascending order of the group column character
values or of unformatted numeric values.
INCLUDEMISSINGGROUP=TRUE | FALSE
specifies whether missing values of the group variable are included in the plot.
Default TRUE
Interaction For this option to take effect, the GROUP= option must also be
specified.
Tip The attributes of the missing group value are determined by the
GraphMissing style element unless a discrete attribute map is in
effect, the INDEX= option is used, the MISSING= system option
changes the default missing character, or a user-defined format is
applied to the group value. In those cases, the attributes of the
missing group value are determined by a GraphData1–GraphDataN
style element instead of by the GraphMissing style element.
See “boolean ” on page xii for other Boolean values that you can use.
VECTORPLOT Statement 1009
INDEX=positive-integer-column | expression
specifies indices for mapping line attributes (color and line pattern) to one of
the GraphData1–GraphDataN style elements.
All of the indexes for a specific group value must be the same.
Otherwise, the results are unpredictable.
Interaction For this option to take effect, the GROUP= option must also be
specified.
Notes The index values are 1-based indices. For the style attributes in
GraphData1–GraphDataN, if the index value is greater than N,
then a modulo operation remaps that index value to a number
less than N to determine which style to use.
If you do not use this option, then the group values are mapped in
the order of the data.
Tip You can use indexing to collapse the number of groups that are
represented in a graph. For more information, see “Remapping
Groups for Grouped Data” on page 211.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
Note The arrow head size is nonlinearly proportional to the line thickness
in order to maintain appropriately sized arrow heads for thicker
lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element
LINETHICKNESSMAX=dimension
specifies the maximum line thickness when a response variable is used to
determine the line thickness. By default, this option determines the thickness of
the line that represents the maximum response column value.
LINETHICKNESSMAXRESPONSE=numeric | scalar-numeric-expression
specifies the response value that corresponds to the maximum line thickness.
Default The maximum value in the response column that is specified in the
LINETHICKNESSRESPONSE= option.
The thickness for all lines that exceed the maximum response value
is set to the value specified in the LINETHICKNESSMAX= option.
VECTORPLOT Statement 1011
LINETHICKNESSMIN=dimension
specifies the minimum line thickness when a response variable is used to
determine the line thickness.
LINETHICKNESSRESPONSE=numeric-column | expression
specifies a response column or range attribute variable that is used to map a
line thickness to each group value.
Interactions When the column values are all zero, all negative, or all missing,
this option is ignored. In these cases, the default line thickness is
used for all of the lines.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
1012 Chapter 6 / Plot Statements
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
PRIMARY=TRUE | FALSE
specifies that the data columns for this plot and the plot type be used for
determining default axis features. This option is needed only when two or more
plots within an overlay-type layout contribute to a common axis.
Default FALSE
See “When Plots Share Data and a Common Axis” on page 1046
“boolean ” on page xii for other Boolean values that you can use.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles X, Y, DATALABEL, XORIGIN, YORIGIN,
GROUP, and INDEX.
SCALE=number
specifies the scale factor of the vector length.
Default 1.0
TIP=(role-list ) | NONE
specifies the information to display when the cursor is positioned over a vector
line. If this option is used, then the information specified replaces all of the
VECTORPLOT Statement 1013
information that is displayed by default. You can specify roles for columns that
do not contribute to the vector plot along with roles that do.
(role-list)
an ordered, space-separated list of unique VECTORPLOT roles and user-
defined roles.
Example The following example displays data tips for the columns assigned
to the roles X, Y, GROUP, and the column Obs, which is not
assigned to any pre-defined VECTORPLOT role. The Obs column
must first be assigned a role.
ROLENAME=(TIP1=OBS)
TIP=(TIP1 X Y GROUP)
NONE
suppresses data tips from the plot.
Requirement To generate data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip You can control the labels and formats for the TIP roles with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example ROLENAME=(TIP1=SALARY)
TIP=(TIP1)
TIPFORMAT=(TIP1=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
1014 Chapter 6 / Plot Statements
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example ROLENAME=(TIP1=PCT)
TIP=(TIP1)
TIPLABEL=(TIP1="Percent")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
Requirement A column must be assigned to each of the specified roles. (See the
ROLENAME= option.)
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
By default in a VECTORPLOT, each vector starts at 0, 0 in the data space and is
terminated with an open arrowhead. Zero-length vectors are represented by a dot
at the starting point. To specify alternative coordinates for the starting point, use
the XORIGIN= and YORIGIN= arguments.
VECTORPLOT Statement 1015
Example Program
data CarPref;
input Make $11. Model $13. (S1-S25) (1.);
datalines;
Cadillac Deville 8007990491240508971093809
Chevrolet Aveo 0051200423451043003515698
Chevrolet Cavalier 4053305814161643544747795
Chevrolet Malibu 6027400723121345545668658
Dodge Intrepid 7006000434101107333458708
Dodge Stratus 3005005635461302444675655
Dodge Neon 4005003614021602754476555
Ford Taurus 2024006715021443530648655
Ford Mustang 5007197705021101850657555
Ford Focus 0021000303030201500514078
Honda Accord 5956897609699952998975078
Honda Civic 4836709507488852567765075
Lincoln LS 7008990592230409962091909
Pontiac Firebird 0107895613201206958265907
Volkswagen Jetta 4858696508877795377895000
Volkswagen Beetle 4858509709695795487885000
Volvo S40 9989998909999987989919000
;
run;
* Compute Two Component Model;
1016 Chapter 6 / Plot Statements
ods graphics;
ods exclude all;
ods output mdprefplot=plotdata;
proc prinqual data=CarPref n=2 replace mdpref method=mgv;
id model;
transform monotone(S1-S25);
run;
ods select all;
proc template;
define statgraph vectorplot;
begingraph;
entrytitle "Multidimensional Preference Analysis";
entrytitle "of Preference Ratings for Automobiles";
layout overlayequated / equatetype=fit cycleattrs=true;
referenceline y=0 / datatransparency=0.7;
referenceline x=0 / datatransparency=0.7;
vectorplot y=vec2 x=vec1 xorigin=0 yorigin=0 /
datalabel=label2var;
scatterplot y=prin2 x=prin1 /
datalabel=idlab1 primary=true
markerattrs=(symbol=circlefilled);
endlayout;
endgraph;
end;
run;
WATERFALLCHART Statement
Creates a waterfall chart that is computed from input data.
Restriction: The WATERFALLCHART statement does not support CAS in-memory tables. In
SAS 9.4M6 and earlier releases, unexpected results might occur when data stored
in a CAS in-memory table is used. Starting with SAS Viya 3.5 and SAS Studio 5.2,
the waterfall chart is dropped when data stored in a CAS in-memory table is used.
Interaction: A Waterfall chart accumulates response values in data order. Any change in the
order of the X-axis values from the data order can adversely affect the waterfall
chart. The X-axis value order can change when the Waterfall chart is overlaid with
other plots or when it is used in a Lattice with uniform axes. It can also change
when certain options are applied to the X axis.
Tip: Starting with SAS 9.4M3, you can use subpixel rendering with this statement. It is
enabled by default. To disable subpixel rendering, specify SUBPIXEL=OFF in the
BEGINGRAPH statement or in an ODS GRAPHICS statement. For information
about the BEGINGRAPH statement SUBPIXEL= option, see SUBPIXEL= on page 39.
For information about the ODS GRAPHICS statement SUBPIXEL= option, see “ODS
GRAPHICS Statement” on page 1561.
WATERFALLCHART Statement 1017
Syntax
WATERFALLCHART CATEGORY=column | expression
RESPONSE=numeric-column | expression </options>;
Axes options
BASELINEINTERCEPT=number
specifies the response axis intercept for the baseline.
FINALBARTICKVALUE="string"
1018 Chapter 6 / Plot Statements
specifies a tick value to use on the category axis when the “final” bar is
displayed
INITIALBARTICKVALUE="string"
specifies a tick value to use on the category axis when the “initial” bar is
displayed.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to
the secondary X2 (top) axis.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Label options
BARLABEL=TRUE | FALSE
specifies whether the bar statistic value is displayed at the end of the
bar.
BARLABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the text properties of the bar label text.
BARLABELFITPOLICY=AUTO | NONE
specifies a policy for avoiding collisions among the bar labels when labels
are displayed.
BARLABELFORMAT=format
specifies the text format used to display the bar label.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
ODS options
URL=string-column
specifies an HTML page to display when a bar is selected.
Statistics options
COLORSTAT=SUM | MEAN
WATERFALLCHART Statement 1019
Required Arguments
CATEGORY=column | expression
specifies the column or expression for the category values. Duplicated category
values are summarized into a unique value. All values are treated as discrete.
RESPONSE=numeric-column | expression
specifies the numeric column or expression for the response values.
Optional Arguments
BARLABEL=TRUE | FALSE
specifies whether the bar statistic value is displayed at the end of the bar.
Default FALSE
Note By default, the bar-label format is derived from the format that is
assigned to the response column or from BEST6 if no format is
assigned. The derived format retains the precision of the response-
column format and, if necessary, increases the format width to
accommodate the summarized value on the response axis.
Tip The font and color attributes for the label are specified by the
BARLABELATTRS= option. The text format is specified by the
BARLABELFORMAT= option.
See “boolean ” on page xii for other Boolean values that you can use.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
BARLABELFITPOLICY=AUTO | NONE
specifies a policy for avoiding collisions among the bar labels when labels are
displayed.
AUTO
rotates the bar labels if the labels exceed the midpoint spacing.
If the labels collide horizontally due to thin bars, then AUTO drops all of the
labels. The following figure shows an example.
See the BARWIDTH= option for more information about the bar spacing.
NONE
does not rotate the bar labels.
Default AUTO
BARLABELFORMAT=format
specifies the text format used to display the bar label.
Default The bar-label format is derived from the format that is applied to
the response column or from BEST6 if no format is assigned. The
derived format retains the precision of the response-column
format and, if necessary, increases the format width to
accommodate the summarized value on the response axis.
Note When a bar-label format is specified with this option, the bar
labels are formatted as specified by format. The specified format is
not automatically expanded to accommodate values that are too
wide.
BARWIDTH=number
specifies the width of a bar as a ratio of the maximum possible width.
Default 0.85
Range 0–1, where 0 is the minimum width, which is one pixel wide, and 1 is the
maximum possible width
BASELINEATTRS=style-element | (line-options)
specifies the appearance of the baseline.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
BASELINEINTERCEPT=number
specifies the response axis intercept for the baseline. The baseline is always
displayed in the chart, whether for a specified value or for the default value.
When the BASELINEINTERCEPT= option is used, the axis range is adjusted to
include the baseline, and the baseline is placed at the specified value on the
response axis.
1022 Chapter 6 / Plot Statements
Default 0
Interactions The value set by this option affects only the chart’s initial and final
bars. If no initial bar value is specified, then the first transaction bar
is drawn from 0, no matter what is set for the baseline value.
discrete-attr-var
specifies a discrete attribute map variable.
Notes All of the COLORGROUP values for a specific category value must
be the same. Otherwise, the results are unpredictable.
All the transaction bars have only one fill and one outline color,
determined by the ODS style or set by the FILLATTRS= and
OUTLINEATTRS= options.
Tip To manage the color of the “initial” bar, use the INITIALBARATTRS=
option. To manage the color of the “final” bar, use the
FINALBARATTRS= option.
COLORMODEL=color-ramp-style-element | (color-list)
specifies a color ramp to use with the COLORRESPONSE= option.
color-ramp-style-element
specifies the name of a color-ramp style element.
STARTCOLOR
specifies the color for the smallest data value of the COLORRESPONSE=
column.
NEUTRALCOLOR
specifies the color for the midpoint of the range of the
COLORRESPONSE= column.
1024 Chapter 6 / Plot Statements
ENDCOLOR
specifies the color for the highest data value of the COLORRESPONSE=
column.
(color-list)
specifies a space-separated list of colors to use in the color ramp. You can
use style attribute references such as GraphData3:Color, color names, or
RGB, CMYK, HLS, and HSV (HSB) color codes to specify a color. The list can
contain a mix of style attribute references, color names, and color codes.
Interactions For this option to take effect, the COLORRESPONSE= option must
also be specified.
Tip To manage the color of the initial bar, use the INITIALBARATTRS=
option. To manage the color of the final bar, use the
FINALBARATTRS= option.
range-attr-var
specifies a range attribute map variable that is defined in a RANGEATTRVAR
statement.
“RANGEATTRVAR Statement”
Restriction This option affects only the fill colors. When only the bar outlines
are displayed, this option has no effect.
Interactions When the COLORGROUP= option is specified with this option, the
COLORGROUP= option is ignored.
COLORSTAT=SUM | MEAN
specifies the statistic to use for computing the response colors.
Default SUM
Tip This option might affect existing SAS programs. For programs
written before SAS 9.4M3, if STAT= and COLORRESPONSE= are
specified in a WATERFALLCHART statement, the chart colors and
color statistic might change from the previous SAS releases. To
restore the original colors and color statistic in that case, set
COLORSTAT= in the WATERFALLCHART statement to the same
statistic that is specified in STAT=.
CONNECT=START | END
determines whether trend lines connect to the adjacent bar’s starting or ending
value.
START
draws the trend lines horizontally and connects each to the adjacent bar’s
starting value.
Each connecting line extends from the right corner of one bar’s ending value
to the left corner of the adjacent bar’s starting value.
END
draws the trend lines diagonally and connects each to the adjacent bar’s
ending value.
Each connecting line extends from the right corner of one bar’s ending value
to the left corner of the adjacent bar’s ending value.
Default START
1026 Chapter 6 / Plot Statements
Restriction The last connect line is always drawn horizontally, extending from
the right corner of the last data bar’s ending value to the left corner
of the “final” bar’s starting value.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
CONNECTBREAK=TRUE | FALSE
specifies whether the connect line is broken for values that have no
observations.
Default FALSE
Requirement DISPLAY= must include CONNECT for this option to have any
effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
Requirement For this option to have any effect, the fill must be enabled by the
ODS style or the DISPLAY= option.
When a data skin is applied, all bar outlines are set by the skin, and
the OUTLINEATTRS= option is ignored.
DATATRANSPARENCY=number
specifies the degree of the transparency of the bar fill, bar outline, bar labels,
and trend lines, if displayed.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
filled bar area. The INITIALBARATTRS= and FINALBARATTRS=
options can be used to specify transparency for the initial and final
bars. You can combine this option with FILLATTRS=,
INITIALBARATTRS=, and FINALBARATTRS= to set one transparency
for the bar outlines and trend lines but a different transparency for the
bar fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
1028 Chapter 6 / Plot Statements
(display-options)
a space-separated list of one or more display options enclosed in
parentheses.
CONNECT
displays line segments (trend lines) connecting adjacent bar. The
connection point is determined by the CONNECT= option.
FILL
displays filled bars.
FINALBAR
displays the final bar.
OUTLINE
displays outlined bars.
STANDARD
specifies CONNECT, FILL, FINALBAR, and OUTLINE
ALL
currently the same as STANDARD
Default STANDARD
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FILLTYPE=SOLID | GRADIENT
specifies the bar fill type.
SOLID
fills each bar with the color that is assigned to that bar.
GRADIENT
fills each bar with a color gradient that starts with the neutral color from the
color model or with the middle color from the color model color list, if
specified, and ends with the color for that bar that is determined by the
COLORGROUP= or COLORRESPONSE= option.
Default SOLID
Interaction The DISPLAY= option must include FILL for this option to have any
effect.
Tip The colors that are used depend on whether the COLORGROUP=
option or the COLORRESPONSE= option is also specified.
Interaction This option is ignored if the DISPLAY= option does not display the
“final” bar.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
FINALBARTICKVALUE="string"
specifies a tick value to use on the category axis when the “final” bar is
displayed
Default "Final"
Interaction This option is ignored if the DISPLAY= option does not display the
“final” bar.
1030 Chapter 6 / Plot Statements
Interaction For this option to take effect, the INITIALBARVALUE= option must
also be specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
INITIALBARTICKVALUE="string"
specifies a tick value to use on the category axis when the “initial” bar is
displayed.
Default "Initial"
Interaction For this option to take effect, the INITIALBARVALUE= option must
also be specified.
INITIALBARVALUE=number
specifies a value for the initial bar. The initial bar’s value is used as the starting
response value for the first transaction bar.
Interactions If this option is not specified, then the initial bar is not included in
the chart and the first transaction bar is drawn from response value
0. This is true even if an intercept value is set by the
BASELINEINTERCEPT= option.
LEGENDLABEL="string"
specifies a label to be used in a discrete legend for this plot.
NAME="string"
assigns a name to this plot statement for reference in other template
statements. The specified name is used primarily in legend statements to
coordinate the use of colors and line patterns between the plot and the legend.
Restrictions The string is case sensitive, cannot contain spaces, and must define
a unique name within the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interaction The string is used as the default legend label if the LEGENDLABEL=
option is not used.
Interactions For this option to have any effect, outlines must be enabled by the
ODS style or the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the data
tips. This option provides a way to add to the data columns that appear in data
tips that are specified by the TIP= option.
(role-name-list)
a space-separated list of role-name = column pairs.
1032 Chapter 6 / Plot Statements
Example The following example assigns the column Obs to the user-defined
role TIP:
ROLENAME=(TIP1=OBS)
Requirement The role names that you choose must be unique and different from
the predefined roles CATEGORY, RESPONSE, COLORGROUP, and
COLORRESPONSE.
STAT=SUM | MEAN
specifies the statistic to be computed for the RESPONSE axis.
Default SUM
Tip If you use this option with COLORRESPONSE= in SAS programs that
were written before SAS 9.4M3, the chart colors and color statistic
might change from the previous SAS releases. To restore the original
colors and color statistic in that case, set COLORSTAT= in the
WATERFALLCHART statement to the same statistic that is specified in
STAT=.
TIP=(role-list) | NONE
specifies the information to display when the cursor is positioned over a bar. If
this option is used, then it replaces all of the information that is displayed by
default. Roles for columns that do not contribute to the waterfall chart can be
specified along with roles that do.
(role-list)
an ordered, space-separated list of unique WATERFALLCHART and user-
defined roles.
Example The following example displays data tips only for the column that
is assigned to the RESPONSE role:
TIP=(RESPONSE)
NONE
suppresses data tips and URLs (if requested) from the plot.
Requirement To enable data tips in the output, you must include an ODS
GRAPHICS ON statement that specifies the IMAGEMAP option,
and you must write the output to the ODS HTML destination.
Tip The labels and formats for the TIP roles can be controlled with the
TIPLABEL= and TIPFORMAT= options.
TIPFORMAT=(role-format-list)
specifies display formats for tip columns. This option provides a way to control
the formats of columns that appear in data tips.
(role-format-list)
a space-separated list of role-name = format pairs.
Example TIP=(RESPONSE)
TIPFORMAT=(RESPONSE=DOLLAR12.)
Default The column format of the column assigned to the role or BEST6 if
no format is assigned to a numeric column.
Restriction Only the roles that appear in the TIP= option are used.
TIPLABEL=(role-label-list)
specifies display labels for tip columns. This option provides a way to control
the labels of columns that appear in data tips.
role-label-list
a space-separated list of rolename ="string" pairs.
Example TIP=(RESPONSE)
TIPLABEL=(RESPONSE="Average Sales")
Default The column label or column name of the column assigned to the
role.
Restriction Only the roles that appear in the TIP= option are used.
URL=string-column
specifies an HTML page to display when a bar is selected.
string-column
specifies a column that contains a valid HTML page reference (HREF) for
each bar that is to have an active link.
Example http://www.sas.com
For grouped data, the values of the column are expected to be the
same for each unique RESPONSE and group combination.
Tips The URL value can be blank for some RESPONSE values, meaning
that no action is taken when the bars for those RESPONSE values
are selected.
The URL value can be the same for different RESPONSE values,
meaning that the same action is taken when the bars for those
RESPONSE values are selected.
XAXIS=X | X2
specifies whether data are mapped to the primary X (bottom) axis or to the
secondary X2 (top) axis.
Default X
Interaction The overall plot specification and the layout type determine the axis
display. For more information, see “How Axis Features Are
Determined” on page 1040.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the
secondary Y2 (right) axis.
Default Y
The overall plot specification and the layout type determine the
axis display. For more information, see “How Axis Features Are
Determined” on page 1040.
Details
The input data for the WATERFALLCHART statement is raw, unsummarized input
data, and the statement calculates appropriate summarization statistics (sum or
mean). By default, the bars in the chart appear in the order in which the CATEGORY
WATERFALLCHART Statement 1035
values are present in the input data. A waterfall chart is typically used to show
credit and debit transactions or successive changes to a given state.
In a waterfall chart, the bars that are calculated from the data are called
“transaction” bars. The transaction bars represent the values of the RESPONSE
variable across a series of intermediate values for the specified CATEGORY
variable. You can manage the color of the transaction bars using the
COLORGROUP , COLORMODEL , or COLORRESPONSE= option.
A waterfall chart can also display an “initial” bar and a “final” bar. The value of the
initial bar determines the starting response value for the first transaction bar. To
set the initial value, use the INITIALBARVALUE= option. If the initial bar is not
displayed, then the first transaction bar has a starting response value of 0. The
value of the final bar is set automatically to the ending value of the last transaction
bar.
Example Program
data transactions;
input ID $ Amount type $;
datalines;
Alpha 2000 credit
Beta -2500 debit
1036 Chapter 6 / Plot Statements
PART 5
Plot Axes
Chapter 7
Axis Features in Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1039
Chapter 8
Axis Options in Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1055
1038
1039
7
Axis Features in Layouts
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1039
How Axis Features Are Determined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1040
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1040
Plot Data Are Mapped to a Designated Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1040
When Plots Share Data and a Common Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1046
Plot Axis Types Must Agree on Common Axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1049
Controlling Axis Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1049
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1049
Setting the Axis Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1050
Adjusting the Axis View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1051
Adjusting Axis Thresholds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1052
Adjusting Axis Offsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1053
Overview
GTL plots are specified within layout blocks that enable you to control the graph
display features, including the display of the axes for the plots within the layout.
For example, the LAYOUT OVERLAY statement has XAXISOPTS= and
YAXISOPTS= options that enable you to specify axis features for the plots within
the layout.
The following sections explain how the axis features are determined in a layout.
The sections also discuss the issues that you must consider when setting the axis
type or adjusting the appearance of the axis display.
1040 Chapter 7 / Axis Features in Layouts
Overview
GTL uses various criteria to determine the displayed axis features for a graph.
Generally, axis features are based on the following criteria:
n the layout type
n the order of plot statements in the layout and the options specified on those
statements
n the use of primary and secondary axes on the plots (when secondary axes are
supported)
n the plot type
n the column or columns of data that contribute to defining the axis range
Because the default axis features depend on a combination of the factors above, it
is useful to understand how the axis features are determined in the templates that
you build:
n how the data are mapped to the plot axes
Within single-cell layouts (for example, OVERLAY layout), there can be just one
each of these four axes. However, within multi-cell layouts (for example, LATTICE
How Axis Features Are Determined 1041
layouts), each cell can display the four axes. Thus, there can be multiple X, X2, Y,
and Y2 axes across the columns and rows in the layout grid. In a lattice-type layout,
you might have to use layout options to specify how the data ranges and axis
display should be managed. This section discusses the simpler case for axis
mapping, and “Axis Mapping in Lattice-type Layouts” on page 1042 discusses the
case for lattice-type layouts.
Note: GRIDDED layouts can be used to create a grid of cells, but the cells are
independent. Thus, axes in the grid cannot be managed across columns and rows,
so the simpler case applies to GRIDDED layouts.
To determine the axis features within a layout, GTL must first determine what data
must be mapped to a particular axis. Thus, your use of primary and secondary axes
on plot specifications affects GTL’s determination of default axis features for the
layout.
For example, the plot statements in the following template specify Y-data
mappings to the Y2 and Y axes:
proc template;
define statgraph y2axis;
begingraph;
layout overlay;
histogram weight / scale=count yaxis=y2 ;
histogram weight / scale=percent yaxis=y ;
densityplot weight / normal();
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.class template=y2axis;
run;
1042 Chapter 7 / Axis Features in Layouts
In this example, the first HISTOGRAM maps its Y-axis data to the Y2 axis, and the
second HISTOGRAM maps its Y-axis data to the Y axis. The DENSITY plot does not
explicitly map its Y-axis data, so the default Y axis is used. None of the plots
explicitly maps X-data, so the default X axis is used for all three plots. Thus, GTL
must manage any interactions that result from representing multiple plots on the X
and Y axes. For example, on the X axis, it must determine an appropriate data range
for representing the data values of all three plots.
When establishing axis features for each axis, GTL determines which plot
specifications map data to the axis. GTL also collects the data for all of the plots
that must be represented and maps that data to the designated axis. “When Plots
Share Data and a Common Axis” on page 1046 discusses the criteria GTL uses to
determine the axis features for the axes after this mapping has been done for each
axis.
For example, the following template uses a LAYOUT LATTICE to generate a grid
that displays a height analysis next to a weight analysis. By default in a LAYOUT
How Axis Features Are Determined 1043
example, comparing the height of female subjects to the height of male subjects),
then you could specify COLUMNDATARANGE=UNIONALL. This would set the
same scaling to the X-axis data ranges across the two layout columns. In this
example, you would not bother changing the default COLUMN2DATARANGE=
setting because the X2 axis is not needed.
In the example, scaling the data ranges across the row ensures proper axis scaling.
However, the graph display is cluttered by the duplicate display of ticks, axis
values, and axis labels on both the Y and Y2 axes. To simplify the display, you can
consolidate the axes. To do so, use a ROWAXES block to display a single Y axis for
both cells, and a ROW2AXES block to display a single Y2 axis for both cells. The
consolidated view removes the internal axes from the grid and displays only the
external axes:
proc template;
define statgraph y2axis;
begingraph;
layout lattice / columns=2 columngutter=10
rowdatarange=union row2datarange=union;
rowaxes;
rowaxis / griddisplay=on;
endrowaxes;
row2axes;
rowaxis;
endrow2axes;
layout overlay;
histogram height / scale=count yaxis=y2;
histogram height / scale=percent yaxis=y;
densityplot height / normal();
endlayout;
layout overlay;
histogram weight / scale=count yaxis=y2;
histogram weight / scale=percent yaxis=y;
densityplot weight / normal();
endlayout;
endlayout;
endgraph;
end;
When using ROWAXES or ROW2AXES blocks in a LATTICE layout, you nest within
the block one ROWAXIS statement for each row in the layout grid. The ROWAXIS
statements are applied sequentially to the rows, and each ROWAXIS statement
specifies the axis options for the Y or Y2 axes in its corresponding row. ROWAXIS
statements within the ROWAXES block apply to the Y axes, and ROWAXIS
statements within the ROW2AXES block apply to the Y2 axes. This example has
just a single row in the grid, so each block specifies only one ROWAXIS statement.
Notice that the ROWAXIS statement in the ROW2AXES block does not use any
options. Thus, it consolidates Y2 axes in the row into a single, external Y2 axis, but
it does not alter the default features of that axis. For columns in the grid, the
LATTICE layout provides COLUMNAXES and COLUMN2AXES blocks. These
blocks use COLUMNAXIS statements to externalize X and X2 axes and specify
their features.
When you use DATALATTICE and DATAPANEL layouts, the layout dynamically
generates a grid that contains as many cells as can be produced from the
combination of classification values. In those layouts the axes are always external,
and you can use the COLUMNAXISOPTS=, COLUMN2AXISOPTS=,
ROWAXISOPTS=, and ROW2AXISOPTS= options to specify the features for the
axes. The settings on each option apply across the entire grid. For example, if you
specify the ROWAXISOPTS= option in a DATALATTICE layout, then the specified
settings apply to the external Y axes in every row.
1046 Chapter 7 / Axis Features in Layouts
Overview
If a layout block contains multiple plots that share data and a common axis, then
the plot settings often interact in ways that affect the axis features. Axis features
include the axis type, axis label, tick-mark layout, and so on. GTL resolves these
interactions in ways that vary according to the layout block and plot statements.
Note: Axis interactions might not occur if other settings in the template prevent
them. As discussed in “Plot Data Are Mapped to a Designated Axis” on page 1040,
if two plot statements are within an OVERLAY layout, then one of them might map
its data to the X axis and the other might map its data to the X2 (top) axis. Mapping
to separate axes can avoid the interactions that might occur if they both mapped
their data to the X axis.
Within overlay-type layouts, if you do not explicitly set axis features in your
template statements, then GTL automatically determines them. It sets the axis
features based on the layouts and plots in the layout block and the data that are
associated with the template at run time.
If only one plot statement within an overlay-type layout generates an axis, then
determining axis features is straight forward: the features are derived directly from
the plot type and the columns that are used for the plot data. For example, if a
LAYOUT OVERLAY block contains a single SCATTERPLOT and the X= argument
specifies a numeric column of children’s weights, then the default X-axis type is
LINEAR. The default X-axis label is the column label of the Weight column. If the
Weight column has no defined label, then the column name is used as a label.
When an overlay-type layout contains multiple plots that generate axes, GTL can
determine default axis features for the shared axes. Alternatively, you can use the
PRIMARY= option on one of the plot statements to specify which plot you want
GTL to use. The following code fragment explicitly specifies that the
SCATTERPLOT of children’s weights be used to determine axis features within the
layout:
layout overlay;
scatterplot x=weight ... / primary=true;
...
How Axis Features Are Determined 1047
In this case, the default X-axis type is DISCRETE and the X-axis label is the label
that is assigned to column Name, or Name if no label is assigned to column Name.
Note: The SAS format on the primary plot’s column determines the axis format,
although the axis might not use that SAS format “as-is” from the column.
For some plot types, the default axis type does not directly correlate to the
specified column’s data type. For example, the following code fragment specifies a
BARCHART for the numeric column Age:
layout overlay;
barchart category=age ... / primary=true;
...
Because a BARCHART requires a discrete X axis, the default X-axis type in this
case is DISCRETE, in spite of the fact that column Age is numeric. The X-axis label
is the column label of Age, or the column name if no label exists.
Finally, consider a HISTOGRAM that is set as the primary plot in the layout and
that bins data values:
layout overlay;
histogram weight / binaxis=true primary=true;
...
In this case, the default X-axis type is LINEAR, but the histogram’s data bins are
used by default as the basis for the axis tick marks.
1048 Chapter 7 / Axis Features in Layouts
Axes are shared in the layout when one of the options COLUMNDATARANGE=,
COLUMN2DATARANGE=, ROWDATARANGE=, or ROW2DATARANGE= is used to
unite axis data ranges for layout cells. By default in those cases, the first cell that is
drawn (by default, the top left cell) determines the axis features in the display.
When UNIONALL is in effect, those same features are used in all of the grid’s
layout cells. When UNION is in effect, those same features are used on a per-row or
per-column basis. If you specify external axes for the columns or rows in the layout,
you can specify desired axis features on the appropriate COLUMNAXIS or
ROWAXIS statements used in the layout.
For an example LATTICE layout with external axes, see “Axis Mapping in Lattice-
type Layouts” on page 1042.
common axis. Thus, no competition exists among layout cells for determining the
axis features.
“When Plots Share Data and a Common Axis” on page 1046 discusses the criteria
GTL uses to determine the default axis features. After the axis type has been
determined, GTL expects that all plots that share that axis will have the assigned
axis type. The expectation applies whether you specify axis features in your
template or let GTL determine default features.
For example, a BOXPLOT cannot be overlaid by a LINEPARM: the two types of plot
cannot share axes because the plot types are incompatible within the same set of
axes. Thus, if you were to use both a BOXPLOT statement and a LINEPARM
statement within a LAYOUT OVERLAY block, then only one of them can be
displayed. GTL therefore displays the primary plot (the first specified plot by
default, or the plot designated as primary by setting PRIMARY=TRUE). The other
plot is not displayed.
Axis types must also be the same for plots that must share an axis across the
columns or rows in a multi-cell layout. For example, in a LAYOUT LATTICE, GTL
expects that plots have the same axis type and data ranges if they are to share an
external axis. Otherwise, the external axis cannot be displayed for that row or
column.
Overview
To enable you to control axis features within each of the layout types, there are
different sets of axis options for the different types of axes:
1050 Chapter 7 / Axis Features in Layouts
The options that are available for each layout are documented separately, but it is
worth discussing the following tasks in general for all of the layout types:
n Setting the Axis Type
The axis options for each layout statement include a TYPE= option that enables
you to specify an axis type that overrides the default selection mechanisms. When
you override the default axis type, you must be sure to specify the correct axis type
for the plots that you are defining. For every plot in the template language, the
documentation indicates what axis types it supports. Plots statements that are
specified in the template are ignored if they are incompatible with the axis type.
Each axis type has features specific to that type, and the following axis options
enable you to specify features for the different types:
LINEAROPTS=(linear-suboptions)
DISCRETEOPTS=(discrete-suboptions)
TIMEOPTS=(time-suboptions)
LOGOPTS=(log-suboptions)
One or more of these options can be specified for an axis, but the specified settings
are applied only to the axis type that supports them.
For example, a bar chart has two axes – a TYPE=DISCRETE axis for the X axis and a
TYPE=LINEAR axis for the Y axis. If a numeric column (for example, Age) is
assigned to the X role, then this column’s values are always treated as discrete
values, never as a continuous range of values. You cannot request another axis type
for the X axis, but you can request a different axis type for the Y axis.
Controlling Axis Features 1051
Sometimes you want a specialized axis type depending on the nature of the data.
For example, if the data have a very large range of values (orders of magnitude
apart), then you could request that the values be displayed on a logarithmic scale.
To set a logarithmic scale, use the TYPE=LOG axis option.
Time series data benefit from displaying the X axis with a TYPE=TIME axis. A TIME
axis type requires that the column values are SAS Date, Time, or Datetime values.
Note: Certain plot types or layouts might impose restrictions on what type of axis
can be assigned. The documentation for each plot and layout type identifies any
restrictions that might apply to the axes.
A VIEWMIN= value that is greater than the data minimum or a VIEWMAX= value
that is less than the data maximum acts like a “zoom in” operation. The adjusted
view reduces the range of values represented on the axis and can sometimes
exclude markers, lines, or fills that would normally appear.
A VIEWMIN= value that is less than the data minimum or a VIEWMAX= value that
is greater than the data maximum acts like a “zoom out” operation. The adjusted
view extends the range of values represented on the axis and sometimes
compresses the markers, lines, or fills into a smaller area.
The following figure shows how the view settings can affect the tick and data
displays.
1052 Chapter 7 / Axis Features in Layouts
The bias at the maximum end of the axis is calculated using the THRESHOLDMAX=
value and the maximum data value (by default) or the VIEWMAX= value (if set).
The following figure shows how the threshold settings can affect the tick display on
an axis. In the figure, 8 is the minimum value for the display and 29 is the maximum
value.
Controlling Axis Features 1053
The offset range is from 0 to 1, and the specified value is used to calculate the
offset as a percentage of the full axis length. The larger the offset area that is
reserved, the less space is available for the tick display area. The default offset
reserves just enough area to fully display markers and other graphical features near
the ends of an axis.
The following figure shows how offset values of 0.08 might compare with the
default offsets for a continuous axis.
1054 Chapter 7 / Axis Features in Layouts
This next figure shows how offset values might affect the discrete axis of a bar
chart.
1055
8
Axis Options in Layouts
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1055
Axis Options for LAYOUT OVERLAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1055
Axis Options for LAYOUT OVERLAY3D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1119
Row and Column Axis Options for LAYOUT LATTICE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1140
Axis Options for LAYOUT OVERLAYEQUATED . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1197
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL . . . . . . . . . . . . 1218
Dictionary
Interaction: The OVERLAY’s axis options are ignored when the LAYOUT OVERLAY statement is
nested within another layout type that has external axes in effect. For example, the
axis options are ignored when the OVERLAY is nested in a LAYOUT LATTICE with a
COLUMNAXIS= or ROWAXIS= option in effect.
Note: Unless otherwise indicated in an option description, each axis option is available for
the X, Y, X2, and Y2 axis.
See: “LAYOUT OVERLAY Statement” on page 159
Syntax
Axis options for the plots within an OVERLAY layout are specified with the
following
options on a LAYOUT OVERLAY statement:
1056 Chapter 8 / Axis Options in Layouts
XAXISOPTS=(axis-options)
YAXISOPTS=(axis-options)
X2AXISOPTS=(axis-options)
Y2AXISOPTS=(axis-options)
DISCRETEOPTS=(discrete-axis-options)
specifies one or more options for a discrete axis. Options must be enclosed in
parentheses. Each option is specified as a name = value pair and each pair is
space separated.
See “Options for Discrete Axes Only” on page 1072 for the options that
you can use for discrete-axis-options.
1058 Chapter 8 / Axis Options in Layouts
STANDARD
specifies that the LABEL, LINE, TICKS, and TICKVALUES are displayed
ALL
currently the same as STANDARD
NONE
specifies that no axis features are displayed
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
LABEL
displays the axis label
LINE
displays the axis line
TICKS
displays the tick marks
TICKVALUES
displays the values that are represented by the major tick marks
Default STANDARD
Tips The default line attributes for the axis line and axis tick marks are
defined in the GraphAxisLine style element.
Use the GRIDDISPLAY= and GRIDATTRS= options to set the axis grid
lines.
When LINE is excluded from the DISPLAY= option, the layout wall
outline or the default baseline of a bar chart, needle plot, or waterfall
chart can appear to be an axis line. To suppress the wall outline, use the
WALLDISPLAY= option in the layout statement. To suppress the plot
baseline, use the BASELINEATTRS= option in the plot statement.
NONE
specifies that no axis features are displayed
Axis Options for LAYOUT OVERLAY 1059
STANDARD
specifies that the LABEL, LINE, TICKS, and TICKVALUES are displayed on
the secondary axis
ALL
currently the same as STANDARD
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
LABEL
displays the axis label
LINE
displays the axis line
TICKS
displays the tick marks
TICKVALUES
displays the values that are represented by the major tick marks
Default NONE
Restriction If some plot statements set XAXIS=X and others set XAXIS=X2,
both the X and X2 axis are primary and a secondary X axis cannot be
displayed. In that case, this option is ignored. The same applies for
the Y axes.
Tip Use the GRIDDISPLAY= and GRIDATTRS= options to set the axis
grid lines.
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tip On a log axis, this option affects the appearance of the major grid
lines only. It does not affect the appearance of the minor grid lines.
To control the appearance of the minor grid lines on a log axis, use
the MINORGRIDATTRS= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO_OFF
specifies that grid lines are not displayed unless the GraphGridLines element
in the current style contains DisplayOpts="ON."
AUTO_ON
specifies that grid lines are displayed unless the GraphGridLines element in
the current style contains DisplayOpts="OFF."
ON
specifies that grid lines are always displayed.
OFF
specifies that grid lines are never displayed.
The following table shows the end results for various combinations of the
GRIDDISPLAY= option and the DisplayOpts= attribute of the GraphGridLines
style element. Most supplied templates use the default setting AUTO_OFF to
indicate a preference for not displaying grid lines, but allowing the style to
override.
DisplayOpts= style
GRIDDISPLAY= option attribute Grid Lines Shown?
AUTO_OFF AUTO no
AUTO_OFF ON yes
AUTO_OFF OFF no
AUTO_ON ON yes
AUTO_ON OFF no
Default AUTO_OFF
Note Supplied styles use DisplayOpts="AUTO," which means that the style
has no preference about grid lines and the graphics template setting for
grid lines is always used.
Axis Options for LAYOUT OVERLAY 1061
Default The default label is derived from the primary plot in the layout. For
more information, see “When Plots Share Data and a Common Axis”
on page 1046.
Note If the axis label is too long to fit along the axis, then it is truncated
by default.
See “Overriding the Default Axis Label” in SAS Graph Template Language:
User’s Guide
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO
uses the short label, when specified, instead of the original label.
If the short label does not fit, then it is clipped. When no short label is
specified, the original label is clipped.
SPLIT
splits the axis label at a split character only when necessary in order to make
the label fit the available space.
not fit the available space even after splitting might overlap the adjoining
space.
SPLITALWAYS
always split the axis label at every occurrence of a split character, which is
specified by the LABELSPLITCHAR= option.
STACKED
displays the Y or Y2 axis label vertically as stacked letters.
Default AUTO
CENTER
centers the axis label in the axis area.
For the Y and Y2 axes, the label is oriented vertically and is centered in the
axis area (including the offsets). The label is positioned to the left of the tick
values for the Y axis or to the right of the axis values for the Y2 axis. For the
X and X2 axes, the label is centered in the axis area (including the offsets). It
is positioned below the tick values for the X axis or above the axis values for
the X2 axis.
DATACENTER
centers the axis label in the axis tick display area.
For the Y and Y2 axes, the label is oriented vertically and is centered in the
axis tick display area (excluding the offsets). It is positioned to the left of the
tick values for the Y axis or to the right of the axis values for the Y2 axis. For
the X and X2 axes, the label is centered in the axis tick display area
(excluding the offsets). The label is positioned below the tick values for the
X axis or above the axis values for the X2 axis.
TOP
BOTTOM
orients the label horizontally at the top or bottom of the axis area.
Axis Options for LAYOUT OVERLAY 1063
The label is right-justified in the axis area for the Y axis and left-justified for
the Y2 axis. If there is not sufficient room in the axis area to display the
label, then the label grows to the right for the Y axis and to the left for the
Y2 axis.
Restriction These options are valid for the Y and Y2 axes only.
Note When TOP or BOTTOM is used, the label might collide with other
graphical features. In that case, use CENTER or DATACENTER
instead.
LEFT
RIGHT
positions the label to the left or right of the axis area.
Restriction These options are valid for the X and X2 axes only.
Note When LEFT or RIGHT is used, the label might collide with other
graphical features.
The following figure shows the CENTER and DATACENTER positions for a blue
Y-axis label Type and a red X-axis label MPG.
In this example, an axis offset is applied to the maximum end of both axes in
order to demonstrate the difference between CENTER and DATACENTER.
CENTER centers the labels on the entire axis area, including the offset.
DATACENTER centers the labels on the tick display areas, which does not
include the offset.
The next figure shows the TOP and LEFT positions, and the BOTTOM and
RIGHT positions for the same axis labels.
1064 Chapter 8 / Axis Options in Layouts
The following figure shows the CENTER and DATACENTER positions for a blue
Y-axis label Qtr and a red X-axis label Close.
The next figure shows the TOP and LEFT positions, and the BOTTOM and
RIGHT positions for the same axis labels.
Default CENTER
Restriction This option does not support collision avoidance. In some cases, axis
label collisions can occur in the axis area.
See SHORTLABEL= on page 1068 for information about how short labels
are used.
LABELSPLITCHAR="character-list"
specifies one or more characters on which the axis labels can be split, if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the axis label. In that case, all of the specified split characters
together are treated as a single split character.
When LABELFITPOLICY=SPLIT, if the axis label does not fit the available
space, then it is split on a specified split character only if a split is needed at
that point to make the label fit. In this case, a split might not occur on every
split character. When LABELFITPOLICY=SPLITALWAYS, the axis label is split
unconditionally on every occurrence of a split character. If the axis label does
not contain any of the specified split characters, the label is not split.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
LABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the displayed axis labels.
TRUE
drops the split characters from the axis label display.
FALSE
includes the split characters in the axis label display.
Default TRUE. The split characters are dropped from the axis label.
See “boolean ” on page xii for other Boolean values that you can use.
LABELSPLITJUSTIFY=justification
specifies the justification of the strings that are inside the axis label blocks.
justification
CENTER
LEFT
RIGHT
specifies the justification for the X or X2 axis label.
CENTER
TOP
BOTTOM
specifies the justification for the Y or Y2 axis label.
Default CENTER
LINEAROPTS=(linear-axis-options)
specifies one or more options for a numeric interval axis. Options must be
enclosed in parentheses. Each option is specified as a name = value pair and
each pair is space separated.
See “Options for Linear Axes Only” on page 1082 for the options that you
can use for linear-axis-options.
FULL
specifies an axis line that extends along the entire length of the axis.
DATA
specifies an axis line that extends through the data range from the minimum
offset to the maximum offset.
number
specifies how much the axis line extends from DATA toward FULL as a
decimal proportion. A value of 0 is equivalent to DATA, and a value of 1 is
equivalent to FULL.
Range 0–1
Tip A numeric value is useful for bar charts when DATA terminates the
axis line at the midpoint positions of the minimum and maximum
bars. In that case, you can specify a numeric value to lengthen the
axis line so that it extends to the full width of both bars.
The following figure shows a simple example of each value for the X axis and Y-
axis lines. The light-blue dashed lines depict the minimum and maximum offsets
that are set on the axes.
Default FULL
Tip The graph wall outline might appear to be an axis line. In that case,
use the WALLDISPLAY=NONE or WALLDISPLAY=(FILL) option in
the layout statement to suppress the wall outline.
LOGOPTS=(log-axis-options)
specifies one or more options for a log axis. Options must be enclosed in
parentheses. Each option is specified as a name = value pair and each pair is
space separated.
See “Options for Log Axes Only” on page 1097 for the options that you
can use for log-axis-options.
NAME="string"
assigns a name to an axis for reference in other statements. Currently, it is used
only in an AXISLEGEND statement.
Restriction This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interactions This option is ignored unless the axis is discrete. The axis can be
discrete by default, or explicitly set to discrete with a TYPE=
DISCRETE setting.
AUTO
reserves just enough area to fully display markers and other graphical
features near the maximum end of an axis.
AUTOCOMPRESS
applies an automatic offset that prevents axis labels and tick values from
extending beyond the axis length.
number
specifies the offset as a decimal proportion of the full axis length.
Default AUTO
Range 0–1. The sum of OFFSETMAX= and OFFSETMIN= should not be more
than 1.
AUTO
reserves just enough area to fully display markers and other graphical
features near the maximum end of an axis.
AUTOCOMPRESS
applies an automatic offset that prevents axis labels and tick values from
extending beyond the axis length.
number
specifies the offset as a decimal proportion of the full axis length.
Default AUTO
Range 0–1. The sum of OFFSETMAX= and OFFSETMIN= should not be more
than 1.
REVERSE=TRUE | FALSE
specifies whether tick values should appear in the reverse order.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
SHORTLABEL="string"
specifies an alternate axis label to display when the default label or the label
specified by the LABEL= option is too long to fit the available space. When
LABELPOSITION=CENTER (default), the available space for an axis label is the
full axis, including the axis offsets. When LABELPOSITION=DATACENTER, the
available space for an axis label is the axis tick display area, which excludes the
axis offsets. If the label length exceeds the available space, then the label is
anchored at the left or bottom offset. It extends beyond the opposing offset
until it reaches the end of the axis where it is truncated. An ellipsis designates
the truncation.
Note If the specified label is itself too long for the axis, it is truncated in
the display.
OUTSIDE
displays tick marks outside of the axis frame.
INSIDE
displays tick marks inside the axis frame.
ACROSS
displays tick marks across the axis line.
Restriction This option applies to the major tick marks only. It does not affect
the minor tick marks.
Note This option has no effect on the placement of the tick values, which
are always outside the axis frame.
Tip You can use the Annotate facility to draw inside or across minor tick
marks in your graphs. See “Creating a Macro That Generates
Annotation Data” in SAS Graph Template Language: User’s Guide.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TIMEOPTS=(time-axis-options)
specifies one or more options for a time axis.
Requirements Columns associated with a time axis must be in SAS time, SAS
date, or SAS datetime units and have an associated SAS time,
date, or datetime format.
See “Options for Time Axes Only” on page 1107 for the options that
you can use for time-axis-options.
AUTO
requests that the axis type be automatically determined, based on the
overlay contents.
For more information, see “When Plots Share Data and a Common Axis” on
page 1046.
DISCRETE
uses a DISCRETE axis if possible.
The data for discrete axes can be character or numeric. You can add a
DISCRETEOPTS= option list to customize this axis type.
LINEAR
uses a LINEAR axis if possible.
You can add a LINEAROPTS= option list to customize this axis type.
TIME
uses a TIME axis if possible.
Data for this axis must be SAS time, SAS date, or SAS datetime values. You
can add a TIMEOPTS= option list to customize this axis type.
LOG
uses a LOG axis if possible.
You can add a LOGOPTS= option list to customize this axis type.
Interaction If a log axis is requested and the axis data contains 0 or negative
values, the axis reverts to a linear axis. This outcome can occur
for the response axis of a bar chart, line chart, needle plot, or
waterfall chart when a baseline intercept of 0 or less is specified.
It can also occur for the response axis of a waterfall chart when
an initial bar value of 0 or less is specified. To get a log response
axis in those cases, set the baseline intercept or initial bar value
to a positive value.
Default AUTO
Interactions If this option is set to anything other than AUTO, then plots within
the layout are dropped from the display if their data types or data
ranges do not match the axis type requirements. For more
information, see “Plot Axis Types Must Agree on Common Axes” on
page 1049.
After the axis type is determined (whether you set a specific type
or AUTO is in effect), you can use only options that are supported
by that axis type. For example, if TYPE=TIME, then only the general
OVERLAY axis options and those available on TIMEOPTS= are
supported.
1072 Chapter 8 / Axis Options in Layouts
Default NONE
Axis Options for LAYOUT OVERLAY 1073
Interaction Specifying this option for more than one axis in the layout might
have unexpected results. The order in which color bands are drawn
might not match the order in which the axis options are specified.
Note The full width of a color band is the distance between midpoints.
When no axis offsets are specified, the first band begins at one-half
of the midpoint distance, and the last band ends at one-half of the
midpoint distance. When axis offsets are specified, the first and last
color bands on the axis might extend into their adjacent offsets by
as much as half the color-band width.
Tips Borders for the color bands can be added by setting TICKTYPE=
INBETWEEN in the DISCRETEOPTS= option, and by setting
GRIDDISPLAY= ON.
Because alternating color bands are drawn on top of the plot wall,
this option can be coordinated with the LAYOUT OVERLAY
statement’s WALLCOLOR= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
SORTORDER=AUTO | DATA
specifies how the axis values are to be sorted.
AUTO
for a column in a SAS data set, enables the system to determine the best
sorting for the axis tick values.
For a column in a CAS in-memory table, sorts the tick values in ascending
order by the formatted values.
DATA
arranges the axis tick values in the order in which they appear in the data.
Note In SAS 9.4M6 and SAS 9.4M5, when data stored in a CAS in-memory
table is used and DATA is specified, unpredictable results might occur.
To generate consistent graphs in that case, specify AUTO. Starting
with SAS Viya 3.5 and SAS Studio 5.2, when data stored in a CAS in-
1074 Chapter 8 / Axis Options in Layouts
Default AUTO
TICKDISPLAYLIST=(string-list)
specifies the text that is displayed for the tick values that are defined in the
TICKVALUELIST= option. The string list is a space-separated list of string
values that are displayed on the axis in place of the values in the
TICKVALUELIST= option. The strings map one-to-one positionally with the
values that are listed in the TICKVALUELIST= option.
Tip This option should be used with the TICKVALUELIST= option. The
number of items in the list for this option should equal the
number of items in the list for the TICKVALUELIST= option.
Example The following example specifies the axis tick values 10, 20, 30,
and 40, and the tick display values A, B, C, and D:
tickvaluelist=("10" "20" "30" "40");
tickdisplaylist=("A" "B" "C" "D");
TICKTYPE=MIDPOINT | INBETWEEN
specifies the position of the axis tick marks.
MIDPOINT
places the tick marks at the midpoint value location.
INBETWEEN
places the tick marks half way between adjacent midpoint locations.
Default MIDPOINT
TICKVALUEFITPOLICY=policy
specifies a policy for avoiding tick value collision on an axis. The effectiveness
of a collision-avoidance policy depends on the number of tick values, their
length, and the length of the axis. Which policies are valid depends on the axis
on which this option is used.
EXTRACT
displays consecutive integers along the axis instead of the actual tick values
in order to represent those tick values.
Axis Options for LAYOUT OVERLAY 1075
EXTRACTALWAYS
same as EXTRACT, except that the extraction is implemented regardless of
whether collision occurs.
NONE
makes no attempt to avoid collisions between tick values.
SPLIT
splits the tick value at a split character, which is specified by the
TICKVALUESPLITCHAR= option, only when necessary in order to make the
value fit the available space.
A split does not occur at a split character if a split is not needed at that
location. If the value does not contain any of the specified split characters,
then the value is not split. Values that are not split or that do not fit the
available space even after splitting might overlap the adjoining space.
SPLITALWAYS
always splits the axis tick value at every occurrence of a split character that
is specified by the TICKVALUESPLITCHAR= option.
SPLITALWAYSTHIN
same as SPLITALWAYS, except that thinning is performed when long words
do not fit the available space.
SPLITTHIN
same as SPLIT, except that thinning is performed when long words do not fit
the available space.
THIN
eliminates alternate tick values.
EXTRACT
displays consecutive integers along the axis instead of the actual tick values
in order to represent those tick values.
1076 Chapter 8 / Axis Options in Layouts
EXTRACTALWAYS
same as EXTRACT, except that the extraction is implemented regardless of
whether collision occurs.
NONE
makes no attempt to avoid collisions between tick values.
ROTATE
rotates the tick values if a collision occurs.
ROTATEALWAYS
rotates the tick values regardless of whether a collision occurs.
ROTATEALWAYSDROP
attempts the ROTATEALWAYS policy, and then drops the tick values if
collisions still occur.
ROTATETHIN
attempts the ROTATE policy, and then the THIN policy.
SPLIT
splits the tick value at a split character, which is specified by the
TICKVALUESPLITCHAR= option, only when necessary in order to make the
value fit the available space.
A split does not occur at a split character if a split is not needed at that
location. If the value does not contain any of the specified split characters,
then the value is not split. Values that are not split or that do not fit the
available space even after splitting might overlap the adjoining space.
SPLITALWAYS
always splits the axis tick value at every occurrence of a split character that
is specified by the TICKVALUESPLITCHAR= option.
SPLITROTATE
attempts the SPLIT policy, and then the ROTATE policy.
STACKEDALWAYS
always displays the tick values vertically as stacked letters.
STACKEDALWAYSTHIN
always displays the tick values vertically as stacked letters.
Thinning is performed when the tick values do not fit the available space.
STAGGER
alternates the tick values between two rows.
STAGGERROTATE
attempts the STAGGER policy, and then the ROTATE policy.
STAGGERTHIN
attempts the STAGGER policy, and then the THIN policy.
STAGGERTRUNCATE
attempts the STAGGER policy, and then the TRUNCATE policy.
THIN
eliminates alternate tick values.
TRUNCATE
shortens the tick labels that exceed 12 characters to 12 characters.
TRUNCATEROTATE
attempts the TRUNCATE policy, and then the ROTATE policy.
TRUNCATESTAGGER
attempts the TRUNCATE policy, and then the STAGGER policy.
TRUNCATETHIN
attempts the TRUNCATE policy, and then the THIN policy.
Note A note is written to the SAS log when tick value thinning occurs.
1078 Chapter 8 / Axis Options in Layouts
TICKVALUEFORMAT=format
specifies how to format the values for major tick marks.
Interaction This option is ignored when the axis tick values are extracted to an
axis legend. See TICKVALUEFITPOLICY=EXTRACT |
EXTRACTALWAYS.
Tip Use this option when you want to duplicate tick values on an axis.
TICKVALUELIST=(string-list)
specifies the list of tick values that are to be displayed on the axis.
string-list
a space-separated list of values, enclosed in parentheses.
Only the tick values that are included in the string list are displayed on the axis.
The values are displayed in the order in which they are listed. The data values
that are not in the list are dropped. The list can be a subset of the data values. It
can also contain values that are not included in the actual data. A tick value that
is not included in the data appears on the axis, but no data is represented at its
tick mark.
Notes If the string list contains duplicate values, then the first
occurrence of the duplicated value in the list is honored and the
remaining instances are ignored.
When the values specified in the list are compared with the actual
data values, leading blanks are honored and trailing blanks are
ignored.
Tips You can use this option to subset the axis values or to display the
values in a specific order.
You can use this option to display values on the axis that are not
contained in the data.
Examples The following example specifies the axis tick values Sedan,
Sports, Wagon, and SUV:
tickvaluelist=("Sedan" "Sports" "Wagon" "SUV")
The following example specifies the axis tick values 10, 20, 30,
and 40:
Axis Options for LAYOUT OVERLAY 1079
The X labels read left to right in a downward direction. The X2 labels read
left to right in an upward direction.
DIAGONAL2
rotates the tick values to a –45-degree diagonal position.
The X labels read left to right in an upward direction. The X2 labels read left
to right in a downward direction.
VERTICAL
rotates the labels to a 90-degree vertical position.
Default DIAGONAL
TICKVALUESPLITCHAR="character-list"
specifies a list of characters on which the tick values can be split, if needed.
When multiple characters are specified, each character in the list is treated as a
separate split character unless the specified characters appear consecutively in
the tick value. In that case, all of the specified split characters together are
treated as a single split character.
"character-list"
one or more characters with no delimiter between each character.
tickvaluesplitchar="abc"
TICKVALUESPLITCHARDROP=TRUE | FALSE
specifies whether the split characters should be included in the displayed tick
values. The split characters are specified by the TICKVALUESPLITCHAR=
option.
TRUE
drops the split characters from the tick value display.
FALSE
includes the split characters in the tick value display.
The fit policy determines how the characters are displayed. If the display
policy is SPLIT or SPLITTHIN and TICKVALUESPLITCHARDROP=FALSE,
then each tick value is split at a split character only where a split is
necessary in order to make the value fit the available space. A split might not
Axis Options for LAYOUT OVERLAY 1081
occur at every split character in the tick value. At each split point, the split
character remains as the last character in the current line. The characters
that follow the split character, up to and including the split character at the
next split point, are then wrapped to the following line. This process repeats
until the entire data tick value is displayed. The following figure shows an
example in which TICKVALUESPLITCHARDROP=FALSE and three-word,
asterisk-delimited tick values are split on the asterisk character by using the
SPLIT policy.
Notice that a split occurs on the first asterisk and not at the second. In this
case, a split is not needed at the second asterisk.
Notice that a split occurs after each asterisk and each asterisk appears at
the end of the line. In this case, three lines are displayed.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
INCLUDERANGES on page 1083 Specifies one or more ranges for a broken axis.
start
specifies a numeric value or the keyword MIN.
end
specifies a numeric value or the keyword MAX.
The following figure shows a linear axis, broken into ranges 50–52 and 56–73.
Restrictions This option is valid for linear and time axes in an OVERLAY layout
only.
Only one axis can be broken. If this option is specified for both
axes, then it is honored for the vertical axis and ignored for the
horizontal axis.
When plots are associated with the X and X2 axes or with Y and
Y2 axes, neither axis can be broken.
When this option is specified, data tips are not displayed, and the
plot URL= option is ignored.
Notes When this option is specified, data-clipping might occur for the
following: plot markers and marker characters, box-plot outlier
markers, fixed-position data labels, needle plots and fringe plots
in the X direction, reference lines and drop lines on the broken
axis, axis tables, and relative bubble plots.
Curve label positions are based on the contiguous axis data range.
When curve labels are specified with a broken axis, the curve
label positions might not be ideal.
Tip Starting with SAS 9.4M3, you can use the AXISBREAKTYPE= and
AXISBREAKSYMBOL= options in the BEGINGRAPH statement to
display the break in the axis as only a symbol on the axis line.
INTEGER=TRUE | FALSE
specifies that evenly spaced integer values are used for tick marks.
Default FALSE
Note This option is ignored when the data exceeds the limits of integer
values.
See “boolean ” on page xii for other Boolean values that you can use.
MINORGRID=TRUE | FALSE
specifies whether grid lines are displayed at the minor tick marks.
1086 Chapter 8 / Axis Options in Layouts
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tips The GRIDATTRS= option does not affect the appearance of the
minor grid lines. To control the minor grid line appearance, use the
MINORGRIDATTRS= option.
Use the MINORTICKS= option to display the minor tick marks on the
axis.
See “boolean ” on page xii for other Boolean values that you can use.
The following figure shows the minor grid lines set to light blue, dotted lines on
a linear axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a base-10 log axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a time axis. (See the example.)
Defaults The GraphGridLines style element is used starting with SAS 9.4.
Tip Use the GRIDATTRS= option to control the appearance of the major
grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Example Here is an example that specifies light blue, dotted lines for the
minor grid.
minorgridattrs=(color=lightblue pattern=dot);
MINORTICKCOUNT=positive-integer
specifies the number of minor ticks that are displayed on the axis.
Defaults Four ticks with five intervals in SAS 9.4M1 and earlier releases.
MINORTICKS=TRUE | FALSE
specifies whether minor ticks are displayed. When MINORTICKS=TRUE, the
minor tick marks are displayed on the axis as shown in the following figure.
Default FALSE
Tip Use the MINORGRID= option to display grid lines at the minor tick
values.
See “boolean ” on page xii for other Boolean values that you can use.
1088 Chapter 8 / Axis Options in Layouts
ORIGIN=number
specifies that the axis perpendicular to the current axis is drawn at the indicated
data value. For managing origin settings, GTL treats the X and Y axes as a pair,
and the X2 and Y2 axes as a separate pair. Thus, if you set the Y-axis origin to
200, then the X axis is drawn from that origin point. If the graph also displays an
X2 axis, then it is unaffected and does not move. Similarly, if you set an origin
for the Y2 axis, then the X2 axis moves to that origin point and the X axis is
unaffected.
If you set an origin for the Y2 axis and there is no X2 axis, then the origin setting
for Y2 does not affect the graph display. That is, the X axis does not move to
that origin point.
If you set an origin for an axis and the axis has a tick value at that origin value,
the tick value is not displayed. Suppressing the tick value at the origin prevents
the value from colliding with the axis value on the perpendicular axis. However,
it is possible that the tick values on the orthogonal axes will collide.
Default The axis perpendicular to the current axis is drawn at the minimum
tick value minus the OFFSETMIN= value.
Interactions If the specified value is outside the data range for the current axis,
then the data range is extended to include the value.
The axis line, ticks, and tick values of the “perpendicular” axis move
to the location indicated by the origin. The axis label is not moved.
Tip This option is often used to create Cartesian axes (axes centered at
ORIGIN=0).
THRESHOLDMAX=number
specifies a bias for including one more tick mark at the maximum end of the
axis.
Default 0.30
Range 0–1
THRESHOLDMIN=number
specifies a bias for including one more tick mark at the minimum end of the axis.
Default 0.30
Range 0–1
TICKDISPLAYLIST=(string-list)
specifies the text that is displayed for the tick values that are defined in the
TICKVALUELIST= option. The string list is a space-separated list of string
values that are displayed on the axis in place of the values in the
TICKVALUELIST= option. The strings map one-to-one positionally with the
values that are listed in the TICKVALUELIST= option.
Tip This option should be used with the TICKVALUELIST= option. The
number of items in the list for this option should equal the
number of items in the list for the TICKVALUELIST= option.
TICKVALUEFITPOLICY=policy
specifies a policy for avoiding tick value collision on an axis. The effectiveness
of a collision-avoidance policy depends on the number of tick values, their
length, and the length of the axis. Which policies are valid depends on the axis
on which this option is used.
NONE
makes no attempt to avoid collisions between tick values.
THIN
eliminates alternate tick values.
NONE
makes no attempt to avoid collisions between tick values.
ROTATE
rotates the tick values if a collision occurs.
ROTATEALWAYS
rotates the tick values regardless of whether a collision occurs.
ROTATETHIN
attempts the ROTATE policy, and then the THIN policy.
STAGGER
alternates the tick values between two rows.
STAGGERROTATE
attempts the STAGGER policy, and then the ROTATE policy.
STAGGERTHIN
attempts the STAGGER policy, and then the THIN policy.
THIN
eliminates alternate tick values.
Default THIN
Note A note is written to the SAS log when tick value thinning occurs.
Axis Options for LAYOUT OVERLAY 1091
(format-options)
specifies one or more formatting options for major tick values.
MAXWIDTH=integer
specifies the maximum width for displayed tick values.
Default 8
MAXDECIMALS=integer
specifies the maximum number of decimals for displayed tick values.
Default 6
PREFERREDDECIMALS=integer
specifies the number of decimal places that you want to display for most
values.
Default 2
EXTRACTSCALE=TRUE | FALSE
specifies whether to extract a scale factor from the tick values and use it
to reduce the tick value width.
For long axis labels, if the scale does not fit the available space, then the
label is truncated, and the scale is appended to the truncated label.
Ellipses indicate that the label was truncated, as shown in the following
example.
Total Sales for the Fourth Quarter Of ... (millions)
In extreme cases in which the scale does not fit even with truncation, the
entire axis is dropped.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can
use.
EXTRACTSCALETYPE=DEFAULT | SCIENTIFIC
specifies whether to extract a named scale or a scientific-notation scale.
DEFAULT
extracts a named scale.
SCIENTIFIC
extracts a scientific-notation scale.
Default DEFAULT
Restriction The scale is derived from the English locale for all locales.
DATA
uses the format that has been assigned to the column that is contributing to
the axis (or BEST6 if no format is assigned) in order to control the formatting
of the major tick values.
format
specifies a format to apply to the major tick values.
Restriction GTL currently honors most, but not every, SAS format. For
details, see Appendix 4, “Format Support in ODS Graphics,” on
page 1621 .
Axis Options for LAYOUT OVERLAY 1093
TICKVALUELIST=(numeric-list)
specifies the tick values for a linear axis as a list.
The VIEWMIN= and VIEWMAX= options alter the axis data range.
If the VIEWMIN= option is set to the minimum tick list value and
the VIEWMAX= option is set to the maximum tick list value, then
all ticks in the tick list are displayed. This might result in some data
not being displayed. For example, data might not be displayed
when the VIEWMIN= value is greater than the actual data
minimum, or when the VIEWMAX= value is less than actual data
maximum.
Tip The values in the list are formatted according to the setting for the
TICKVALUEFORMAT= option.
TICKVALUEPRIORITY=TRUE | FALSE
specifies whether an axis tick specification (TICKVALUELIST= or
TICKVALUESEQUENCE=) can extend the axis data range.
TRUE
extends the axis data range (but does not reduce it) to include the minimum
and maximum values that are specified by either the TICKVALUELIST= or
TICKVALUESEQUENCE= option.
If the minimum and maximum of the user-specified values are within the
data range, this option has no effect.
FALSE
displays only the tick values that are specified by the TICKVALUELIST=
option that fall within the explicit data range set by the VIEWMIN= and
VIEWMAX= options or by the implicit data range set by the actual data
minimum and data maximum.
Default FALSE
Interactions When this option is set to TRUE, the VIEWMIN= and VIEWMAX=
options are ignored.
Note If the minimum and maximum of the specified values are within the
data range, then this option has no effect.
See “boolean ” on page xii for other Boolean values that you can use.
DIAGONAL
rotates the tick values to a 45-degree diagonal position.
The X labels read left to right in a downward direction. The X2 labels read
left to right in an upward direction.
DIAGONAL2
rotates the tick values to a –45-degree diagonal position.
The X labels read left to right in an upward direction. The X2 labels read left
to right in a downward direction.
Axis Options for LAYOUT OVERLAY 1095
VERTICAL
rotates the labels to a 90-degree vertical position.
Default DIAGONAL
START=number
specifies the value for the first tick mark.
END=number
specifies the value for the last tick mark.
INCREMENT=number
specifies the increment for intermediate tick marks between the first and
last tick marks.
The END value always controls the last tick mark. The interval between the
last tick mark and the previous tick mark might not necessarily be the
INCREMENT value.
The VIEWMIN= and VIEWMAX= options alter the axis data range.
If the VIEWMIN= option is set to the START= option value and the
VIEWMAX= option is set to the END= option value, then all ticks in
the tick sequence are displayed.
Tip The values in the sequence are formatted according to the setting
for the TICKVALUEFORMAT= option.
1096 Chapter 8 / Axis Options in Layouts
VIEWMAX=number
specifies the maximum data value to include in the display. The value might be
adjusted by the threshold calculation.
Default The maximum value in the data for the specified axis.
Interactions This option does not determine the maximum axis tick value that
is displayed. The THRESHOLDMAX= value is used to determine
the maximum tick value.
The maximum axis tick value might differ from the VIEWMAX=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMAX= value as the maximum tick value, use
the TICKVALUELIST= option.
VIEWMIN=number
specifies the minimum data value to include in the display. The value might be
adjusted by the threshold calculation.
Default The minimum value in the data for the specified axis.
Interactions This option does not determine the minimum axis tick value that
is displayed. The THRESHOLDMIN= value is used to determine
the minimum tick value.
Axis Options for LAYOUT OVERLAY 1097
The minimum axis tick value might differ from the VIEWMIN=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMIN= value as the minimum tick value, use
the TICKVALUELIST= option.
BASE=10 | 2 | E
specifies the base of the logarithmic scale for the axis values.
Default 10
MINORGRID=TRUE | FALSE
specifies whether grid lines are displayed at the minor tick marks.
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tips The GRIDATTRS= option does not affect the appearance of the
minor grid lines. To control the minor grid line appearance, use the
MINORGRIDATTRS= option.
Axis Options for LAYOUT OVERLAY 1099
Use the MINORTICKS= option to display the minor tick marks on the
axis.
See “boolean ” on page xii for other Boolean values that you can use.
The following figure shows the minor grid lines set to light blue, dotted lines on
a linear axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a base-10 log axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a time axis. (See the example.)
Defaults The GraphGridLines style element is used starting with SAS 9.4.
Tip Use the GRIDATTRS= option to control the appearance of the major
grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Example Here is an example that specifies light blue, dotted lines for the
minor grid.
minorgridattrs=(color=lightblue pattern=dot);
MINORTICKCOUNT=positive-integer
specifies the number of minor ticks that are displayed on the axis.
MINORTICKS=TRUE | FALSE
specifies whether minor ticks are displayed. When MINORTICKS=TRUE, the
minor tick marks are displayed on the axis as shown in the following figure.
Default FALSE
Tip Use the MINORGRID= option to display grid lines at the minor tick
values.
See “boolean ” on page xii for other Boolean values that you can use.
THRESHOLDMAX=number
specifies a bias for including one more tick mark at the maximum end of the
axis.
Default 0.30
Range 0–1
Tips If the threshold is set to 0, the potential tick mark is never displayed.
If the threshold is set to 1, then the tick mark is always displayed.
THRESHOLDMIN=number
specifies a bias for including one more tick mark at the minimum end of the axis.
Default 0.30
Range 0–1
Tips If the threshold is set to 0, the potential tick mark is never displayed.
If the threshold is set to 1, then the tick mark is always displayed.
AUTO
selects a LOGEXPAND, LOGEXPONENT, or LINEAR representation
automatically based on the range of the data.
LOGEXPAND
places the major tick marks at uniform intervals at integer powers of the
base.
Base=10
Base=2
Base=E
LOGEXPONENT
places the major tick marks at uniform intervals at integer powers of the
base.
The tick values are only the integer exponents for all bases.
1102 Chapter 8 / Axis Options in Layouts
LINEAR
places the major tick marks at non-uniform intervals that cover the range of
the data.
Default AUTO
GTL currently honors most but not every SAS format. For details,
see Appendix 4, “Format Support in ODS Graphics,” on page 1621.
TICKVALUEFORMAT=DATA | format
specifies how to format the values for major tick marks.
DATA
uses the format that has been assigned to the column that is contributing to
the axis (or BEST6 if no format is assigned) in order to control the formatting
of the major tick values.
format
specifies a format to apply to the major tick values.
Restriction GTL currently honors most, but not every, SAS format. For
details, see Appendix 4, “Format Support in ODS Graphics,” on
page 1621.
See BASE=
TICKINTERVALSTYLE=
TICKVALUELIST=(numeric-list)
specifies the tick values for a linear axis as a list.
Default Only the tick values specified in the list that fall within the
explicit data range set by the VIEWMIN= and VIEWMAX= options
or by the implicit data range set by the actual data minimum and
data maximum are displayed. An internal algorithm determines
the tick marks.
Interactions The VALUESTYPE= option determines how the values in the list
are interpreted.
The VIEWMIN= and VIEWMAX= options alter the axis data range.
If the VIEWMIN= option is set to the minimum tick list value and
the VIEWMAX= option is set to the maximum tick list value, then
all ticks in the tick list are displayed. This might result in some
data not being displayed. For example, data might not be
displayed when the VIEWMIN= value is greater than the actual
data minimum, or when the VIEWMAX= value is less than actual
data maximum.
that case, specify uniform log tick values such as 1, 10, 100, and
1000 in the TICKVALUELIST= option.
See VIEWMIN= and VIEWMAX= options for controlling the data range
TICKVALUEPRIORITY=TRUE | FALSE
specifies whether the TICKVALUELIST= specification can extend the axis data
range.
TRUE
extends the axis data range (but does not reduce it) to include the minimum
and maximum values that are specified by the TICKVALUELIST= option.
If the minimum and maximum of the user-specified values are within the
data range, this option has no effect.
FALSE
displays only the tick values that are specified by the TICKVALUELIST=
option that fall within the explicit data range set by the VIEWMIN= and
VIEWMAX= options or by the implicit data range set by the actual data
minimum and data maximum.
Default FALSE
Interactions When this option is set to TRUE, the VIEWMIN= and VIEWMAX=
options are ignored.
Note If the minimum and maximum of the specified values are within the
data range, then this option has no effect.
See “boolean ” on page xii for other Boolean values that you can use.
VALUESTYPE=EXPANDED | EXPONENT
specifies the scale that the system uses when interpreting the
TICKVALUELIST=, VIEWMAX=, and VIEWMIN= option values. Use this option
to choose your preferred way of specifying log-axis values.
EXPANDED
values are interpreted as powers of the base such as 0.1, 1, 10, 100, and so on,
for base 10, for example.
Axis Options for LAYOUT OVERLAY 1105
EXPONENT
values are interpreted as integer exponents of the base such as 1, 2, 3, and so
on, for base 10, base 2, and base E.
Default EXPANDED
Note This option does not change the style of the tick values that are
displayed on the axis. It changes only how the VIEWMIN=,
VIEWMAX=, and TICKVALUELIST= option values are interpreted by
the system.
VIEWMAX=number
specifies the maximum data value to include in the display.
Default The maximum value in the data for the specified axis.
The maximum axis tick value might differ from the VIEWMAX=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMAX= value as the maximum tick value, use
the TICKVALUELIST= option.
VIEWMIN=number
specifies the minimum data value to include in the display.
Default The minimum value in the data for the specified axis.
The minimum axis tick value might differ from the VIEWMIN=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMIN= value as the minimum tick value, use
the TICKVALUELIST= option.
INCLUDERANGES on page 1108 Specifies one or more ranges for a broken axis.
start
specifies a SAS time, date, or date-time constant, or the keyword MIN.
end
specifies a SAS time, date, or date-time constant, or the keyword MAX.
The following figure shows a linear axis, broken into ranges 50–52 and 56–73.
Axis Options for LAYOUT OVERLAY 1109
As shown in the figure, break lines are drawn to indicate the break in the axis.
Restrictions This option is valid for linear and time axes in an OVERLAY layout
only.
Only one axis can be broken. If this option is specified for both
axes, then it is honored for the vertical axis and ignored for the
horizontal axis.
When plots are associated with the X and X2 axes or with Y and
Y2 axes, neither axis can be broken.
When this option is specified, data tips are not displayed, and the
plot URL= option is ignored.
Notes When this option is specified, data-clipping might occur for the
following: plot markers and marker characters, box-plot outlier
markers, fixed-position data labels, needle plots and fringe plots
in the X direction, reference lines and drop lines on the broken
axis, axis tables, and relative bubble plots.
Curve label positions are based on the contiguous axis data range.
When curve labels are specified with a broken axis, the curve
label positions might not be ideal.
Tip Starting with SAS 9.4M3, you can use the AXISBREAKTYPE= and
AXISBREAKSYMBOL= options in the BEGINGRAPH statement to
display the break in the axis as only a symbol on the axis line.
Example includeranges=('01Jan2001'd-'01May2003'd
'01Jan2005'd-'01Oct2005'd)
Default AUTO. An appropriate interval is chosen based on the data and the
column date, date-time, or time format.
Requirement The data column(s) mapped to a time axis must be in the same
duration units: TIME, DATE, or DATETIME. The selection of an
interval must be consistent with the duration unit. For example, if
the data are in time units, you can specify only AUTO, SECOND,
MINUTE, HOUR.
INTERVALMULTIPLIER=positive-integer
specifies a multiplier to apply to the time interval that is in effect for the axis.
Default 1
MINORGRID=TRUE | FALSE
specifies whether grid lines are displayed at the minor tick marks.
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tips The GRIDATTRS= option does not affect the appearance of the
minor grid lines. To control the minor grid line appearance, use the
MINORGRIDATTRS= option.
Use the MINORTICKS= option to display the minor tick marks on the
axis.
See “boolean ” on page xii for other Boolean values that you can use.
The following figure shows the minor grid lines set to light blue, dotted lines on
a linear axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a base-10 log axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a time axis. (See the example.)
Defaults The GraphGridLines style element is used starting with SAS 9.4.
Axis Options for LAYOUT OVERLAY 1113
Tip Use the GRIDATTRS= option to control the appearance of the major
grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Example Here is an example that specifies light blue, dotted lines for the
minor grid.
minorgridattrs=(color=lightblue pattern=dot);
MINORTICKINTERVAL=interval
specifies the time interval between minor ticks. See Table 8.10 on page 1110 for
information about the intervals that you can select. The interval that you select
must be consistent with the axis data duration units such as TIME, DATE, or
DATETIME. For example, if the axis data is in TIME units, then you must specify
AUTO, SECOND, MINUTE, or HOUR.
Default AUTO
MINORTICKS=TRUE | FALSE
specifies whether minor ticks are displayed. When MINORTICKS=TRUE, the
minor tick marks are displayed on the axis as shown in the following figure.
Default FALSE
Tip Use the MINORGRID= option to display grid lines at the minor tick
values.
See “boolean ” on page xii for other Boolean values that you can use.
SPLITTICKVALUE=TRUE | FALSE
specifies whether to split the tick values on an X or X2 axis, if possible. This
option is not available for a Y or Y2 axis.
TRUE
splits the axis tick values into two lines allowing more tick values to appear.
For example, with INTERVAL= MONTH, this is how tick values are split:
FALSE
does not split the axis tick values.
For example, when this option specifies FALSE, this is how the tick values in
the previous example appear:
Typically, fewer tick values fit, causing thinning, rotation, or staggering of the
values. See the TICKVALUEFITPOLICY= option.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
TICKVALUEFITPOLICY=policy
specifies a policy for avoiding tick value collision on an X or X2 axis. This option
is not available for the Y and Y2 axes. The effectiveness of a collision-avoidance
policy depends on the number of tick values, their length, and the length of the
axis. The following policies are valid:
NONE
makes no attempt to avoid collisions between tick values.
ROTATE
rotates the tick values if a collision occurs.
Axis Options for LAYOUT OVERLAY 1115
ROTATEALWAYS
rotates the tick values regardless of whether a collision occurs.
ROTATETHIN
attempts the ROTATE policy, and then the THIN policy.
STAGGER
alternates the tick values between two rows.
STAGGERROTATE
attempts the STAGGER policy, and then the ROTATE policy.
STAGGERTHIN
attempts the STAGGER policy, and then the THIN policy.
THIN
eliminates alternate tick values.
Default THIN
Note A note is written to the SAS log when tick value thinning occurs.
TICKVALUEFORMAT=format | DATA
specifies how to format the values for major tick marks.
format
specifies a SAS date, time, or datetime format to control how the major tick
values are displayed.
This format must be in the same duration units as the data column(s)
mapped to a time axis: TIME, DATE, or DATETIME and should be appropriate
for the value of the INTERVAL= option. For example, if INTERVAL=MONTH
and there are two years of data displayed on the axis, then choosing
TICKVALUEFORMAT=YEAR. would result in several ticks having the same
year value.
DATA
specifies that the SAS date, time, or datetime format associated with the
data column assigned to the axis be used to control how the major tick
values are displayed.
Default The default format used by the INTERVAL= option. The default
does not apply if TICKVALUELIST= is specified.
GTL currently honors most but not every SAS format. For details,
see Appendix 4, “Format Support in ODS Graphics,” on page 1621.
Interactions The values in the list are formatted according to the format
specified on the TICKVALUEFORMAT= option. If
TICKVALUEFORMAT= is not used, then the values are formatted
according to the column format (the default TICKVALUEFORMAT
value is not applied to these values).
TICKVALUEPRIORITY=TRUE | FALSE
specifies whether the TICKVALUELIST= specification can extend the axis data
range.
TRUE
extends the axis data range (but does not reduce it) to include the minimum
and maximum values that are specified by the TICKVALUELIST= option.
If the minimum and maximum of the user-specified values are within the
data range, this option has no effect.
FALSE
displays only the tick values that are specified by the TICKVALUELIST=
option that fall within the explicit data range set by the VIEWMIN= and
VIEWMAX= options or by the implicit data range set by the actual data
minimum and data maximum.
Default FALSE
Axis Options for LAYOUT OVERLAY 1117
Interactions When this option is set to TRUE, the VIEWMIN= and VIEWMAX=
options are ignored.
Note If the minimum and maximum of the specified values are within the
data range, then this option has no effect.
See “boolean ” on page xii for other Boolean values that you can use.
DIAGONAL
rotates the tick values to a 45-degree diagonal position.
The X labels read left to right in a downward direction. The X2 labels read
left to right in an upward direction.
DIAGONAL2
rotates the tick values to a –45-degree diagonal position.
The X labels read left to right in an upward direction. The X2 labels read left
to right in a downward direction.
VERTICAL
rotates the labels to a 90-degree vertical position.
Default DIAGONAL
VIEWMAX=number
specifies the maximum data value to include in the display.
Default The maximum value in the data for the specified axis.
The maximum axis tick value might differ from the VIEWMAX=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMAX= value as the maximum tick value, use
the TICKVALUELIST= option.
VIEWMIN=number
specifies the minimum data value to include in the display.
Default The minimum value in the data for the specified axis.
The minimum axis tick value might differ from the VIEWMIN=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMIN= value as the minimum tick value, use
the TICKVALUELIST= option.
Details
The LAYOUT OVERLAY statement provides the XAXISOPTS=, YAXISOPTS=,
X2AXISOPTS=, Y2AXISOPTS= options that enable you to manage the axis display
separately for the X, Y, X2, and Y2 axes. The following example template uses the
YAXISOPTS= option to manage the grid lines, tick marks, and tick values on a Y
axis:
begingraph;
layout overlay /
yaxisopts=(
griddisplay=on
display=(ticks tickvalues)
);
seriesplot x=month y=predict;
endlayout;
endgraph;
Within an OVERLAY layout block, each plot axis is always of a particular type. In
the default cases, the axis type is always DISCRETE, LINEAR, or TIME. The TYPE=
option enables you to specify an axis type that overrides the default. For example,
when appropriate for the data, you can request a LOG axis. When you override the
default axis type, you must be sure to specify the correct axis type for the plot(s)
that you are defining.
Each axis type has features specific to that type, and the following axis options
enable you to specify features for the different types: DISCRETEOPTS= ,
LINEAROPTS= , LOGOPTS= , and TIMEOPTS= . One or more of these options can
be specified for an axis, but the specified settings are applied only to the axis type
that supports them.
Restriction: The OVERLAY3D layout supports linear and time axes only.
Note: Unless otherwise indicated in an option description, each axis option is available for
the X, Y, and Z axis.
See: “LAYOUT OVERLAY3D Statement” on page 178
Syntax
Axis options for the plots within an OVERLAY3D layout are specified with the
following options on a LAYOUT OVERLAY3D statement:
XAXISOPTS=(axis-options)
YAXISOPTS=(axis-options)
1120 Chapter 8 / Axis Options in Layouts
ZAXISOPTS=(axis-options)
STANDARD
specifies that the LABEL, LINE, TICKS, and TICKVALUES are displayed
ALL
currently the same as STANDARD
NONE
specifies that no axis features are displayed
Axis Options for LAYOUT OVERLAY3D 1121
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
LABEL
displays the axis label
LINE
displays the axis line
TICKS
displays the tick marks
TICKVALUES
displays the values that are represented by the major tick marks
Default STANDARD
Tips The default line attributes for the axis line and axis tick marks are
defined in the GraphAxisLine style element.
Use the GRIDDISPLAY= and GRIDATTRS= options to set the axis grid
lines.
When LINE is excluded from the DISPLAY= option, the layout wall
outline or the default baseline of a bar chart, needle plot, or waterfall
chart can appear to be an axis line. To suppress the wall outline, use the
WALLDISPLAY= option in the layout statement. To suppress the plot
baseline, use the BASELINEATTRS= option in the plot statement.
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO_OFF
specifies that grid lines are not displayed unless the GraphGridLines element
in the current style contains DisplayOpts="ON."
AUTO_ON
specifies that grid lines are displayed unless the GraphGridLines element in
the current style contains DisplayOpts="OFF."
1122 Chapter 8 / Axis Options in Layouts
ON
specifies that grid lines are always displayed.
OFF
specifies that grid lines are never displayed.
The following table shows the end results for various combinations of the
GRIDDISPLAY= option and the DisplayOpts= attribute of the GraphGridLines
style element. Most supplied templates use the default setting AUTO_OFF to
indicate a preference for not displaying grid lines, but allowing the style to
override.
DisplayOpts= style
GRIDDISPLAY= option attribute Grid Lines Shown?
AUTO_OFF AUTO no
AUTO_OFF ON yes
AUTO_OFF OFF no
AUTO_ON ON yes
AUTO_ON OFF no
Default AUTO_OFF
Note Supplied styles use DisplayOpts="AUTO," which means that the style
has no preference about grid lines and the graphics template setting for
grid lines is always used.
Default The default label is derived from the primary plot in the layout. For
more information, see “When Plots Share Data and a Common Axis”
on page 1046.
Interaction This option is ignored if the DISPLAY= option does not display the
axis label.
Axis Options for LAYOUT OVERLAY3D 1123
Note If the axis label is too long to fit along the axis, then it is truncated
by default.
See “Overriding the Default Axis Label” in SAS Graph Template Language:
User’s Guide
Interaction This option is ignored if the DISPLAY= option does not display the
axis label.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
LINEAROPTS=(linear-axis-options)
specifies one or more options for a numeric interval axis. Options must be
enclosed in parentheses. Each option is specified as a name = value pair and
each pair is space separated.
See “Options for Linear Axes Only” on page 1125 for the options that you
can use for linear-axis-options.
OFFSETMAX=AUTO | number
reserves an area at the maximum end of the axis. No tick marks are displayed in
the reserved area.
AUTO
reserves just enough area to fully display markers and other graphical
features near the maximum end of an axis.
number
specifies the offset as a decimal proportion of the full axis length.
For a continuous axis, the offset follows the highest data value or highest
tick value, whichever is greater.
Default AUTO
Range 0–1. The sum of OFFSETMAX= and OFFSETMIN= should not be more
than 1.
OFFSETMIN=AUTO | number
reserves an area at the minimum end of the axis. No tick marks are displayed in
the reserved area.
AUTO
reserves just enough area to fully display markers and other graphical
features near the minimum end of an axis.
number
specifies the offset as a decimal proportion of the full axis length.
For a continuous axis, the offset precedes the lowest data value or lowest
tick value, whichever is less.
Default AUTO
Range 0–1. The sum of OFFSETMAX= and OFFSETMIN= should not be more
than 1.
Interaction This option is ignored if the DISPLAY= option does not display tick
values.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TIMEOPTS=(time-axis-options)
specifies one or more options for a time axis.
Requirements Columns associated with a time axis must be in SAS time, SAS
date, or SAS datetime units and have an associated SAS time,
date, or datetime format.
See “Options for Time Axes Only” on page 1134 for the options that
you can use for time-axis-options.
AUTO
requests that the axis type be automatically determined by the plot or the
overlay contents.
Axis Options for LAYOUT OVERLAY3D 1125
LINEAR
uses a LINEAR axis if possible.
You can add a LINEAROPTS= option list to customize this axis type.
TIME
uses a TIME axis if possible.
Data for this axis must be SAS time, SAS date, or SAS datetime values. You
can add a TIMEOPS= option list to customize this axis type.
Default AUTO
Interactions If this option is set to anything other than AUTO, then plots within
the layout are dropped from the display if their data types or data
ranges do not match the axis type requirements. For more
information, see “Plot Axis Types Must Agree on Common Axes” on
page 1049.
After the axis type is determined (whether you set a specific type
or AUTO is in effect), only options supported by that axis type can
be used. For example, if TYPE=TIME, then only the general
OVERLAY3D axis options and those available on TIMEOPS= are
supported.
INTEGER=TRUE | FALSE
specifies that evenly spaced integer values are used for tick marks.
Default FALSE
Note This option is ignored when the data exceeds the limits of integer
values.
See “boolean ” on page xii for other Boolean values that you can use.
MINORGRID=TRUE | FALSE
specifies whether grid lines are displayed at the minor tick marks.
Axis Options for LAYOUT OVERLAY3D 1127
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tips The GRIDATTRS= option does not affect the appearance of the
minor grid lines. To control the minor grid line appearance, use the
MINORGRIDATTRS= option.
Use the MINORTICKS= option to display the minor tick marks on the
axis.
See “boolean ” on page xii for other Boolean values that you can use.
The following figure shows the minor grid lines set to light blue, dotted lines on
a linear axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a base-10 log axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a time axis. (See the example.)
Defaults The GraphGridLines style element is used starting with SAS 9.4.
Tip Use the GRIDATTRS= option to control the appearance of the major
grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Example Here is an example that specifies light blue, dotted lines for the
minor grid.
minorgridattrs=(color=lightblue pattern=dot);
MINORTICKCOUNT=positive-integer
specifies the number of minor ticks that are displayed on the axis.
Defaults Four ticks with five intervals in SAS 9.4M1 and earlier releases.
Interactions The DISPLAY= option specification must include TICKS for this
option to have any effect.
MINORTICKS=TRUE | FALSE
specifies whether minor ticks are displayed. When MINORTICKS=TRUE, the
minor tick marks are displayed on the axis as shown in the following figure.
Default FALSE
Tip Use the MINORGRID= option to display grid lines at the minor tick
values.
See “boolean ” on page xii for other Boolean values that you can use.
THRESHOLDMAX=number
specifies a bias for including one more tick mark at the maximum end of the
axis.
Default 0.30
Range 0–1
Tips If the threshold is set to 0, the potential tick mark is never displayed.
If the threshold is set to 1, then the tick mark is always displayed.
THRESHOLDMIN=number
specifies a bias for including one more tick mark at the minimum end of the axis.
Default 0.30
Range 0–1
Tips If the threshold is set to 0, the potential tick mark is never displayed.
If the threshold is set to 1, then the tick mark is always displayed.
TICKDISPLAYLIST=(string-list)
specifies the text that is displayed for the tick values that are defined in the
TICKVALUELIST= option. The string list is a space-separated list of string
values that are displayed on the axis in place of the values in the
TICKVALUELIST= option. The strings map one-to-one positionally with the
values that are listed in the TICKVALUELIST= option.
Tip This option should be used with the TICKVALUELIST= option. The
number of items in the list for this option should equal the
number of items in the list for the TICKVALUELIST= option.
(format-options)
specifies one or more formatting options for major tick values.
MAXWIDTH=integer
specifies the maximum width for displayed tick values.
Default 8
MAXDECIMALS=integer
specifies the maximum number of decimals for displayed tick values.
Default 6
PREFERREDDECIMALS=integer
specifies the number of decimal places that you want to display for most
values.
Default 2
EXTRACTSCALE=TRUE | FALSE
specifies whether to extract a scale factor from the tick values and use it
to reduce the tick value width.
For long axis labels, if the scale does not fit the available space, then the
label is truncated, and the scale is appended to the truncated label.
Ellipses indicate that the label was truncated, as shown in the following
example.
Total Sales for the Fourth Quarter Of ... (millions)
In extreme cases in which the scale does not fit even with truncation, the
entire axis is dropped.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can
use.
EXTRACTSCALETYPE=DEFAULT | SCIENTIFIC
specifies whether to extract a named scale or a scientific-notation scale.
DEFAULT
extracts a named scale.
SCIENTIFIC
extracts a scientific-notation scale.
Default DEFAULT
Restriction The scale is derived from the English locale for all locales.
DATA
uses the format that has been assigned to the column that is contributing to
the axis (or BEST6 if no format is assigned) in order to control the formatting
of the major tick values.
format
specifies a format to apply to the major tick values.
Restriction GTL currently honors most, but not every, SAS format. For
details, see Appendix 4, “Format Support in ODS Graphics,” on
page 1621 .
TICKVALUELIST=(numeric-list)
specifies the tick values for a linear axis as a list.
Tip The values in the list are formatted according to the setting for the
TICKVALUEFORMAT= option.
TICKVALUEPRIORITY=TRUE | FALSE
specifies whether an axis tick specification (TICKVALUELIST= or
TICKVALUESEQUENCE=) can extend the axis data range.
TRUE
extends the axis data range (but does not reduce it) to include the minimum
and maximum values that are specified by either the TICKVALUELIST= or
TICKVALUESEQUENCE= option.
If the minimum and maximum of the user-specified values are within the
data range, this option has no effect.
FALSE
displays only the tick values that are specified by the TICKVALUELIST=
option that fall within the explicit data range set by the actual data minimum
and data maximum.
Default FALSE
This option is ignored if the DISPLAY= option does not display the
tick values.
Note If the minimum and maximum of the specified values are within the
data range, then this option has no effect.
See “boolean ” on page xii for other Boolean values that you can use.
START=number
specifies the value for the first tick mark.
END=number
specifies the value for the last tick mark.
INCREMENT=number
specifies the increment for intermediate tick marks between the first and
last tick marks.
The END value always controls the last tick mark. The interval between the
last tick mark and the previous tick mark might not necessarily be the
INCREMENT value.
This option is ignored if the DISPLAY= option does not display tick
marks.
Tip The values in the sequence are formatted according to the setting
for the TICKVALUEFORMAT= option.
Default AUTO. An appropriate interval is chosen based on the data and the
column date, date-time, or time format.
Requirement The data column(s) mapped to a time axis must be in the same
duration units: TIME, DATE, or DATETIME. The selection of an
interval must be consistent with the duration unit. For example, if
1136 Chapter 8 / Axis Options in Layouts
the data are in time units, you can specify only AUTO, SECOND,
MINUTE, HOUR.
INTERVALMULTIPLIER=positive-integer
specifies a multiplier to apply to the time interval that is in effect for the axis.
Default 1
MINORGRID=TRUE | FALSE
specifies whether grid lines are displayed at the minor tick marks.
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tips The GRIDATTRS= option does not affect the appearance of the
minor grid lines. To control the minor grid line appearance, use the
MINORGRIDATTRS= option.
Axis Options for LAYOUT OVERLAY3D 1137
Use the MINORTICKS= option to display the minor tick marks on the
axis.
See “boolean ” on page xii for other Boolean values that you can use.
The following figure shows the minor grid lines set to light blue, dotted lines on
a linear axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a base-10 log axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a time axis. (See the example.)
Defaults The GraphGridLines style element is used starting with SAS 9.4.
Tip Use the GRIDATTRS= option to control the appearance of the major
grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Example Here is an example that specifies light blue, dotted lines for the
minor grid.
minorgridattrs=(color=lightblue pattern=dot);
MINORTICKINTERVAL=interval
specifies the time interval between minor ticks. See Table 8.11 on page 1135 for
information about the intervals that you can select. The interval that you select
must be consistent with the axis data duration units such as TIME, DATE, or
DATETIME. For example, if the axis data is in TIME units, then you must specify
AUTO, SECOND, MINUTE, or HOUR.
Default AUTO
1138 Chapter 8 / Axis Options in Layouts
MINORTICKS=TRUE | FALSE
specifies whether minor ticks are displayed. When MINORTICKS=TRUE, the
minor tick marks are displayed on the axis as shown in the following figure.
Default FALSE
Tip Use the MINORGRID= option to display grid lines at the minor tick
values.
See “boolean ” on page xii for other Boolean values that you can use.
TICKVALUEFORMAT=format | DATA
specifies how to format the values for major tick marks.
format
specifies a SAS date, time, or datetime format to control how the major tick
values are displayed.
This format must be in the same duration units as the data column(s)
mapped to a time axis: TIME, DATE, or DATETIME and should be appropriate
for the value of the INTERVAL= option. For example, if INTERVAL=MONTH
and there are two years of data displayed on the axis, then choosing
TICKVALUEFORMAT=YEAR. would result in several ticks having the same
year value.
DATA
specifies that the SAS date, time, or datetime format associated with the
data column assigned to the axis be used to control how the major tick
values are displayed.
Default The default format used by the INTERVAL= option. The default
does not apply if TICKVALUELIST= is specified.
Axis Options for LAYOUT OVERLAY3D 1139
GTL currently honors most but not every SAS format. For details,
see Appendix 4, “Format Support in ODS Graphics,” on page 1621.
Interactions The values in the list are formatted according to the format
specified on the TICKVALUEFORMAT= option. If
TICKVALUEFORMAT= is not used, then the values are formatted
according to the column format (the default TICKVALUEFORMAT
value is not applied to these values).
Details
The LAYOUT OVERLAY3D statement provides XAXISOPTS=, YAXISOPTS=, and
ZAXISOPTS= options that enable you to manage the axis display separately for the
X, Y, and Z axes. The following example template uses the YAXISOPTS= option to
manage the display of grid lines, tick marks, and tick values on a Y axis:
begingraph;
layout overlay3d /
yaxisopts=(
griddisplay=on
display=(ticks tickvalues)
);
bihistogram3dparm x=rater y=customer z=percent;
endlayout;
endgraph;
1140 Chapter 8 / Axis Options in Layouts
Within an OVERLAY3D layout block, each plot axis is always either a linear or a
time axis. The default axis-type setting is AUTO, which specifies that the axis type
be automatically determined by the plot or the overlay contents. The TYPE= option
enables you to explicitly specify either a LINEAR or a TIME axis type. When you
override the default axis type, you must be sure to specify the correct axis type for
the plot(s) that you are defining.
Each axis type has features specific to that type, and the axis options
LINEAROPTS= and TIMEOPS= enable you to specify features for a linear or a time
axis. You can combine one or more general axis options with the options for the
specific axis type. However, specified settings are applied only to the axis type that
supports them. For example, if you specify general axis options with time axis
options and the generated graph produces a linear axis type, then the time axis
options are ignored.
Syntax
Axis options for the plots in a LATTICE layout are specified with the following
statements in a LAYOUT LATTICE statement block:
COLUMNAXIS /column-axis-options
ROWAXIS /row-axis-options
DISCRETEOPTS=(discrete-axis-options)
specifies one or more options for a discrete axis. Options must be enclosed in
parentheses. Each option is specified as a name = value pair and each pair is
space separated.
See “Options for Row and Column Discrete Axes Only” on page 1153 for
the options that you can use for discrete-axis-options.
STANDARD
specifies that the LABEL, LINE, TICKS, and TICKVALUES are displayed
ALL
currently the same as STANDARD
NONE
specifies that no axis features are displayed
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
LABEL
displays the axis label
LINE
displays the axis line
TICKS
displays the tick marks
TICKVALUES
displays the values that are represented by the major tick marks
Default STANDARD
Row and Column Axis Options for LAYOUT LATTICE 1143
Tips The default line attributes for the axis line and axis tick marks are
defined in the GraphAxisLine style element.
Use the GRIDDISPLAY= and GRIDATTRS= options to set the axis grid
lines.
When LINE is excluded from the DISPLAY= option, the layout wall
outline or the default baseline of a bar chart, needle plot, or waterfall
chart can appear to be an axis line. To suppress the wall outline, use the
WALLDISPLAY= option in the layout statement. To suppress the plot
baseline, use the BASELINEATTRS= option in the plot statement.
See “Details” on page 1193 for more information about the primary and
secondary axes.
NONE
specifies that no axis features are displayed
STANDARD
specifies that the LABEL, LINE, TICKS, and TICKVALUES are displayed on
the secondary axis
ALL
currently the same as STANDARD
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
LABEL
displays the axis label
LINE
displays the axis line
TICKS
displays the tick marks
TICKVALUES
displays the values that are represented by the major tick marks
Default NONE
Restriction If some plot statements set XAXIS=X and others set XAXIS=X2,
both the X and X2 axis are primary and a secondary X axis cannot
1144 Chapter 8 / Axis Options in Layouts
Tip Use the GRIDDISPLAY= and GRIDATTRS= options to set the axis
grid lines.
See “Details” on page 1193 for more information about the primary and
secondary axes.
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tip On a log axis, this option affects the appearance of the major grid
lines only. It does not affect the appearance of the minor grid lines.
To control the appearance of the minor grid lines on a log axis, use
the MINORGRIDATTRS= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO_OFF
specifies that grid lines are not displayed unless the GraphGridLines element
in the current style contains DisplayOpts="ON."
AUTO_ON
specifies that grid lines are displayed unless the GraphGridLines element in
the current style contains DisplayOpts="OFF."
ON
specifies that grid lines are always displayed.
OFF
specifies that grid lines are never displayed.
Row and Column Axis Options for LAYOUT LATTICE 1145
The following table shows the end results for various combinations of the
GRIDDISPLAY= option and the DisplayOpts= attribute of the GraphGridLines
style element. Most supplied templates use the default setting AUTO_OFF to
indicate a preference for not displaying grid lines, but allowing the style to
override.
DisplayOpts= style
GRIDDISPLAY= option attribute Grid Lines Shown?
AUTO_OFF AUTO no
AUTO_OFF ON yes
AUTO_OFF OFF no
AUTO_ON ON yes
AUTO_ON OFF no
Default AUTO_OFF
Note Supplied styles use DisplayOpts="AUTO," which means that the style
has no preference about grid lines and the graphics template setting for
grid lines is always used.
Default The default label is derived from the primary plot in the layout. For
more information, see “When Plots Share Data and a Common Axis”
on page 1046.
Note If the axis label is too long to fit along the axis, then it is truncated
by default.
See “Overriding the Default Axis Label” in SAS Graph Template Language:
User’s Guide
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO
uses the short label, when specified, instead of the original label.
If the short label does not fit, then it is clipped. When no short label is
specified, the original label is clipped.
SPLIT
splits the axis label at a split character only when necessary in order to make
the label fit the available space.
SPLITALWAYS
always split the axis label at every occurrence of a split character, which is
specified by the LABELSPLITCHAR= option.
STACKED
displays the Y or Y2 axis label vertically as stacked letters.
Default AUTO
LABELPOSITION=CENTER | DATACENTER
specifies the position of the axis label.
CENTER
centers each row or column axis label in its axis area.
For the row Y and Y2 axes, the label is oriented vertically and is centered in
the axis area (including the offsets) of its row. It is positioned to the left of
the tick values for the Y axis or to the right of the axis values for the Y2 axis.
For the column X and X2 axes, the label is centered in the axis area
(including the offsets) of its column. It is positioned below the tick values for
the X axis or above the axis values for the X2 axis.
DATACENTER
centers each row or column axis label in its axis tick display area.
For the row Y and Y2 axes, each label is oriented vertically and is centered in
the axis tick display area (excluding the offsets) of its row. The labels are
positioned to the left of the tick values for the Y axis or to the right of the
axis values for the Y2 axis. For the column X and X2 axes, each label is
centered in the axis tick display area (excluding the offsets) of its column.
The labels are positioned below the tick values for the X axis or above the
axis values for the X2 axis.
The following figure shows the CENTER and DATACENTER positions for row Y-
axis labels Open and Close, and column X-axis label Month. An offset is applied
to the maximum end of each axis for demonstration purposes.
Default CENTER
1148 Chapter 8 / Axis Options in Layouts
LABELSPLITCHAR="character-list"
specifies one or more characters on which the axis labels can be split, if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the axis label. In that case, all of the specified split characters
together are treated as a single split character.
When LABELFITPOLICY=SPLIT, if the axis label does not fit the available
space, then it is split on a specified split character only if a split is needed at
that point to make the label fit. In this case, a split might not occur on every
split character. When LABELFITPOLICY=SPLITALWAYS, the axis label is split
unconditionally on every occurrence of a split character. If the axis label does
not contain any of the specified split characters, the label is not split.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
LABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the displayed axis labels.
TRUE
drops the split characters from the axis label display.
FALSE
includes the split characters in the axis label display.
Default TRUE. The split characters are dropped from the axis label.
Row and Column Axis Options for LAYOUT LATTICE 1149
See “boolean ” on page xii for other Boolean values that you can use.
LABELSPLITJUSTIFY=justification
specifies the justification of the strings that are inside the axis label blocks.
justification
CENTER
LEFT
RIGHT
specifies the justification for the X or X2 axis label.
CENTER
TOP
BOTTOM
specifies the justification for the Y or Y2 axis label.
Default CENTER
LINEAROPTS=(linear-axis-options)
specifies one or more options for a numeric interval axis. Options must be
enclosed in parentheses. Each option is specified as a name = value pair and
each pair is space separated.
See “Options for Row and Column Linear Axes Only” on page 1162 for
the options that you can use for linear-axis-options.
LOGOPTS=(log-axis-options)
specifies one or more options for a log axis. Options must be enclosed in
parentheses. Each option is specified as a name = value pair and each pair is
space separated.
See “Options for Row and Column Log Axes Only” on page 1174 for the
options that you can use for log-axis-options.
NAME="string"
assigns a name to an axis for reference in other statements. Currently, it is used
only in an AXISLEGEND statement.
Restriction This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
1150 Chapter 8 / Axis Options in Layouts
Interactions This option is ignored unless the axis is discrete. The axis can be
discrete by default, or explicitly set to discrete with a TYPE=
DISCRETE setting.
AUTO
reserves just enough area to fully display markers and other graphical
features near the maximum end of an axis.
AUTOCOMPRESS
applies an automatic offset that prevents axis labels and tick values from
extending beyond the axis length.
number
specifies the offset as a decimal proportion of the full axis length.
Default AUTO
Range 0–1. The sum of OFFSETMAX= and OFFSETMIN= should not be more
than 1.
AUTO
reserves just enough area to fully display markers and other graphical
features near the maximum end of an axis.
AUTOCOMPRESS
applies an automatic offset that prevents axis labels and tick values from
extending beyond the axis length.
number
specifies the offset as a decimal proportion of the full axis length.
Default AUTO
Range 0–1. The sum of OFFSETMAX= and OFFSETMIN= should not be more
than 1.
REVERSE=TRUE | FALSE
specifies whether tick values should appear in the reverse order.
Row and Column Axis Options for LAYOUT LATTICE 1151
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
SHORTLABEL="string"
specifies an alternate axis label to display when the default label or the label
specified by the LABEL= option is too long to fit the available space.
Note If the specified label is itself too long for the axis, it is truncated in
the display.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TIMEOPTS=(time-axis-options)
specifies one or more options for a time axis.
Requirements Columns associated with a time axis must be in SAS time, SAS
date, or SAS datetime units and have an associated SAS time,
date, or datetime format.
See “Options for Row and Column Time Axes Only” on page 1184 for
the options that you can use for time-axis-options.
AUTO
requests that the axis type be automatically determined, based on the
overlay contents.
DISCRETE
uses a DISCRETE axis if possible.
The data for discrete axes can be character or numeric. You can add a
DISCRETEOPTS= option list to customize this axis type.
LINEAR
uses a LINEAR axis if possible.
You can add a LINEAROPTS= option list to customize this axis type.
TIME
uses a TIME axis if possible.
Row and Column Axis Options for LAYOUT LATTICE 1153
Data for this axis must be SAS time, SAS date, or SAS datetime values. You
can add a TIMEOPTS= option list to customize this axis type.
LOG
uses a LOG axis if possible.
You can add a LOGOPTS= option list to customize this axis type.
Interaction If a log axis is requested and the axis data contains 0 or negative
values, the axis reverts to a linear axis. This outcome can occur
for the response axis of a bar chart, line chart, needle plot, or
waterfall chart when a baseline intercept of 0 or less is specified.
It can also occur for the response axis of a waterfall chart when
an initial bar value of 0 or less is specified. To get a log response
axis in those cases, set the baseline intercept or initial bar value
to a positive value.
Default AUTO
Interactions If this option is set to anything other than AUTO, then plots within
the layout are dropped from the display if their data types or data
ranges do not match the axis type requirements. For more
information, see “Plot Axis Types Must Agree on Common Axes” on
page 1049.
After the axis type is determined (whether you set a specific type
or AUTO is in effect), you can use only options that are supported
by that axis type. For example, if TYPE=TIME, then only the general
OVERLAY axis options and those available on TIMEOPTS= are
supported.
TICKDISPLAYLIST=(string-list)
specifies the text that is displayed for the tick values that are defined in the
TICKVALUELIST= option. The string list is a space-separated list of string
values that are displayed on the axis in place of the values in the
TICKVALUELIST= option. The strings map one-to-one positionally with the
values that are listed in the TICKVALUELIST= option.
Tip This option should be used with the TICKVALUELIST= option. The
number of items in the list for this option should equal the
number of items in the list for the TICKVALUELIST= option.
Example The following example specifies the axis tick values 10, 20, 30,
and 40, and the tick display values A, B, C, and D:
tickvaluelist=("10" "20" "30" "40");
tickdisplaylist=("A" "B" "C" "D");
TICKTYPE=MIDPOINT | INBETWEEN
specifies the position of the axis tick marks.
MIDPOINT
places the tick marks at the midpoint value location.
INBETWEEN
places the tick marks half way between adjacent midpoint locations.
Default MIDPOINT
TICKVALUEFITPOLICY=policy
specifies a policy for avoiding tick value collision on an axis. The effectiveness
of a collision-avoidance policy depends on the number of tick values, their
length, and the length of the axis. Which policies are valid depends on the axis
on which this option is used.
EXTRACT
displays consecutive integers along the axis instead of the actual tick values
in order to represent those tick values.
EXTRACTALWAYS
same as EXTRACT, except that the extraction is implemented regardless of
whether collision occurs.
NONE
makes no attempt to avoid collisions between tick values.
SPLIT
splits the tick value at a split character, which is specified by the
TICKVALUESPLITCHAR= option, only when necessary in order to make the
value fit the available space.
A split does not occur at a split character if a split is not needed at that
location. If the value does not contain any of the specified split characters,
then the value is not split. Values that are not split or that do not fit the
available space even after splitting might overlap the adjoining space.
SPLITALWAYS
always splits the axis tick value at every occurrence of a split character that
is specified by the TICKVALUESPLITCHAR= option.
1156 Chapter 8 / Axis Options in Layouts
SPLITALWAYSTHIN
same as SPLITALWAYS, except that thinning is performed when long words
do not fit the available space.
SPLITTHIN
same as SPLIT, except that thinning is performed when long words do not fit
the available space.
THIN
eliminates alternate tick values.
EXTRACT
displays consecutive integers along the axis instead of the actual tick values
in order to represent those tick values.
EXTRACTALWAYS
same as EXTRACT, except that the extraction is implemented regardless of
whether collision occurs.
NONE
makes no attempt to avoid collisions between tick values.
ROTATE
rotates the tick values if a collision occurs.
ROTATEALWAYS
rotates the tick values regardless of whether a collision occurs.
ROTATEALWAYSDROP
attempts the ROTATEALWAYS policy, and then drops the tick values if
collisions still occur.
ROTATETHIN
attempts the ROTATE policy, and then the THIN policy.
SPLIT
splits the tick value at a split character, which is specified by the
TICKVALUESPLITCHAR= option, only when necessary in order to make the
value fit the available space.
A split does not occur at a split character if a split is not needed at that
location. If the value does not contain any of the specified split characters,
then the value is not split. Values that are not split or that do not fit the
available space even after splitting might overlap the adjoining space.
SPLITALWAYS
always splits the axis tick value at every occurrence of a split character that
is specified by the TICKVALUESPLITCHAR= option.
SPLITROTATE
attempts the SPLIT policy, and then the ROTATE policy.
STACKEDALWAYS
always displays the tick values vertically as stacked letters.
STACKEDALWAYSTHIN
always displays the tick values vertically as stacked letters.
Thinning is performed when the tick values do not fit the available space.
STAGGER
alternates the tick values between two rows.
STAGGERROTATE
attempts the STAGGER policy, and then the ROTATE policy.
STAGGERTHIN
attempts the STAGGER policy, and then the THIN policy.
STAGGERTRUNCATE
attempts the STAGGER policy, and then the TRUNCATE policy.
THIN
eliminates alternate tick values.
TRUNCATE
shortens the tick labels that exceed 12 characters to 12 characters.
1158 Chapter 8 / Axis Options in Layouts
TRUNCATEROTATE
attempts the TRUNCATE policy, and then the ROTATE policy.
TRUNCATESTAGGER
attempts the TRUNCATE policy, and then the STAGGER policy.
TRUNCATETHIN
attempts the TRUNCATE policy, and then the THIN policy.
Note A note is written to the SAS log when tick value thinning occurs.
TICKVALUEFORMAT=format
specifies how to format the values for major tick marks.
Interaction This option is ignored when the axis tick values are extracted to an
axis legend. See TICKVALUEFITPOLICY=EXTRACT |
EXTRACTALWAYS.
Tip Use this option when you want to duplicate tick values on an axis.
TICKVALUELIST=(string-list)
specifies the list of tick values that are to be displayed on the axis.
string-list
a space-separated list of values, enclosed in parentheses.
Only the tick values that are included in the string list are displayed on the axis.
The values are displayed in the order in which they are listed. The data values
that are not in the list are dropped. The list can be a subset of the data values. It
can also contain values that are not included in the actual data. A tick value that
is not included in the data appears on the axis, but no data is represented at its
tick mark.
Notes If the string list contains duplicate values, then the first
occurrence of the duplicated value in the list is honored and the
remaining instances are ignored.
When the values specified in the list are compared with the actual
data values, leading blanks are honored and trailing blanks are
ignored.
Tips You can use this option to subset the axis values or to display the
values in a specific order.
You can use this option to display values on the axis that are not
contained in the data.
Examples The following example specifies the axis tick values Sedan,
Sports, Wagon, and SUV:
tickvaluelist=("Sedan" "Sports" "Wagon" "SUV")
The following example specifies the axis tick values 10, 20, 30,
and 40:
tickvaluelist=("10" "20" "30" "40")
DIAGONAL
rotates the tick values to a 45-degree diagonal position.
The X labels read left to right in a downward direction. The X2 labels read
left to right in an upward direction.
DIAGONAL2
rotates the tick values to a –45-degree diagonal position.
The X labels read left to right in an upward direction. The X2 labels read left
to right in a downward direction.
VERTICAL
rotates the labels to a 90-degree vertical position.
Default DIAGONAL
TICKVALUESPLITCHAR="character-list"
specifies a list of characters on which the tick values can be split, if needed.
When multiple characters are specified, each character in the list is treated as a
separate split character unless the specified characters appear consecutively in
1160 Chapter 8 / Axis Options in Layouts
the tick value. In that case, all of the specified split characters together are
treated as a single split character.
When a tick value collision is detected, the tick value is split at each occurrence
of any of the characters in the character list or all. If all of the split characters
occur consecutively in the tick value, then they are treated as a single split
character. If the tick value does not contain any of the specified characters, then
the value is not split.
"character-list"
one or more characters with no delimiter between each character.
TICKVALUESPLITCHARDROP=TRUE | FALSE
specifies whether the split characters should be included in the displayed tick
values. The split characters are specified by the TICKVALUESPLITCHAR=
option.
TRUE
drops the split characters from the tick value display.
Row and Column Axis Options for LAYOUT LATTICE 1161
FALSE
includes the split characters in the tick value display.
The fit policy determines how the characters are displayed. If the display
policy is SPLIT or SPLITTHIN and TICKVALUESPLITCHARDROP=FALSE,
then each tick value is split at a split character only where a split is
necessary in order to make the value fit the available space. A split might not
occur at every split character in the tick value. At each split point, the split
character remains as the last character in the current line. The characters
that follow the split character, up to and including the split character at the
next split point, are then wrapped to the following line. This process repeats
until the entire data tick value is displayed. The following figure shows an
example in which TICKVALUESPLITCHARDROP=FALSE and three-word,
asterisk-delimited tick values are split on the asterisk character by using the
SPLIT policy.
Notice that a split occurs on the first asterisk and not at the second. In this
case, a split is not needed at the second asterisk.
Notice that a split occurs after each asterisk and each asterisk appears at
the end of the line. In this case, three lines are displayed.
Default TRUE
1162 Chapter 8 / Axis Options in Layouts
See “boolean ” on page xii for other Boolean values that you can use.
INTEGER=TRUE | FALSE
specifies that evenly spaced integer values are used for tick marks.
Default FALSE
Note This option is ignored when the data exceeds the limits of integer
values.
See “boolean ” on page xii for other Boolean values that you can use.
MINORGRID=TRUE | FALSE
specifies whether grid lines are displayed at the minor tick marks.
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tips The GRIDATTRS= option does not affect the appearance of the
minor grid lines. To control the minor grid line appearance, use the
MINORGRIDATTRS= option.
Use the MINORTICKS= option to display the minor tick marks on the
axis.
See “boolean ” on page xii for other Boolean values that you can use.
The following figure shows the minor grid lines set to light blue, dotted lines on
a linear axis. (See the example.)
Row and Column Axis Options for LAYOUT LATTICE 1165
The following figure shows the minor grid lines set to light blue, dotted lines on
a base-10 log axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a time axis. (See the example.)
Defaults The GraphGridLines style element is used starting with SAS 9.4.
Tip Use the GRIDATTRS= option to control the appearance of the major
grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Example Here is an example that specifies light blue, dotted lines for the
minor grid.
minorgridattrs=(color=lightblue pattern=dot);
MINORTICKCOUNT=positive-integer
specifies the number of minor ticks that are displayed on the axis.
Defaults Four ticks with five intervals in SAS 9.4M1 and earlier releases.
MINORTICKS=TRUE | FALSE
specifies whether minor ticks are displayed. When MINORTICKS=TRUE, the
minor tick marks are displayed on the axis as shown in the following figure.
1166 Chapter 8 / Axis Options in Layouts
Default FALSE
Tip Use the MINORGRID= option to display grid lines at the minor tick
values.
See “boolean ” on page xii for other Boolean values that you can use.
THRESHOLDMAX=number
specifies a bias for including one more tick mark at the maximum end of the
axis.
Default 0.30
Range 0–1
Tips If the threshold is set to 0, the potential tick mark is never displayed.
If the threshold is set to 1, then the tick mark is always displayed.
THRESHOLDMIN=number
specifies a bias for including one more tick mark at the minimum end of the axis.
Default 0.30
Range 0–1
Tips If the threshold is set to 0, the potential tick mark is never displayed.
If the threshold is set to 1, then the tick mark is always displayed.
TICKDISPLAYLIST=(string-list)
specifies the text that is displayed for the tick values that are defined in the
TICKVALUELIST= option. The string list is a space-separated list of string
values that are displayed on the axis in place of the values in the
TICKVALUELIST= option. The strings map one-to-one positionally with the
values that are listed in the TICKVALUELIST= option.
Tip This option should be used with the TICKVALUELIST= option. The
number of items in the list for this option should equal the
number of items in the list for the TICKVALUELIST= option.
TICKVALUEFITPOLICY=policy
specifies a policy for avoiding tick value collision on an axis. The effectiveness
of a collision-avoidance policy depends on the number of tick values, their
length, and the length of the axis. Which policies are valid depends on the axis
on which this option is used.
NONE
makes no attempt to avoid collisions between tick values.
THIN
eliminates alternate tick values.
NONE
makes no attempt to avoid collisions between tick values.
ROTATE
rotates the tick values if a collision occurs.
ROTATEALWAYS
rotates the tick values regardless of whether a collision occurs.
ROTATETHIN
attempts the ROTATE policy, and then the THIN policy.
STAGGER
alternates the tick values between two rows.
STAGGERROTATE
attempts the STAGGER policy, and then the ROTATE policy.
STAGGERTHIN
attempts the STAGGER policy, and then the THIN policy.
THIN
eliminates alternate tick values.
Default THIN
Note A note is written to the SAS log when tick value thinning occurs.
(format-options)
specifies one or more formatting options for major tick values.
MAXWIDTH=integer
specifies the maximum width for displayed tick values.
Default 8
MAXDECIMALS=integer
specifies the maximum number of decimals for displayed tick values.
Default 6
Row and Column Axis Options for LAYOUT LATTICE 1169
PREFERREDDECIMALS=integer
specifies the number of decimal places that you want to display for most
values.
Default 2
EXTRACTSCALE=TRUE | FALSE
specifies whether to extract a scale factor from the tick values and use it
to reduce the tick value width.
For long axis labels, if the scale does not fit the available space, then the
label is truncated, and the scale is appended to the truncated label.
Ellipses indicate that the label was truncated, as shown in the following
example.
Total Sales for the Fourth Quarter Of ... (millions)
In extreme cases in which the scale does not fit even with truncation, the
entire axis is dropped.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can
use.
EXTRACTSCALETYPE=DEFAULT | SCIENTIFIC
specifies whether to extract a named scale or a scientific-notation scale.
DEFAULT
extracts a named scale.
1170 Chapter 8 / Axis Options in Layouts
SCIENTIFIC
extracts a scientific-notation scale.
Default DEFAULT
Restriction The scale is derived from the English locale for all locales.
DATA
uses the format that has been assigned to the column that is contributing to
the axis (or BEST6 if no format is assigned) in order to control the formatting
of the major tick values.
format
specifies a format to apply to the major tick values.
Restriction GTL currently honors most, but not every, SAS format. For
details, see Appendix 4, “Format Support in ODS Graphics,” on
page 1621 .
TICKVALUELIST=(numeric-list)
specifies the tick values for a linear axis as a list.
The VIEWMIN= and VIEWMAX= options alter the axis data range.
If the VIEWMIN= option is set to the minimum tick list value and
the VIEWMAX= option is set to the maximum tick list value, then
all ticks in the tick list are displayed. This might result in some data
not being displayed. For example, data might not be displayed
when the VIEWMIN= value is greater than the actual data
minimum, or when the VIEWMAX= value is less than actual data
maximum.
Tip The values in the list are formatted according to the setting for the
TICKVALUEFORMAT= option.
TICKVALUEPRIORITY=TRUE | FALSE
specifies whether an axis tick specification (TICKVALUELIST= or
TICKVALUESEQUENCE=) can extend the axis data range.
TRUE
extends the axis data range (but does not reduce it) to include the minimum
and maximum values that are specified by either the TICKVALUELIST= or
TICKVALUESEQUENCE= option.
If the minimum and maximum of the user-specified values are within the
data range, this option has no effect.
FALSE
displays only the tick values that are specified by the TICKVALUELIST=
option that fall within the explicit data range set by the VIEWMIN= and
VIEWMAX= options or by the implicit data range set by the actual data
minimum and data maximum.
Default FALSE
Interactions When this option is set to TRUE, the VIEWMIN= and VIEWMAX=
options are ignored.
Note If the minimum and maximum of the specified values are within the
data range, then this option has no effect.
See “boolean ” on page xii for other Boolean values that you can use.
DIAGONAL
rotates the tick values to a 45-degree diagonal position.
The X labels read left to right in a downward direction. The X2 labels read
left to right in an upward direction.
DIAGONAL2
rotates the tick values to a –45-degree diagonal position.
The X labels read left to right in an upward direction. The X2 labels read left
to right in a downward direction.
VERTICAL
rotates the labels to a 90-degree vertical position.
Default DIAGONAL
START=number
specifies the value for the first tick mark.
END=number
specifies the value for the last tick mark.
INCREMENT=number
specifies the increment for intermediate tick marks between the first and
last tick marks.
Row and Column Axis Options for LAYOUT LATTICE 1173
The END value always controls the last tick mark. The interval between the
last tick mark and the previous tick mark might not necessarily be the
INCREMENT value.
The VIEWMIN= and VIEWMAX= options alter the axis data range.
If the VIEWMIN= option is set to the START= option value and the
VIEWMAX= option is set to the END= option value, then all ticks in
the tick sequence are displayed.
Tip The values in the sequence are formatted according to the setting
for the TICKVALUEFORMAT= option.
VIEWMAX=number
specifies the maximum data value to include in the display. The value might be
adjusted by the threshold calculation.
Default The maximum value in the data for the specified axis.
Interactions This option does not determine the maximum axis tick value that
is displayed. The THRESHOLDMAX= value is used to determine
the maximum tick value.
The maximum axis tick value might differ from the VIEWMAX=
value. The VIEWMIN= and VIEWMAX= values, and additional
1174 Chapter 8 / Axis Options in Layouts
Tip To display the VIEWMAX= value as the maximum tick value, use
the TICKVALUELIST= option.
VIEWMIN=number
specifies the minimum data value to include in the display. The value might be
adjusted by the threshold calculation.
Default The minimum value in the data for the specified axis.
Interactions This option does not determine the minimum axis tick value that
is displayed. The THRESHOLDMIN= value is used to determine
the minimum tick value.
The minimum axis tick value might differ from the VIEWMIN=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMIN= value as the minimum tick value, use
the TICKVALUELIST= option.
BASE=10 | 2 | E
specifies the base of the logarithmic scale for the axis values.
Default 10
MINORGRID=TRUE | FALSE
specifies whether grid lines are displayed at the minor tick marks.
1176 Chapter 8 / Axis Options in Layouts
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tips The GRIDATTRS= option does not affect the appearance of the
minor grid lines. To control the minor grid line appearance, use the
MINORGRIDATTRS= option.
Use the MINORTICKS= option to display the minor tick marks on the
axis.
See “boolean ” on page xii for other Boolean values that you can use.
The following figure shows the minor grid lines set to light blue, dotted lines on
a linear axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a base-10 log axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a time axis. (See the example.)
Defaults The GraphGridLines style element is used starting with SAS 9.4.
Tip Use the GRIDATTRS= option to control the appearance of the major
grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Example Here is an example that specifies light blue, dotted lines for the
minor grid.
minorgridattrs=(color=lightblue pattern=dot);
MINORTICKCOUNT=positive-integer
specifies the number of minor ticks that are displayed on the axis.
MINORTICKS=TRUE | FALSE
specifies whether minor ticks are displayed. When MINORTICKS=TRUE, the
minor tick marks are displayed on the axis as shown in the following figure.
Default FALSE
Requirement If you set this option to TRUE, you must also specify a value for
MINORTICKCOUNT=. Otherwise, minor tick marks do not appear
on the log axis.
1178 Chapter 8 / Axis Options in Layouts
Tip Use the MINORGRID= option to display grid lines at the minor tick
values.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
selects a LOGEXPAND, LOGEXPONENT, or LINEAR representation
automatically based on the range of the data.
LOGEXPAND
places the major tick marks at uniform intervals at integer powers of the
base.
Base=10
Base=2
Base=E
LOGEXPONENT
places the major tick marks at uniform intervals at integer powers of the
base.
The tick values are only the integer exponents for all bases.
LINEAR
places the major tick marks at non-uniform intervals that cover the range of
the data.
Default AUTO
Row and Column Axis Options for LAYOUT LATTICE 1179
GTL currently honors most but not every SAS format. For details,
see Appendix 4, “Format Support in ODS Graphics,” on page 1621.
TICKVALUEFORMAT=DATA | format
specifies how to format the values for major tick marks.
DATA
uses the format that has been assigned to the column that is contributing to
the axis (or BEST6 if no format is assigned) in order to control the formatting
of the major tick values.
format
specifies a format to apply to the major tick values.
Restriction GTL currently honors most, but not every, SAS format. For
details, see Appendix 4, “Format Support in ODS Graphics,” on
page 1621.
See BASE=
TICKINTERVALSTYLE=
1180 Chapter 8 / Axis Options in Layouts
TICKVALUELIST=(numeric-list)
specifies the tick values for a linear axis as a list.
Default Only the tick values specified in the list that fall within the
explicit data range set by the VIEWMIN= and VIEWMAX= options
or by the implicit data range set by the actual data minimum and
data maximum are displayed. An internal algorithm determines
the tick marks.
Interactions The VALUESTYPE= option determines how the values in the list
are interpreted.
The VIEWMIN= and VIEWMAX= options alter the axis data range.
If the VIEWMIN= option is set to the minimum tick list value and
the VIEWMAX= option is set to the maximum tick list value, then
all ticks in the tick list are displayed. This might result in some
data not being displayed. For example, data might not be
displayed when the VIEWMIN= value is greater than the actual
data minimum, or when the VIEWMAX= value is less than actual
data maximum.
TICKVALUEPRIORITY=TRUE | FALSE
specifies whether the TICKVALUELIST= specification can extend the axis data
range.
TRUE
extends the axis data range (but does not reduce it) to include the minimum
and maximum values that are specified by the TICKVALUELIST= option.
If the minimum and maximum of the user-specified values are within the
data range, this option has no effect.
FALSE
displays only the tick values that are specified by the TICKVALUELIST=
option that fall within the explicit data range set by the VIEWMIN= and
VIEWMAX= options or by the implicit data range set by the actual data
minimum and data maximum.
Default FALSE
Interactions When this option is set to TRUE, the VIEWMIN= and VIEWMAX=
options are ignored.
Note If the minimum and maximum of the specified values are within the
data range, then this option has no effect.
See “boolean ” on page xii for other Boolean values that you can use.
VALUESTYPE=EXPANDED | EXPONENT
specifies the scale that the system uses when interpreting the
TICKVALUELIST=, VIEWMAX=, and VIEWMIN= option values. Use this option
to choose your preferred way of specifying log-axis values.
EXPANDED
values are interpreted as powers of the base such as 0.1, 1, 10, 100, and so on,
for base 10, for example.
EXPONENT
values are interpreted as integer exponents of the base such as 1, 2, 3, and so
on, for base 10, base 2, and base E.
Default EXPANDED
Note This option does not change the style of the tick values that are
displayed on the axis. It changes only how the VIEWMIN=,
VIEWMAX=, and TICKVALUELIST= option values are interpreted by
the system.
10 log axis. This results in X-axis tick values of 10, 100, 1000, 10000,
and 100000.
xaxisopts=(type=log
logopts=(base=10
tickintervalstyle=logexpand
valuestype=exponent
viewmin=1 viewmax=5));
VIEWMAX=number
specifies the maximum data value to include in the display.
Default The maximum value in the data for the specified axis.
The maximum axis tick value might differ from the VIEWMAX=
value. The VIEWMIN= and VIEWMAX= values, and additional
Row and Column Axis Options for LAYOUT LATTICE 1183
Tip To display the VIEWMAX= value as the maximum tick value, use
the TICKVALUELIST= option.
VIEWMIN=number
specifies the minimum data value to include in the display.
Default The minimum value in the data for the specified axis.
The minimum axis tick value might differ from the VIEWMIN=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
1184 Chapter 8 / Axis Options in Layouts
Tip To display the VIEWMIN= value as the minimum tick value, use
the TICKVALUELIST= option.
Default AUTO. An appropriate interval is chosen based on the data and the
column date, date-time, or time format.
Requirement The data column(s) mapped to a time axis must be in the same
duration units: TIME, DATE, or DATETIME. The selection of an
interval must be consistent with the duration unit. For example, if
the data are in time units, you can specify only AUTO, SECOND,
MINUTE, HOUR.
INTERVALMULTIPLIER=positive-integer
specifies a multiplier to apply to the time interval that is in effect for the axis.
Default 1
MINORGRID=TRUE | FALSE
specifies whether grid lines are displayed at the minor tick marks.
Row and Column Axis Options for LAYOUT LATTICE 1187
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tips The GRIDATTRS= option does not affect the appearance of the
minor grid lines. To control the minor grid line appearance, use the
MINORGRIDATTRS= option.
Use the MINORTICKS= option to display the minor tick marks on the
axis.
See “boolean ” on page xii for other Boolean values that you can use.
The following figure shows the minor grid lines set to light blue, dotted lines on
a linear axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a base-10 log axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a time axis. (See the example.)
Defaults The GraphGridLines style element is used starting with SAS 9.4.
Tip Use the GRIDATTRS= option to control the appearance of the major
grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Example Here is an example that specifies light blue, dotted lines for the
minor grid.
minorgridattrs=(color=lightblue pattern=dot);
MINORTICKINTERVAL=interval
specifies the time interval between minor ticks. See Table 8.12 on page 1185 for
information about the intervals that you can select. The interval that you select
must be consistent with the axis data duration units such as TIME, DATE, or
DATETIME. For example, if the axis data is in TIME units, then you must specify
AUTO, SECOND, MINUTE, or HOUR.
Default AUTO
MINORTICKS=TRUE | FALSE
specifies whether minor ticks are displayed. When MINORTICKS=TRUE, the
minor tick marks are displayed on the axis as shown in the following figure.
Default FALSE
Tip Use the MINORGRID= option to display grid lines at the minor tick
values.
See “boolean ” on page xii for other Boolean values that you can use.
SPLITTICKVALUE=TRUE | FALSE
specifies whether to split the tick values on an X or X2 axis, if possible. This
option is not available for a Y or Y2 axis.
TRUE
splits the axis tick values into two lines allowing more tick values to appear.
For example, with INTERVAL= MONTH, this is how tick values are split:
FALSE
does not split the axis tick values.
For example, when this option specifies FALSE, this is how the tick values in
the previous example appear:
Typically, fewer tick values fit, causing thinning, rotation, or staggering of the
values. See the TICKVALUEFITPOLICY= option.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
TICKVALUEFITPOLICY=policy
specifies a policy for avoiding tick value collision on an X or X2 axis. This option
is not available for the X and X2 axes. The effectiveness of a collision-avoidance
policy depends on the number of tick values, their length, and the length of the
axis. The following policies are valid for the X and X2 axes:
NONE
makes no attempt to avoid collisions between tick values.
ROTATE
rotates the tick values if a collision occurs.
ROTATEALWAYS
rotates the tick values regardless of whether a collision occurs.
ROTATETHIN
attempts the ROTATE policy, and then the THIN policy.
STAGGER
alternates the tick values between two rows.
STAGGERROTATE
attempts the STAGGER policy, and then the ROTATE policy.
STAGGERTHIN
attempts the STAGGER policy, and then the THIN policy.
THIN
eliminates alternate tick values.
Default THIN
Note A note is written to the SAS log when tick value thinning occurs.
TICKVALUEFORMAT=format | DATA
specifies how to format the values for major tick marks.
format
specifies a SAS date, time, or datetime format to control how the major tick
values are displayed.
This format must be in the same duration units as the data column(s)
mapped to a time axis: TIME, DATE, or DATETIME and should be appropriate
for the value of the INTERVAL= option. For example, if INTERVAL=MONTH
and there are two years of data displayed on the axis, then choosing
TICKVALUEFORMAT=YEAR. would result in several ticks having the same
year value.
DATA
specifies that the SAS date, time, or datetime format associated with the
data column assigned to the axis be used to control how the major tick
values are displayed.
Default The default format used by the INTERVAL= option. The default
does not apply if TICKVALUELIST= is specified.
GTL currently honors most but not every SAS format. For details,
see Appendix 4, “Format Support in ODS Graphics,” on page 1621.
Row and Column Axis Options for LAYOUT LATTICE 1191
Interactions The values in the list are formatted according to the format
specified on the TICKVALUEFORMAT= option. If
TICKVALUEFORMAT= is not used, then the values are formatted
according to the column format (the default TICKVALUEFORMAT
value is not applied to these values).
TICKVALUEPRIORITY=TRUE | FALSE
specifies whether the TICKVALUELIST= specification can extend the axis data
range.
TRUE
extends the axis data range (but does not reduce it) to include the minimum
and maximum values that are specified by the TICKVALUELIST= option.
If the minimum and maximum of the user-specified values are within the
data range, this option has no effect.
FALSE
displays only the tick values that are specified by the TICKVALUELIST=
option that fall within the explicit data range set by the VIEWMIN= and
VIEWMAX= options or by the implicit data range set by the actual data
minimum and data maximum.
Default FALSE
Interactions When this option is set to TRUE, the VIEWMIN= and VIEWMAX=
options are ignored.
1192 Chapter 8 / Axis Options in Layouts
Note If the minimum and maximum of the specified values are within the
data range, then this option has no effect.
See “boolean ” on page xii for other Boolean values that you can use.
DIAGONAL
rotates the tick values to a 45-degree diagonal position.
The X labels read left to right in a downward direction. The X2 labels read
left to right in an upward direction.
DIAGONAL2
rotates the tick values to a –45-degree diagonal position.
The X labels read left to right in an upward direction. The X2 labels read left
to right in a downward direction.
VERTICAL
rotates the labels to a 90-degree vertical position.
Default DIAGONAL
VIEWMAX=number
specifies the maximum data value to include in the display.
Default The maximum value in the data for the specified axis.
The maximum axis tick value might differ from the VIEWMAX=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMAX= value as the maximum tick value, use
the TICKVALUELIST= option.
VIEWMIN=number
specifies the minimum data value to include in the display.
Default The minimum value in the data for the specified axis.
The minimum axis tick value might differ from the VIEWMIN=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMIN= value as the minimum tick value, use
the TICKVALUELIST= option.
Details
The LAYOUT LATTICE statement creates a grid of graphs that automatically aligns
plot areas, data display areas, axis labels, and headers across the columns and rows
of the layout. The axis data ranges can be scaled, and the axes for individual cells in
the layout can be managed by row and by column using COLUMNAXIS and
ROWAXIS statements. COLUMNAXIS statements are used within a COLUMNAXES
or COLUMN2AXES block to externalize column axes for the layout. Similarly,
ROWAXIS statements are used within a ROWAXES or ROW2AXES block to
externalize row axes for the layout. Each axis block is used to manage the primary
axis. The axis that is considered primary depends on the settings for the XAXIS=
and YAXIS= options in plot statements that are specified within the layout:
1194 Chapter 8 / Axis Options in Layouts
In addition to managing the primary axes, you can also display “secondary” axes in
the grid. A secondary axis is not an independent axis. Rather, it mirrors the primary
axis, but it is displayed on the opposite side and can have different display options.
For example, when the X axis (bottom) is primary, you can mirror that axis with a
secondary X axis at the top of the grid. Similarly, when the Y2 axis (right) is primary,
you can mirror that axis with a secondary Y2 axis on the left of the grid. A
secondary axis makes it easier to interpolate values in the cells that are farthest
away from the primary axis. To display a secondary axis, use the
DISPLAYSECONDARY= option.
For general information about managing primary and secondary axes, see “Plot
Data Are Mapped to a Designated Axis” on page 1040. For details about managing
the axes within a LAYOUT LATTICE, see the discussion about the LAYOUT
LATTICE “Row and Column Axis Statements” on page 146.
The following example shows COLUMNAXIS statements for a lattice with two
columns:
layout lattice / columns=2 columndatarange=union;
columnaxes;
columnaxis / griddisplay=on displaysecondary=(ticks tickvalues);
columnaxis / griddisplay=on displaysecondary=(ticks tickvalues);
Row and Column Axis Options for LAYOUT LATTICE 1195
endcolumnaxes;
endlayout;
In the default cases for each plot in the layout, the axis type is always DISCRETE,
LINEAR, or TIME. The TYPE= option enables you to specify an axis type that
overrides the default. For example, when appropriate for the data, you can request
a LOG axis. When you override the default axis type, you must be sure to specify
the correct axis type for the plot(s) that you are defining.
Each axis type has features specific to that type, and the following axis options
enable you to specify features for the different types: DISCRETEOPTS= ,
LINEAROPTS= , LOGOPTS= , and TIMEOPTS= . One or more of these options can
be specified for an axis, but the specified settings are applied only to the axis type
that supports them.
The following graph was generated by the “Example Program” on page 1196 :
Example Program
proc template;
define statgraph y2axis;
begingraph;
layout lattice / columns=2 columngutter=10
rowdatarange=union row2datarange=union ;
rowaxes;
rowaxis / griddisplay=on;
endrowaxes;
row2axes;
rowaxis;
endrow2axes;
layout overlay;
histogram height / scale=count yaxis=y2 ;
histogram height / scale=percent yaxis=y ;
densityplot height / normal();
endlayout;
layout overlay;
histogram weight / scale=count yaxis=y2 ;
histogram weight / scale=percent yaxis=y ;
densityplot weight / normal();
endlayout;
endlayout;
endgraph;
Axis Options for LAYOUT OVERLAYEQUATED 1197
end;
Interaction: The OVERLAYEQUATED’s axis options are ignored when the LAYOUT
OVERLAYEQUATED statement is nested within another layout type that has
external axes in effect. For example, the axis options are ignored when the
statement is nested within a LAYOUT LATTICE with a COLUMNAXIS= or
ROWAXIS= option in effect.
See: “LAYOUT OVERLAYEQUATED Statement” on page 168
Syntax
Axis options for the plots within an OVERLAYEQUATED layout are specified with
the
following options on a LAYOUT OVERLAYEQUATED statement:
COMMONAXISOPTS=(common-equated-axis-options)
XAXISOPTS=(equated-axis-options)
YAXISOPTS=(equated-axis-options)
INTEGER=TRUE | FALSE
specifies that evenly spaced integer values are used for tick marks.
Default FALSE
Note This option is ignored when the data exceeds the limits of integer
values.
See “boolean ” on page xii for other Boolean values that you can use.
OUTSIDE
displays tick marks outside of the axis frame.
Axis Options for LAYOUT OVERLAYEQUATED 1199
INSIDE
displays tick marks inside the axis frame.
ACROSS
displays tick marks across the axis line.
Restriction This option applies to the major tick marks only. It does not affect
the minor tick marks.
Note This option has no effect on the placement of the tick values, which
are always outside the axis frame.
Tip You can use the Annotate facility to draw inside or across minor tick
marks in your graphs. See “Creating a Macro That Generates
Annotation Data” in SAS Graph Template Language: User’s Guide.
TICKVALUELIST=(numeric-list)
specifies the tick values for a linear axis as a list.
The VIEWMIN= and VIEWMAX= options alter the axis data range.
If the VIEWMIN= option is set to the minimum tick list value and
the VIEWMAX= option is set to the maximum tick list value, then
all ticks in the tick list are displayed. This might result in some data
not being displayed. For example, data might not be displayed
when the VIEWMIN= value is greater than the actual data
minimum, or when the VIEWMAX= value is less than actual data
maximum.
Tip The values in the list are formatted according to the setting for the
TICKVALUEFORMAT= option.
TICKVALUEPRIORITY=TRUE | FALSE
specifies whether an axis tick specification (TICKVALUELIST= or
TICKVALUESEQUENCE=) can extend the axis data range.
TRUE
extends the axis data range (but does not reduce it) to include the minimum
and maximum values that are specified by either the TICKVALUELIST= or
TICKVALUESEQUENCE= option.
If the minimum and maximum of the user-specified values are within the
data range, this option has no effect.
FALSE
displays only the tick values that are specified by the TICKVALUELIST=
option that fall within the explicit data range set by the VIEWMIN= and
VIEWMAX= options or by the implicit data range set by the actual data
minimum and data maximum.
Default FALSE
Interactions When this option is set to TRUE, the VIEWMIN= and VIEWMAX=
options are ignored.
Notes If the minimum and maximum of the specified values are within the
data range, then this option has no effect.
See “boolean ” on page xii for other Boolean values that you can use.
START=number
specifies the value for the first tick mark.
END=number
specifies the value for the last tick mark.
INCREMENT=number
specifies the increment for intermediate tick marks between the first and
last tick marks.
The END value always controls the last tick mark. The interval between the
last tick mark and the previous tick mark might not necessarily be the
INCREMENT value.
The VIEWMIN= and VIEWMAX= options alter the axis data range.
If the VIEWMIN= option is set to the START= option value and the
VIEWMAX= option is set to the END= option value, then all ticks in
the tick sequence are displayed.
Tip The values in the sequence are formatted according to the setting
for the TICKVALUEFORMAT= option.
1202 Chapter 8 / Axis Options in Layouts
VIEWMAX=number
specifies the maximum data value to include in the display on the X and Y axes
when the axis lengths and major tick values are equal. The value might be
adjusted by the threshold calculation.
Default The maximum value in the data for the X and Y axes.
Interactions This option does not determine the maximum axis tick value that
is displayed. The THRESHOLDMAX= value is used to determine
the maximum tick value.
The maximum axis tick value might differ from the VIEWMAX=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMAX= value as the maximum tick value, use
the TICKVALUELIST= option.
VIEWMIN=number
specifies the minimum data value to include in the display on the X and Y axes
when the axis lengths and major tick values are equal. The value might be
adjusted by the threshold calculation.
Default The minimum value in the data for the X and Y axes.
Interactions This option does not determine the minimum axis tick value that
is displayed. The THRESHOLDMIN= value is used to determine
the minimum tick value.
The minimum axis tick value might differ from the VIEWMIN=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMIN= value as the minimum tick value, use
the TICKVALUELIST= option.
LABELFITPOLICY on page 1208 Specifies a policy for fitting axis labels in the
available space.
STANDARD
specifies that the LABEL, LINE, TICKS, and TICKVALUES are displayed
Axis Options for LAYOUT OVERLAYEQUATED 1205
ALL
currently the same as STANDARD
NONE
specifies that no axis features are displayed
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
LABEL
displays the axis label
LINE
displays the axis line
TICKS
displays the tick marks
TICKVALUES
displays the values that are represented by the major tick marks
Default STANDARD
Tips The default line attributes for the axis line and axis tick marks are
defined in the GraphAxisLine style element.
Use the GRIDDISPLAY= and GRIDATTRS= options to set the axis grid
lines.
When LINE is excluded from the DISPLAY= option, the layout wall
outline or the default baseline of a bar chart, needle plot, or waterfall
chart can appear to be an axis line. To suppress the wall outline, use the
WALLDISPLAY= option in the layout statement. To suppress the plot
baseline, use the BASELINEATTRS= option in the plot statement.
NONE
specifies that no axis features are displayed
STANDARD
specifies that the LABEL, LINE, TICKS, and TICKVALUES are displayed on
the secondary axis
ALL
currently the same as STANDARD
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
LABEL
displays the axis label
LINE
displays the axis line
TICKS
displays the tick marks
TICKVALUES
displays the values that are represented by the major tick marks
Default NONE
Tip Use the GRIDDISPLAY= and GRIDATTRS= options to set the axis grid
lines.
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO_OFF
specifies that grid lines are not displayed unless the GraphGridLines element
in the current style contains DisplayOpts="ON."
AUTO_ON
specifies that grid lines are displayed unless the GraphGridLines element in
the current style contains DisplayOpts="OFF."
ON
specifies that grid lines are always displayed.
OFF
specifies that grid lines are never displayed.
The following table shows the end results for various combinations of the
GRIDDISPLAY= option and the DisplayOpts= attribute of the GraphGridLines
style element. Most supplied templates use the default setting AUTO_OFF to
indicate a preference for not displaying grid lines, but allowing the style to
override.
Axis Options for LAYOUT OVERLAYEQUATED 1207
DisplayOpts= style
GRIDDISPLAY= option attribute Grid Lines Shown?
AUTO_OFF AUTO no
AUTO_OFF ON yes
AUTO_OFF OFF no
AUTO_ON ON yes
AUTO_ON OFF no
Default AUTO_OFF
Note Supplied styles use DisplayOpts="AUTO," which means that the style
has no preference about grid lines and the graphics template setting for
grid lines is always used.
Default The default label is derived from the primary plot in the layout. For
more information, see “When Plots Share Data and a Common Axis” on
page 1046.
Note If the axis label is too long to fit along the axis, then it is truncated by
default.
See “Overriding the Default Axis Label” in SAS Graph Template Language:
User’s Guide
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO
uses the short label, when specified, instead of the original label.
If the short label does not fit, then it is clipped. When no short label is
specified, the original label is clipped.
SPLIT
splits the axis label at a split character only when necessary in order to make
the label fit the available space.
SPLITALWAYS
always split the axis label at every occurrence of a split character, which is
specified by the LABELSPLITCHAR= option.
STACKED
displays the Y or Y2 axis label vertically as stacked letters.
Default AUTO
LABELSPLITCHAR="character-list"
specifies one or more characters on which the axis labels can be split, if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the axis label. In that case, all of the specified split characters
together are treated as a single split character.
When LABELFITPOLICY=SPLIT, if the axis label does not fit the available
space, then it is split on a specified split character only if a split is needed at
that point to make the label fit. In this case, a split might not occur on every
Axis Options for LAYOUT OVERLAYEQUATED 1209
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
LABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the displayed axis labels.
TRUE
drops the split characters from the axis label display.
FALSE
includes the split characters in the axis label display.
Default TRUE. The split characters are dropped from the axis label.
See “boolean ” on page xii for other Boolean values that you can use.
FULL
specifies an axis line that extends along the entire length of the axis.
DATA
specifies an axis line that extends through the data range from the minimum
offset to the maximum offset.
number
specifies how much the axis line extends from DATA toward FULL as a
decimal proportion. A value of 0 is equivalent to DATA, and a value of 1 is
equivalent to FULL.
Range 0–1
Tip A numeric value is useful for bar charts when DATA terminates the
axis line at the midpoint positions of the minimum and maximum
bars. In that case, you can specify a numeric value to lengthen the
axis line so that it extends to the full width of both bars.
The following figure shows a simple example of each value for the X axis and Y-
axis lines. The light-blue dashed lines depict the minimum and maximum offsets
that are set on the axes.
Default FULL
Tip The graph wall outline might appear to be an axis line. In that case,
use the WALLDISPLAY=NONE or WALLDISPLAY=(FILL) option in
the layout statement to suppress the wall outline.
AUTO
reserves just enough area to fully display markers and other graphical
features near the maximum end of an axis.
AUTOCOMPRESS
applies an automatic offset that prevents axis labels and tick values from
extending beyond the axis length.
number
specifies the offset as a decimal proportion of the full axis length.
Default AUTO
Range 0–1. The sum of OFFSETMAX= and OFFSETMIN= should not be more
than 1.
AUTO
reserves just enough area to fully display markers and other graphical
features near the maximum end of an axis.
AUTOCOMPRESS
applies an automatic offset that prevents axis labels and tick values from
extending beyond the axis length.
number
specifies the offset as a decimal proportion of the full axis length.
Default AUTO
Range 0–1. The sum of OFFSETMAX= and OFFSETMIN= should not be more
than 1.
REVERSE=TRUE | FALSE
specifies whether tick values should appear in the reverse order.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
SHORTLABEL="string"
specifies an alternate axis label to display when the default label or the label
specified by the LABEL= option is too long to fit the available space.
Note If the specified label is itself too long for the axis, it is truncated in
the display.
1212 Chapter 8 / Axis Options in Layouts
THRESHOLDMAX=number
specifies a bias for including one more tick mark at the maximum end of the
axis.
Default 0.30
Range 0–1
Tips If the threshold is set to 0, the potential tick mark is never displayed.
If the threshold is set to 1, then the tick mark is always displayed.
THRESHOLDMIN=number
specifies a bias for including one more tick mark at the minimum end of the axis.
Default 0.30
Range 0–1
Tips If the threshold is set to 0, the potential tick mark is never displayed.
If the threshold is set to 1, then the tick mark is always displayed.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TICKVALUEFITPOLICY=policy
specifies a policy for avoiding tick value collision on an axis. The effectiveness
of a collision-avoidance policy depends on the number of tick values, their
length, and the length of the axis. Which policies are valid depends on the axis
on which this option is used.
NONE
makes no attempt to avoid collisions between tick values.
THIN
eliminates alternate tick values.
NONE
makes no attempt to avoid collisions between tick values.
ROTATE
rotates the tick values if a collision occurs.
ROTATEALWAYS
rotates the tick values regardless of whether a collision occurs.
ROTATETHIN
attempts the ROTATE policy, and then the THIN policy.
STAGGER
alternates the tick values between two rows.
STAGGERROTATE
attempts the STAGGER policy, and then the ROTATE policy.
STAGGERTHIN
attempts the STAGGER policy, and then the THIN policy.
THIN
eliminates alternate tick values.
Default THIN
Note A note is written to the SAS log when tick value thinning occurs.
1214 Chapter 8 / Axis Options in Layouts
(format-options)
specifies one or more formatting options for major tick values.
MAXWIDTH=integer
specifies the maximum width for displayed tick values.
Default 8
MAXDECIMALS=integer
specifies the maximum number of decimals for displayed tick values.
Default 6
PREFERREDDECIMALS=integer
specifies the number of decimal places that you want to display for most
values.
Default 2
EXTRACTSCALE=TRUE | FALSE
specifies whether to extract a scale factor from the tick values and use it
to reduce the tick value width.
For long axis labels, if the scale does not fit the available space, then the
label is truncated, and the scale is appended to the truncated label.
Ellipses indicate that the label was truncated, as shown in the following
example.
Total Sales for the Fourth Quarter Of ... (millions)
In extreme cases in which the scale does not fit even with truncation, the
entire axis is dropped.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can
use.
EXTRACTSCALETYPE=DEFAULT | SCIENTIFIC
specifies whether to extract a named scale or a scientific-notation scale.
DEFAULT
extracts a named scale.
SCIENTIFIC
extracts a scientific-notation scale.
Default DEFAULT
Restriction The scale is derived from the English locale for all locales.
DATA
uses the format that has been assigned to the column that is contributing to
the axis (or BEST6 if no format is assigned) in order to control the formatting
of the major tick values.
format
specifies a format to apply to the major tick values.
Restriction GTL currently honors most, but not every, SAS format. For
details, see Appendix 4, “Format Support in ODS Graphics,” on
page 1621 .
align properly with the axis tick values. In that case, specify a
tick-value format with a higher precision.
VIEWMAX=number
specifies the maximum data value to include in the display on the X or Y axes
when the axis lengths and major tick values are equal. The value might be
adjusted by the threshold calculation.
Default The maximum value in the data for the X and Y axes.
This option does not determine the maximum axis tick value that
is displayed. The THRESHOLDMAX= value is used to determine
the maximum tick value.
The maximum axis tick value might differ from the VIEWMAX=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMAX= value as the maximum tick value, use
the TICKVALUELIST= option.
VIEWMIN=number
specifies the minimum data value to include in the display on the X or Y axes
when the axis lengths and major tick values are equal. The value might be
adjusted by the threshold calculation.
Default The minimum value in the data for the X and Y axes.
This option does not determine the minimum axis tick value that
is displayed. The THRESHOLDMIN= value is used to determine
the minimum tick value.
The minimum axis tick value might differ from the VIEWMIN=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMIN= value as the minimum tick value, use
the TICKVALUELIST= option.
Details
The LAYOUT OVERLAYEQUATED statement is used for equated layouts where the
X and Y axes always have equal increments between tick values. Because the axes
within the equated layout are so closely correlated, some axis adjustments cannot
be applied to one axis without applying them to the other.
For example, the INTEGER= option sets evenly spaced integer values for the axis
tick marks. That setting must be applied to both axes if the correlation between
them is to be maintained. The LAYOUT OVERLAYEQUATED statement provides
the COMMONAXISOPTS= option for specifying the INTEGER= option and other
options whose settings apply in common to both axes.
Despite the close correlation between the axes, some axis adjustments can be
made to one axis without affecting the other. For example, displaying grid lines on
one axis has no impact on the other. The XAXISOPTS= and YAXISOPTS= options
are available for applying settings separately to the X and Y axes.
The following example template sets evenly spaced integer values for the axis tick
marks of both axes. It also specifies the display of grid lines, tick marks, and tick
values for the Y axis:
begingraph;
layout overlayequated /
commonaxisopts=(integer=true);
yaxisopts=(griddisplay=on display=(ticks tickvalues));
seriesplot x=var1 y=var2;
endlayout;
endgraph;
1218 Chapter 8 / Axis Options in Layouts
Syntax
The X and X2 axis options for the plots within DATALATTICE and DATAPANEL
layouts are specified with the following options:
COLUMNAXISOPTS=(axis-options)
COLUMN2AXISOPTS=(axis-options)
The Y and Y2 axis options for the plots within DATALATTICE and DATAPANEL
layouts are specified with the following options:
ROWAXISOPTS=(axis-options)
ROW2AXISOPTS=(axis-options)
STANDARD
specifies that the LABEL, LINE, TICKS, and TICKVALUES are displayed
ALL
currently the same as STANDARD
NONE
specifies that no axis features are displayed
(display-options)
a space-separated list of one or more of the following options enclosed in
parentheses:
LABEL
displays the axis label.
A common label is displayed at the center of the grid, and the label
applies to all the primary axes in the row or column. This label is
overridden by a label specified on the DISPLAY= option.
LINE
displays the axis line.
TICKS
displays the tick marks.
TICKVALUES
displays the values that are represented by the major tick marks.
Tips The default line attributes for the axis line and axis tick marks are
defined in the GraphAxisLine style element.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1221
See “Details” on page 1275 for more information about the primary and
secondary axes.
NONE
specifies that no axis features are displayed
STANDARD
specifies that the LABEL, LINE, TICKS, and TICKVALUES are displayed on
the secondary axis
ALL
currently the same as STANDARD
(display-options)
a space-separated list of one or more of the following options enclosed in
parentheses:
LABEL
displays the axis label.
A common label is displayed at the center of the grid, and the label
applies to all the secondary axes in the row or column. This label is
overridden by a label specified on the DISPLAY= option.
LINE
displays the axis line.
TICKS
displays the tick marks.
TICKVALUES
displays the values that are represented by the major tick marks.
Restriction If some plot statements set XAXIS=X and others set XAXIS=X2,
then both the X and X2 axis are primary and a secondary X axis
cannot be displayed. In that case, this option is ignored. The same
applies for the Y axes.
1222 Chapter 8 / Axis Options in Layouts
Tips The default line attributes for the axis line and axis tick marks are
defined in the GraphAxisLine style element.
See “Details” on page 1275 for more information about the primary and
secondary axes.
DISCRETEOPTS=(discrete-axis-options)
specifies one or more options for a discrete axis. Options must be enclosed in
parentheses. Each option is specified as a name = value pair and each pair is
space separated.
See “Options for Discrete Axes Only” on page 1235 for the options that
you can use for discrete-axis-options.
STANDARD
specifies that the LABEL, LINE, TICKS, and TICKVALUES are displayed
ALL
currently the same as STANDARD
NONE
specifies that no axis features are displayed
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
LABEL
displays the axis label
LINE
displays the axis line
TICKS
displays the tick marks
TICKVALUES
displays the values that are represented by the major tick marks
Default STANDARD
Tips The default line attributes for the axis line and axis tick marks are
defined in the GraphAxisLine style element.
Use the GRIDDISPLAY= and GRIDATTRS= options to set the axis grid
lines.
When LINE is excluded from the DISPLAY= option, the layout wall
outline or the default baseline of a bar chart, needle plot, or waterfall
chart can appear to be an axis line. To suppress the wall outline, use the
WALLDISPLAY= option in the layout statement. To suppress the plot
baseline, use the BASELINEATTRS= option in the plot statement.
See “Details” on page 1275 for more information about the primary and
secondary axes..
NONE
specifies that no axis features are displayed
STANDARD
specifies that the LABEL, LINE, TICKS, and TICKVALUES are displayed on
the secondary axis
ALL
currently the same as STANDARD
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
LABEL
displays the axis label
LINE
displays the axis line
TICKS
displays the tick marks
TICKVALUES
displays the values that are represented by the major tick marks
1224 Chapter 8 / Axis Options in Layouts
Default NONE
Restriction If some plot statements set XAXIS=X and others set XAXIS=X2,
both the X and X2 axis are primary and a secondary X axis cannot be
displayed. In that case, this option is ignored. The same applies for
the Y axes.
Tip Use the GRIDDISPLAY= and GRIDATTRS= options to set the axis
grid lines.
See for more information about the primary and secondary axes.“Details”
on page 1275 .
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tip On a log axis, this option affects the appearance of the major grid
lines only. It does not affect the appearance of the minor grid lines.
To control the appearance of the minor grid lines on a log axis, use
the MINORGRIDATTRS= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO_OFF
specifies that grid lines are not displayed unless the GraphGridLines element
in the current style contains DisplayOpts="ON."
AUTO_ON
specifies that grid lines are displayed unless the GraphGridLines element in
the current style contains DisplayOpts="OFF."
ON
specifies that grid lines are always displayed.
OFF
specifies that grid lines are never displayed.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1225
The following table shows the end results for various combinations of the
GRIDDISPLAY= option and the DisplayOpts= attribute of the GraphGridLines
style element. Most supplied templates use the default setting AUTO_OFF to
indicate a preference for not displaying grid lines, but allowing the style to
override.
DisplayOpts= style
GRIDDISPLAY= option attribute Grid Lines Shown?
AUTO_OFF AUTO no
AUTO_OFF ON yes
AUTO_OFF OFF no
AUTO_ON ON yes
AUTO_ON OFF no
Default AUTO_OFF
Note Supplied styles use DisplayOpts="AUTO," which means that the style
has no preference about grid lines and the graphics template setting for
grid lines is always used.
Default The default label is derived from the primary plot in the layout. For
more information, see “When Plots Share Data and a Common Axis”
on page 1046.
Note If the axis label is too long to fit along the axis, then it is truncated
by default.
See “Overriding the Default Axis Label” in SAS Graph Template Language:
User’s Guide
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
AUTO
uses the short label, when specified, instead of the original label.
If the short label does not fit, then it is clipped. When no short label is
specified, the original label is clipped.
SPLIT
splits the axis label at a split character only when necessary in order to make
the label fit the available space.
SPLITALWAYS
always split the axis label at every occurrence of a split character, which is
specified by the LABELSPLITCHAR= option.
STACKED
displays the Y or Y2 axis label vertically as stacked letters.
Default AUTO
CENTER
centers the axis label in the axis area.
For the Y and Y2 axes, the label is oriented vertically and is centered in the
axis area (including the offsets). The label is positioned to the left of the tick
values for the Y axis or to the right of the axis values for the Y2 axis. For the
X and X2 axes, the label is centered in the axis area (including the offsets). It
is positioned below the tick values for the X axis or above the axis values for
the X2 axis.
DATACENTER
repeats the axis label for each row or column and centers each label in the
axis tick display area of its row or column.
For the Y and Y2 axes, each label is oriented vertically and is centered in the
axis tick display area (excluding the offsets) of its row. The labels are
positioned to the left of the tick values for the Y axis or to the right of the
axis values for the Y2 axis. For the X and X2 axes, each label is centered in
the axis tick display area (excluding the offsets) of its column. The labels are
positioned below the tick values for the X axis or above axis values for the
X2 axis.
TOP
BOTTOM
orients the label horizontally at the top or bottom of the axis area.
The label is right-justified in the axis area for the Y axis and left-justified for
the Y2 axis. If there is not sufficient room in the axis area to display the
label, then the label grows to the right for the Y axis and to the left for the
Y2 axis.
Restriction These options are valid for the Y and Y2 axes only.
Note When TOP or BOTTOM is used, the label might collide with other
graphical features. In that case, use CENTER or DATACENTER
instead.
LEFT
RIGHT
positions the label to the left or right of the axis area.
Restriction These options are valid for the X and X2 axes only.
1228 Chapter 8 / Axis Options in Layouts
Note When LEFT or RIGHT is used, the label might collide with other
graphical features.
The following figure shows the CENTER and DATACENTER positions for a blue
Y-axis label Type and a red X-axis label MPG.
The next figure shows the TOP and LEFT positions, and the BOTTOM and
RIGHT positions for the same axis labels.
The following figure shows the CENTER and DATACENTER positions for a blue
Y-axis label Qtr and a red X-axis label Close.
The next figure shows the TOP and LEFT positions, and the BOTTOM and
RIGHT positions for the same axis labels.
Default CENTER
Restriction This option does not support collision avoidance. In some cases, axis
label collisions can occur in the axis area.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1229
See SHORTLABEL= on page 1232 for information about how short labels
are used.
LABELSPLITCHAR="character-list"
specifies one or more characters on which the axis labels can be split, if needed.
When multiple split characters are specified, each character in the list is treated
as a separate split character unless the specified characters appear
consecutively in the axis label. In that case, all of the specified split characters
together are treated as a single split character.
When LABELFITPOLICY=SPLIT, if the axis label does not fit the available
space, then it is split on a specified split character only if a split is needed at
that point to make the label fit. In this case, a split might not occur on every
split character. When LABELFITPOLICY=SPLITALWAYS, the axis label is split
unconditionally on every occurrence of a split character. If the axis label does
not contain any of the specified split characters, the label is not split.
"character-list"
one or more characters with no space between each character and enclosed
in quotation marks.
LABELSPLITCHARDROP=TRUE | FALSE
specifies whether the split characters are included in the displayed axis labels.
TRUE
drops the split characters from the axis label display.
FALSE
includes the split characters in the axis label display.
1230 Chapter 8 / Axis Options in Layouts
Default TRUE. The split characters are dropped from the axis label.
See “boolean ” on page xii for other Boolean values that you can use.
LABELSPLITJUSTIFY=justification
specifies the justification of the strings that are inside the axis label blocks.
justification
CENTER
LEFT
RIGHT
specifies the justification for the X or X2 axis label.
CENTER
TOP
BOTTOM
specifies the justification for the Y or Y2 axis label.
Default CENTER
LINEAROPTS=(linear-axis-options)
specifies one or more options for a numeric interval axis. Options must be
enclosed in parentheses. Each option is specified as a name = value pair and
each pair is space separated.
See “Options for Linear Axes Only” on page 1243 for the options that you
can use for linear-axis-options.
LOGOPTS=(log-axis-options)
specifies one or more options for a log axis. Options must be enclosed in
parentheses. Each option is specified as a name = value pair and each pair is
space separated.
See “Options for Log Axes Only” on page 1255 for the options that you
can use for log-axis-options.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1231
NAME="string"
assigns a name to an axis for reference in other statements. Currently, it is used
only in an AXISLEGEND statement.
Restriction This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Interactions This option is ignored unless the axis is discrete. The axis can be
discrete by default, or explicitly set to discrete with a TYPE=
DISCRETE setting.
AUTO
reserves just enough area to fully display markers and other graphical
features near the maximum end of an axis.
AUTOCOMPRESS
applies an automatic offset that prevents axis labels and tick values from
extending beyond the axis length.
number
specifies the offset as a decimal proportion of the full axis length.
For a continuous axis, the offset follows the highest data value or highest
tick value, whichever is greater.
Default AUTOCOMPRESS
Range 0–1. The sum of OFFSETMAX= and OFFSETMIN= should not be more
than 1.
AUTO
reserves just enough area to fully display markers and other graphical
features near the maximum end of an axis.
AUTOCOMPRESS
applies an automatic offset that prevents axis labels and tick values from
extending beyond the axis length.
number
specifies the offset as a decimal proportion of the full axis length.
1232 Chapter 8 / Axis Options in Layouts
For a continuous axis, the offset precedes the lowest data value or lowest
tick value, whichever is less.
Default AUTOCOMPRESS
Range 0–1. The sum of OFFSETMAX= and OFFSETMIN= should not be more
than 1.
REVERSE=TRUE | FALSE
specifies whether tick values should appear in the reverse order.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
SHORTLABEL="string"
specifies an alternate axis label to display when the default label or the label
specified by the LABEL= option is too long to fit the available space. When
LABELPOSITION=CENTER (default), the available space for an axis label is the
full axis, including the axis offsets. When LABELPOSITION=DATACENTER, the
available space for an axis label is the axis tick display area, which excludes the
axis offsets. If the label length exceeds the available space, then the label is
anchored at the left or bottom offset. It extends beyond the opposing offset
until it reaches the end of the axis where it is truncated. An ellipsis designates
the truncation.
Note If the specified label is itself too long for the grid length or the grid
width, then it is truncated in the display.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TIMEOPTS=(time-axis-options)
specifies one or more options for a time axis.
Requirements Columns associated with a time axis must be in SAS time, SAS
date, or SAS datetime units and have an associated SAS time,
date, or datetime format.
See “Options for Time Axes Only” on page 1265 for the options that
you can use for time-axis-options.
AUTO
requests that the axis type be automatically determined, based on the
overlay contents.
DISCRETE
uses a DISCRETE axis if possible.
The data for discrete axes can be character or numeric. You can add a
DISCRETEOPTS= option list to customize this axis type.
LINEAR
uses a LINEAR axis if possible.
You can add a LINEAROPTS= option list to customize this axis type.
TIME
uses a TIME axis if possible.
Data for this axis must be SAS time, SAS date, or SAS datetime values. You
can add a TIMEOPTS= option list to customize this axis type.
LOG
uses a LOG axis if possible.
You can add a LOGOPTS= option list to customize this axis type.
Interaction If a log axis is requested and the axis data contains 0 or negative
values, the axis reverts to a linear axis. This outcome can occur
for the response axis of a bar chart, line chart, needle plot, or
waterfall chart when a baseline intercept of 0 or less is specified.
It can also occur for the response axis of a waterfall chart when
an initial bar value of 0 or less is specified. To get a log response
axis in those cases, set the baseline intercept or initial bar value
to a positive value.
Default AUTO
Interactions If this option is set to anything other than AUTO, then plots within
the layout are dropped from the display if their data types or data
ranges do not match the axis type requirements. For more
information, see “Plot Axis Types Must Agree on Common Axes” on
page 1049.
After the axis type is determined (whether you set a specific type
or AUTO is in effect), you can use only options that are supported
by that axis type. For example, if TYPE=TIME, then only the general
OVERLAY axis options and those available on TIMEOPTS= are
supported.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1235
TICKDISPLAYLIST=(string-list)
specifies the text that is displayed for the tick values that are defined in the
TICKVALUELIST= option. The string list is a space-separated list of string
values that are displayed on the axis in place of the values in the
TICKVALUELIST= option. The strings map one-to-one positionally with the
values that are listed in the TICKVALUELIST= option.
Tip This option should be used with the TICKVALUELIST= option. The
number of items in the list for this option should equal the
number of items in the list for the TICKVALUELIST= option.
1236 Chapter 8 / Axis Options in Layouts
Example The following example specifies the axis tick values 10, 20, 30,
and 40, and the tick display values A, B, C, and D:
tickvaluelist=("10" "20" "30" "40");
tickdisplaylist=("A" "B" "C" "D");
TICKTYPE=MIDPOINT | INBETWEEN
specifies the position of the axis tick marks.
MIDPOINT
places the tick marks at the midpoint value location.
INBETWEEN
places the tick marks half way between adjacent midpoint locations.
Default MIDPOINT
TICKVALUEFITPOLICY=policy
specifies a policy for avoiding tick value collision on an axis. The effectiveness
of a collision-avoidance policy depends on the number of tick values, their
length, and the length of the axis. Which policies are valid depends on the axis
on which this option is used.
EXTRACT
displays consecutive integers along the axis instead of the actual tick values
in order to represent those tick values.
EXTRACTALWAYS
same as EXTRACT, except that the extraction is implemented regardless of
whether collision occurs.
NONE
makes no attempt to avoid collisions between tick values.
SPLIT
splits the tick value at a split character, which is specified by the
TICKVALUESPLITCHAR= option, only when necessary in order to make the
value fit the available space.
A split does not occur at a split character if a split is not needed at that
location. If the value does not contain any of the specified split characters,
then the value is not split. Values that are not split or that do not fit the
available space even after splitting might overlap the adjoining space.
SPLITALWAYS
always splits the axis tick value at every occurrence of a split character that
is specified by the TICKVALUESPLITCHAR= option.
SPLITALWAYSTHIN
same as SPLITALWAYS, except that thinning is performed when long words
do not fit the available space.
SPLITTHIN
same as SPLIT, except that thinning is performed when long words do not fit
the available space.
THIN
eliminates alternate tick values.
EXTRACT
displays consecutive integers along the axis instead of the actual tick values
in order to represent those tick values.
EXTRACTALWAYS
same as EXTRACT, except that the extraction is implemented regardless of
whether collision occurs.
NONE
makes no attempt to avoid collisions between tick values.
ROTATE
rotates the tick values if a collision occurs.
ROTATEALWAYS
rotates the tick values regardless of whether a collision occurs.
ROTATEALWAYSDROP
attempts the ROTATEALWAYS policy, and then drops the tick values if
collisions still occur.
ROTATETHIN
attempts the ROTATE policy, and then the THIN policy.
SPLITALWAYS
always splits the axis tick value at every occurrence of a split character that
is specified by the TICKVALUESPLITCHAR= option.
STACKEDALWAYS
always displays the tick values vertically as stacked letters.
STACKEDALWAYSTHIN
always displays the tick values vertically as stacked letters.
Thinning is performed when the tick values do not fit the available space.
STAGGER
alternates the tick values between two rows.
STAGGERROTATE
attempts the STAGGER policy, and then the ROTATE policy.
STAGGERTHIN
attempts the STAGGER policy, and then the THIN policy.
STAGGERTRUNCATE
attempts the STAGGER policy, and then the TRUNCATE policy.
THIN
eliminates alternate tick values.
TRUNCATE
shortens the tick labels that exceed 12 characters to 12 characters.
TRUNCATEROTATE
attempts the TRUNCATE policy, and then the ROTATE policy.
TRUNCATESTAGGER
attempts the TRUNCATE policy, and then the STAGGER policy.
TRUNCATETHIN
attempts the TRUNCATE policy, and then the THIN policy.
Note A note is written to the SAS log when tick value thinning occurs.
TICKVALUEFORMAT=format
specifies how to format the values for major tick marks.
Interaction This option is ignored when the axis tick values are extracted to an
axis legend. See TICKVALUEFITPOLICY=EXTRACT |
EXTRACTALWAYS.
Tip Use this option when you want to duplicate tick values on an axis.
TICKVALUELIST=(string-list)
specifies the list of tick values that are to be displayed on the axis.
string-list
a space-separated list of values, enclosed in parentheses.
Only the tick values that are included in the string list are displayed on the axis.
The values are displayed in the order in which they are listed. The data values
that are not in the list are dropped. The list can be a subset of the data values. It
can also contain values that are not included in the actual data. A tick value that
is not included in the data appears on the axis, but no data is represented at its
tick mark.
Notes If the string list contains duplicate values, then the first
occurrence of the duplicated value in the list is honored and the
remaining instances are ignored.
1240 Chapter 8 / Axis Options in Layouts
When the values specified in the list are compared with the actual
data values, leading blanks are honored and trailing blanks are
ignored.
Tips You can use this option to subset the axis values or to display the
values in a specific order.
You can use this option to display values on the axis that are not
contained in the data.
Examples The following example specifies the axis tick values Sedan,
Sports, Wagon, and SUV:
tickvaluelist=("Sedan" "Sports" "Wagon" "SUV")
The following example specifies the axis tick values 10, 20, 30,
and 40:
tickvaluelist=("10" "20" "30" "40")
DIAGONAL
rotates the tick values to a 45-degree diagonal position.
The X labels read left to right in a downward direction. The X2 labels read
left to right in an upward direction.
DIAGONAL2
rotates the tick values to a –45-degree diagonal position.
The X labels read left to right in an upward direction. The X2 labels read left
to right in a downward direction.
VERTICAL
rotates the labels to a 90-degree vertical position.
Default DIAGONAL
TICKVALUESPLITCHAR="character-list"
specifies a list of characters on which the tick values can be split, if needed.
When multiple characters are specified, each character in the list is treated as a
separate split character unless the specified characters appear consecutively in
the tick value. In that case, all of the specified split characters together are
treated as a single split character.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1241
"character-list"
one or more characters with no delimiter between each character.
TICKVALUESPLITCHARDROP=TRUE | FALSE
specifies whether the split characters should be included in the displayed tick
values. The split characters are specified by the TICKVALUESPLITCHAR=
option.
TRUE
drops the split characters from the tick value display.
tick values are split on the asterisk character by using the SPLITALWAYS
policy.
FALSE
includes the split characters in the tick value display.
The fit policy determines how the characters are displayed. If the display
policy is SPLIT or SPLITTHIN and TICKVALUESPLITCHARDROP=FALSE,
then each tick value is split at a split character only where a split is
necessary in order to make the value fit the available space. A split might not
occur at every split character in the tick value. At each split point, the split
character remains as the last character in the current line. The characters
that follow the split character, up to and including the split character at the
next split point, are then wrapped to the following line. This process repeats
until the entire data tick value is displayed. The following figure shows an
example in which TICKVALUESPLITCHARDROP=FALSE and three-word,
asterisk-delimited tick values are split on the asterisk character by using the
SPLIT policy.
Notice that a split occurs on the first asterisk and not at the second. In this
case, a split is not needed at the second asterisk.
Notice that a split occurs after each asterisk and each asterisk appears at
the end of the line. In this case, three lines are displayed.
Default TRUE
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1243
See “boolean ” on page xii for other Boolean values that you can use.
INTEGER=TRUE | FALSE
specifies that evenly spaced integer values are used for tick marks.
Default FALSE
Note This option is ignored when the data exceeds the limits of integer
values.
See “boolean ” on page xii for other Boolean values that you can use.
MINORGRID=TRUE | FALSE
specifies whether grid lines are displayed at the minor tick marks.
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tips The GRIDATTRS= option does not affect the appearance of the
minor grid lines. To control the minor grid line appearance, use the
MINORGRIDATTRS= option.
Use the MINORTICKS= option to display the minor tick marks on the
axis.
See “boolean ” on page xii for other Boolean values that you can use.
The following figure shows the minor grid lines set to light blue, dotted lines on
a linear axis. (See the example.)
1246 Chapter 8 / Axis Options in Layouts
The following figure shows the minor grid lines set to light blue, dotted lines on
a base-10 log axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a time axis. (See the example.)
Defaults The GraphGridLines style element is used starting with SAS 9.4.
Tip Use the GRIDATTRS= option to control the appearance of the major
grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Example Here is an example that specifies light blue, dotted lines for the
minor grid.
minorgridattrs=(color=lightblue pattern=dot);
MINORTICKCOUNT=positive-integer
specifies the number of minor ticks that are displayed on the axis.
Defaults Four ticks with five intervals in SAS 9.4M1 and earlier releases.
MINORTICKS=TRUE | FALSE
specifies whether minor ticks are displayed. When MINORTICKS=TRUE, the
minor tick marks are displayed on the axis as shown in the following figure.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1247
Default FALSE
Tip Use the MINORGRID= option to display grid lines at the minor tick
values.
See “boolean ” on page xii for other Boolean values that you can use.
THRESHOLDMAX=number
specifies a bias for including one more tick mark at the maximum end of the
axis.
Default 0.30
Range 0–1
Tips If the threshold is set to 0, the potential tick mark is never displayed.
If the threshold is set to 1, then the tick mark is always displayed.
THRESHOLDMIN=number
specifies a bias for including one more tick mark at the minimum end of the axis.
Default 0.30
Range 0–1
Tips If the threshold is set to 0, the potential tick mark is never displayed.
If the threshold is set to 1, then the tick mark is always displayed.
TICKDISPLAYLIST=(string-list)
specifies the text that is displayed for the tick values that are defined in the
TICKVALUELIST= option. The string list is a space-separated list of string
values that are displayed on the axis in place of the values in the
TICKVALUELIST= option. The strings map one-to-one positionally with the
values that are listed in the TICKVALUELIST= option.
Tip This option should be used with the TICKVALUELIST= option. The
number of items in the list for this option should equal the
number of items in the list for the TICKVALUELIST= option.
TICKVALUEFITPOLICY=policy
specifies a policy for avoiding tick value collision on an axis. The effectiveness
of a collision-avoidance policy depends on the number of tick values, their
length, and the length of the axis. Which policies are valid depends on the axis
on which this option is used. For the Y and Y2 axes, the following policies are
valid:
NONE
makes no attempt to avoid collisions between tick values.
THIN
eliminates alternate tick values.
NONE
makes no attempt to avoid collisions between tick values.
ROTATE
rotates the tick values if a collision occurs.
ROTATEALWAYS
rotates the tick values regardless of whether a collision occurs.
ROTATETHIN
attempts the ROTATE policy, and then the THIN policy.
STAGGER
alternates the tick values between two rows.
STAGGERROTATE
attempts the STAGGER policy, and then the ROTATE policy.
STAGGERTHIN
attempts the STAGGER policy, and then the THIN policy.
THIN
eliminates alternate tick values.
Default THIN
Note A note is written to the SAS log when tick value thinning occurs.
(format-options)
specifies one or more formatting options for major tick values.
MAXWIDTH=integer
specifies the maximum width for displayed tick values.
Default 8
MAXDECIMALS=integer
specifies the maximum number of decimals for displayed tick values.
Default 6
1250 Chapter 8 / Axis Options in Layouts
PREFERREDDECIMALS=integer
specifies the number of decimal places that you want to display for most
values.
Default 2
EXTRACTSCALE=TRUE | FALSE
specifies whether to extract a scale factor from the tick values and use it
to reduce the tick value width.
For long axis labels, if the scale does not fit the available space, then the
label is truncated, and the scale is appended to the truncated label.
Ellipses indicate that the label was truncated, as shown in the following
example.
Total Sales for the Fourth Quarter Of ... (millions)
In extreme cases in which the scale does not fit even with truncation, the
entire axis is dropped.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can
use.
EXTRACTSCALETYPE=DEFAULT | SCIENTIFIC
specifies whether to extract a named scale or a scientific-notation scale.
DEFAULT
extracts a named scale.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1251
SCIENTIFIC
extracts a scientific-notation scale.
Default DEFAULT
Restriction The scale is derived from the English locale for all locales.
DATA
uses the format that has been assigned to the column that is contributing to
the axis (or BEST6 if no format is assigned) in order to control the formatting
of the major tick values.
format
specifies a format to apply to the major tick values.
Restriction GTL currently honors most, but not every, SAS format. For
details, see Appendix 4, “Format Support in ODS Graphics,” on
page 1621 .
TICKVALUELIST=(numeric-list)
specifies the tick values for a linear axis as a list.
The VIEWMIN= and VIEWMAX= options alter the axis data range.
If the VIEWMIN= option is set to the minimum tick list value and
the VIEWMAX= option is set to the maximum tick list value, then
all ticks in the tick list are displayed. This might result in some data
not being displayed. For example, data might not be displayed
when the VIEWMIN= value is greater than the actual data
minimum, or when the VIEWMAX= value is less than actual data
maximum.
Tip The values in the list are formatted according to the setting for the
TICKVALUEFORMAT= option.
TICKVALUEPRIORITY=TRUE | FALSE
specifies whether an axis tick specification (TICKVALUELIST= or
TICKVALUESEQUENCE=) can extend the axis data range.
TRUE
extends the axis data range (but does not reduce it) to include the minimum
and maximum values that are specified by either the TICKVALUELIST= or
TICKVALUESEQUENCE= option.
If the minimum and maximum of the user-specified values are within the
data range, this option has no effect.
FALSE
displays only the tick values that are specified by the TICKVALUELIST=
option that fall within the explicit data range set by the VIEWMIN= and
VIEWMAX= options or by the implicit data range set by the actual data
minimum and data maximum.
Default FALSE
Interactions When this option is set to TRUE, the VIEWMIN= and VIEWMAX=
options are ignored.
Note If the minimum and maximum of the specified values are within the
data range, then this option has no effect.
See “boolean ” on page xii for other Boolean values that you can use.
DIAGONAL
rotates the tick values to a 45-degree diagonal position.
The X labels read left to right in a downward direction. The X2 labels read
left to right in an upward direction.
DIAGONAL2
rotates the tick values to a –45-degree diagonal position.
The X labels read left to right in an upward direction. The X2 labels read left
to right in a downward direction.
VERTICAL
rotates the labels to a 90-degree vertical position.
Default DIAGONAL
START=number
specifies the value for the first tick mark.
END=number
specifies the value for the last tick mark.
INCREMENT=number
specifies the increment for intermediate tick marks between the first and
last tick marks.
1254 Chapter 8 / Axis Options in Layouts
The END value always controls the last tick mark. The interval between the
last tick mark and the previous tick mark might not necessarily be the
INCREMENT value.
The VIEWMIN= and VIEWMAX= options alter the axis data range.
If the VIEWMIN= option is set to the START= option value and the
VIEWMAX= option is set to the END= option value, then all ticks in
the tick sequence are displayed.
Tip The values in the sequence are formatted according to the setting
for the TICKVALUEFORMAT= option.
VIEWMAX=number
specifies the maximum data value to include in the display. The value might be
adjusted by the threshold calculation.
Default The maximum value in the data for the specified axis.
Interactions This option does not determine the maximum axis tick value that
is displayed. The THRESHOLDMAX= value is used to determine
the maximum tick value.
The maximum axis tick value might differ from the VIEWMAX=
value. The VIEWMIN= and VIEWMAX= values, and additional
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1255
Tip To display the VIEWMAX= value as the maximum tick value, use
the TICKVALUELIST= option.
VIEWMIN=number
specifies the minimum data value to include in the display. The value might be
adjusted by the threshold calculation.
Default The minimum value in the data for the specified axis.
Interactions This option does not determine the minimum axis tick value that
is displayed. The THRESHOLDMIN= value is used to determine
the minimum tick value.
The minimum axis tick value might differ from the VIEWMIN=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMIN= value as the minimum tick value, use
the TICKVALUELIST= option.
BASE=10 | 2 | E
specifies the base of the logarithmic scale for the axis values.
Default 10
MINORGRID=TRUE | FALSE
specifies whether grid lines are displayed at the minor tick marks.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1257
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tips The GRIDATTRS= option does not affect the appearance of the
minor grid lines. To control the minor grid line appearance, use the
MINORGRIDATTRS= option.
Use the MINORTICKS= option to display the minor tick marks on the
axis.
See “boolean ” on page xii for other Boolean values that you can use.
The following figure shows the minor grid lines set to light blue, dotted lines on
a linear axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a base-10 log axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a time axis. (See the example.)
Defaults The GraphGridLines style element is used starting with SAS 9.4.
Tip Use the GRIDATTRS= option to control the appearance of the major
grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Example Here is an example that specifies light blue, dotted lines for the
minor grid.
minorgridattrs=(color=lightblue pattern=dot);
MINORTICKCOUNT=positive-integer
specifies the number of minor ticks that are displayed on the axis.
MINORTICKS=TRUE | FALSE
specifies whether minor ticks are displayed. When MINORTICKS=TRUE, the
minor tick marks are displayed on the axis as shown in the following figure.
Default FALSE
Requirement If you set this option to TRUE, you must also specify a value for
MINORTICKCOUNT=. Otherwise, minor tick marks do not appear
on the log axis.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1259
Tip Use the MINORGRID= option to display grid lines at the minor tick
values.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
selects a LOGEXPAND, LOGEXPONENT, or LINEAR representation
automatically based on the range of the data.
LOGEXPAND
places the major tick marks at uniform intervals at integer powers of the
base.
Base=10
Base=2
Base=E
LOGEXPONENT
places the major tick marks at uniform intervals at integer powers of the
base.
The tick values are only the integer exponents for all bases.
LINEAR
places the major tick marks at non-uniform intervals that cover the range of
the data.
Default AUTO
1260 Chapter 8 / Axis Options in Layouts
GTL currently honors most but not every SAS format. For details,
see Appendix 4, “Format Support in ODS Graphics,” on page 1621.
TICKVALUEFORMAT=DATA | format
specifies how to format the values for major tick marks.
DATA
uses the format that has been assigned to the column that is contributing to
the axis (or BEST6 if no format is assigned) in order to control the formatting
of the major tick values.
format
specifies a format to apply to the major tick values.
Restriction GTL currently honors most, but not every, SAS format. For
details, see Appendix 4, “Format Support in ODS Graphics,” on
page 1621.
See BASE=
TICKINTERVALSTYLE=
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1261
TICKVALUELIST=(numeric-list)
specifies the tick values for a linear axis as a list.
Default Only the tick values specified in the list that fall within the
explicit data range set by the VIEWMIN= and VIEWMAX= options
or by the implicit data range set by the actual data minimum and
data maximum are displayed. An internal algorithm determines
the tick marks.
Interactions The VALUESTYPE= option determines how the values in the list
are interpreted.
The VIEWMIN= and VIEWMAX= options alter the axis data range.
If the VIEWMIN= option is set to the minimum tick list value and
the VIEWMAX= option is set to the maximum tick list value, then
all ticks in the tick list are displayed. This might result in some
data not being displayed. For example, data might not be
displayed when the VIEWMIN= value is greater than the actual
data minimum, or when the VIEWMAX= value is less than actual
data maximum.
See VIEWMIN= and VIEWMAX= options for controlling the data range
TICKVALUEPRIORITY=TRUE | FALSE
specifies whether the TICKVALUELIST= specification can extend the axis data
range.
TRUE
extends the axis data range (but does not reduce it) to include the minimum
and maximum values that are specified by the TICKVALUELIST= option.
If the minimum and maximum of the user-specified values are within the
data range, this option has no effect.
FALSE
displays only the tick values that are specified by the TICKVALUELIST=
option that fall within the explicit data range set by the VIEWMIN= and
VIEWMAX= options or by the implicit data range set by the actual data
minimum and data maximum.
Default FALSE
Interactions When this option is set to TRUE, the VIEWMIN= and VIEWMAX=
options are ignored.
Note If the minimum and maximum of the specified values are within the
data range, then this option has no effect.
See “boolean ” on page xii for other Boolean values that you can use.
VALUESTYPE=EXPANDED | EXPONENT
specifies the scale that the system uses when interpreting the
TICKVALUELIST=, VIEWMAX=, and VIEWMIN= option values. Use this option
to choose your preferred way of specifying log-axis values.
EXPANDED
values are interpreted as powers of the base such as 0.1, 1, 10, 100, and so on,
for base 10, for example.
EXPONENT
values are interpreted as integer exponents of the base such as 1, 2, 3, and so
on, for base 10, base 2, and base E.
Default EXPANDED
Note This option does not change the style of the tick values that are
displayed on the axis. It changes only how the VIEWMIN=,
VIEWMAX=, and TICKVALUELIST= option values are interpreted by
the system.
10 log axis. This results in X-axis tick values of 10, 100, 1000, 10000,
and 100000.
xaxisopts=(type=log
logopts=(base=10
tickintervalstyle=logexpand
valuestype=exponent
viewmin=1 viewmax=5));
VIEWMAX=number
specifies the maximum data value to include in the display.
Default The maximum value in the data for the specified axis.
The maximum axis tick value might differ from the VIEWMAX=
value. The VIEWMIN= and VIEWMAX= values, and additional
1264 Chapter 8 / Axis Options in Layouts
Tip To display the VIEWMAX= value as the maximum tick value, use
the TICKVALUELIST= option.
VIEWMIN=number
specifies the minimum data value to include in the display.
Default The minimum value in the data for the specified axis.
The minimum axis tick value might differ from the VIEWMIN=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1265
Tip To display the VIEWMIN= value as the minimum tick value, use
the TICKVALUELIST= option.
Default AUTO. An appropriate interval is chosen based on the data and the
column date, date-time, or time format.
Requirement The data column(s) mapped to a time axis must be in the same
duration units: TIME, DATE, or DATETIME. The selection of an
interval must be consistent with the duration unit. For example, if
the data are in time units, you can specify only AUTO, SECOND,
MINUTE, HOUR.
INTERVALMULTIPLIER=positive-integer
specifies a multiplier to apply to the time interval that is in effect for the axis.
Default 1
MINORGRID=TRUE | FALSE
specifies whether grid lines are displayed at the minor tick marks.
Interaction This option is ignored if the GRIDDISPLAY= option does not display
the grid lines.
Tips The GRIDATTRS= option does not affect the appearance of the
minor grid lines. To control the minor grid line appearance, use the
MINORGRIDATTRS= option.
Use the MINORTICKS= option to display the minor tick marks on the
axis.
See “boolean ” on page xii for other Boolean values that you can use.
The following figure shows the minor grid lines set to light blue, dotted lines on
a linear axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a base-10 log axis. (See the example.)
The following figure shows the minor grid lines set to light blue, dotted lines on
a time axis. (See the example.)
Defaults The GraphGridLines style element is used starting with SAS 9.4.
Tip Use the GRIDATTRS= option to control the appearance of the major
grid lines.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Example Here is an example that specifies light blue, dotted lines for the
minor grid.
minorgridattrs=(color=lightblue pattern=dot);
1270 Chapter 8 / Axis Options in Layouts
MINORTICKINTERVAL=interval
specifies the time interval between minor ticks. See Table 8.15 on page 1267 for
information about the intervals that you can select. The interval that you select
must be consistent with the axis data duration units such as TIME, DATE, or
DATETIME. For example, if the axis data is in TIME units, then you must specify
AUTO, SECOND, MINUTE, or HOUR.
Default AUTO
MINORTICKS=TRUE | FALSE
specifies whether minor ticks are displayed. When MINORTICKS=TRUE, the
minor tick marks are displayed on the axis as shown in the following figure.
Default FALSE
Tip Use the MINORGRID= option to display grid lines at the minor tick
values.
See “boolean ” on page xii for other Boolean values that you can use.
SPLITTICKVALUE=TRUE | FALSE
specifies whether to split the tick values on an X or X2 axis, if possible. This
option is not available for a Y or Y2 axis.
TRUE
splits the axis tick values into two lines allowing more tick values to appear.
For example, with INTERVAL= MONTH, this is how tick values are split:
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1271
FALSE
does not split the axis tick values.
For example, when this option specifies FALSE, this is how the tick values in
the previous example appear:
Typically, fewer tick values fit, causing thinning, rotation, or staggering of the
values. See the TICKVALUEFITPOLICY= option.
Default TRUE
See “boolean ” on page xii for other Boolean values that you can use.
TICKVALUEFITPOLICY=policy
specifies a policy for avoiding tick value collision on an X or X2 axis. This option
is not available for the Y and Y2 axes. The effectiveness of a collision-avoidance
policy depends on the number of tick values, their length, and the length of the
axis. The following policies are valid for the X and X2 axes:
NONE
makes no attempt to avoid collisions between tick values.
ROTATE
rotates the tick values if a collision occurs.
ROTATEALWAYS
rotates the tick values regardless of whether a collision occurs.
ROTATEALWAYSDROP
attempts the ROTATEALWAYS policy, and then drops the tick values if
collisions still occur.
ROTATETHIN
attempts the ROTATE policy, and then the THIN policy.
STAGGER
alternates the tick values between two rows.
1272 Chapter 8 / Axis Options in Layouts
STAGGERROTATE
attempts the STAGGER policy, and then the ROTATE policy.
STAGGERTHIN
attempts the STAGGER policy, and then the THIN policy.
THIN
eliminates alternate tick values.
Default THIN
Note A note is written to the SAS log when tick value thinning occurs.
TICKVALUEFORMAT=format | DATA
specifies how to format the values for major tick marks.
format
specifies a SAS date, time, or datetime format to control how the major tick
values are displayed.
This format must be in the same duration units as the data column(s)
mapped to a time axis: TIME, DATE, or DATETIME and should be appropriate
for the value of the INTERVAL= option. For example, if INTERVAL=MONTH
and there are two years of data displayed on the axis, then choosing
TICKVALUEFORMAT=YEAR. would result in several ticks having the same
year value.
DATA
specifies that the SAS date, time, or datetime format associated with the
data column assigned to the axis be used to control how the major tick
values are displayed.
Default The default format used by the INTERVAL= option. The default
does not apply if TICKVALUELIST= is specified.
GTL currently honors most but not every SAS format. For details,
see Appendix 4, “Format Support in ODS Graphics,” on page 1621.
Interactions The values in the list are formatted according to the format
specified on the TICKVALUEFORMAT= option. If
TICKVALUEFORMAT= is not used, then the values are formatted
according to the column format (the default TICKVALUEFORMAT
value is not applied to these values).
TICKVALUEPRIORITY=TRUE | FALSE
specifies whether the TICKVALUELIST= specification can extend the axis data
range.
TRUE
extends the axis data range (but does not reduce it) to include the minimum
and maximum values that are specified by the TICKVALUELIST= option.
If the minimum and maximum of the user-specified values are within the
data range, this option has no effect.
FALSE
displays only the tick values that are specified by the TICKVALUELIST=
option that fall within the explicit data range set by the VIEWMIN= and
VIEWMAX= options or by the implicit data range set by the actual data
minimum and data maximum.
Default FALSE
Restriction This option is valid only in the ROWAXIS= and ROW2AXIS= layout
axis options.
Interactions When this option is set to TRUE, the VIEWMIN= and VIEWMAX=
options are ignored.
Note If the minimum and maximum of the specified values are within the
data range, then this option has no effect.
See “boolean ” on page xii for other Boolean values that you can use.
DIAGONAL
rotates the tick values to a 45-degree diagonal position.
The X labels read left to right in a downward direction. The X2 labels read
left to right in an upward direction.
DIAGONAL2
rotates the tick values to a –45-degree diagonal position.
The X labels read left to right in an upward direction. The X2 labels read left
to right in a downward direction.
VERTICAL
rotates the labels to a 90-degree vertical position.
Default DIAGONAL
VIEWMAX=number
specifies the maximum data value to include in the display.
Default The maximum value in the data for the specified axis.
The maximum axis tick value might differ from the VIEWMAX=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1275
Tip To display the VIEWMAX= value as the maximum tick value, use
the TICKVALUELIST= option.
VIEWMIN=number
specifies the minimum data value to include in the display.
Default The minimum value in the data for the specified axis.
The minimum axis tick value might differ from the VIEWMIN=
value. The VIEWMIN= and VIEWMAX= values, and additional
factors such as thresholds and the tick values computed by the
plot statement, are used to determine the axis tick values.
Tip To display the VIEWMIN= value as the minimum tick value, use
the TICKVALUELIST= option.
Details
The LAYOUT DATALATTICE and LAYOUT DATAPANEL statements each create a
grid of graphs based on the values of one or more classification variables. In the
grid, the axes are always external and displayed on the “primary” axes by default.
The axes that are considered primary depend on the settings for the XAXIS= and
YAXIS= options in plot statements that are specified within the LAYOUT
PROTOTYPE. For managing the primary axes, both the LAYOUT DATALATTICE and
LAYOUT DATAPANEL statements have COLUMNAXISOPTS=,
COLUMN2AXISOPTS=, ROWAXISOPTS=, and ROW2AXISOPTS= options that
manage the axis features separately for columns and rows. The settings that are
available can manage odd and even columns and rows separately, enabling you to
simplify the axis display within the grid.
The following table shows which axis is primary for the XAXIS= and YAXIS=
settings, and which axis option to use to manage that primary axis.
The settings that are available for the axis options can manage odd and even
columns and rows separately, enabling you to simplify the axis display within the
grid.
n To manage the first, third, and odd occurrences of a primary axis, use the
DISPLAY= option.
n To manage the second, fourth, and even occurrences of a primary axis, use the
ALTDISPLAY= option.
You can also display “secondary” axes in the grid. A secondary axis is not an
independent axis. Rather, it mirrors the primary axis, but it is displayed on the
opposite side and can have different display options. For example, when the X axis
(bottom) is primary, you can mirror that axis with a secondary X axis at the top of
the grid. Similarly, when the Y2 axis (right) is primary, you can mirror that axis with
a secondary Y2 axis on the left of the grid. A secondary axis makes it easier to
interpolate values in the cells that are farthest away from the primary axis.
Secondary axes can be displayed in the graph, provided all plot statements in the
LAYOUT PROTOTYPE map data to the same primary axis. For example, a
secondary X axis can be displayed at the top of the layout, provided all plot
statements set XAXIS=X to map data to the primary X axis (bottom). Similarly, a
secondary Y2 axis can be displayed to the left in the layout, provided all plot
statements set YAXIS=Y2 to map data to the primary Y2 axis (right). If all plot
statements in the LAYOUT PROTOTYPE do not map data to the same primary axis,
then the secondary axes are not displayed.
In the default cases for the plots within the layout, the axis type is always
DISCRETE, LINEAR, or TIME. The TYPE= option enables you to specify an axis type
that overrides the default. For example, when appropriate for the data, you can
request a LOG axis. When you override the default axis type, you must be sure to
specify the correct axis type for the plot(s) that you are defining.
Each axis type has features specific to that type, and the following axis options
enable you to specify features for the different types: DISCRETEOPTS= ,
LINEAROPTS= , LOGOPTS= , and TIMEOPTS= . One or more of these options can
be specified for an axis, but the specified settings are applied only to the axis type
that supports them.
Axis Options for LAYOUT DATALATTICE and LAYOUT DATAPANEL 1277
Note: Certain plot types or layouts sometimes impose restrictions on what type of
axis can be assigned. See the plot or layout documentation for default axis types
and any restrictions that might apply.
Example Program
This example shows how axis attributes can be managed separately for even and
odd columns and rows in the layout grid. In this case, the ROWAXISOPTS= option is
used to stagger the Y-axes attributes. On the primary (left) Y axis, DISPLAY=
displays TICKS and TICKVALUES on the first and third rows while ALTDISPLAY=
displays just TICKS on the second row. On the secondary (right) Y axis,
DISPLAYSECONDARY= displays just TICKS on the first and third rows, while
ALTDISPLAYSECONDARY= displays TICKS and TICKVALUES on the second row.
This alternating pattern could also have been set for the column axes. The pattern
is independent of the number of rows and columns.
proc template;
define statgraph layoutdatalattice;
begingraph;
1278 Chapter 8 / Axis Options in Layouts
PART 6
Legend Statements
Chapter 9
Legend Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1281
1280
1281
9
Legend Statements
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1281
AXISLEGEND Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1281
CONTINUOUSLEGEND Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1291
DISCRETELEGEND, MERGEDLEGEND Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1303
LEGENDITEM Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1322
LEGENDTEXTITEMS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1329
Dictionary
AXISLEGEND Statement
Generates consecutive integers for display as axis-tick values in the graph, and creates a legend that
correlates those integers with the actual tick values that they represent.
Requirements: The axis must be named with the axis NAME= option.
The axis must be a discrete axis (TYPE=DISCRETE).
The axis must use the TICKVALUEFITPOLICY=EXTRACT or
TICKVALUEFITPOLICY=EXTRACTALWAYS suboption of the DISCRETEOPTS= axis
option.
Interactions: If the total legend area in the graph exceeds the percentage that is set by the
MAXLEGENDAREA= option in an ODS GRAPHICS statement that is in effect for
the output destination, the legend might be dropped
If DISPLAYCLIPPED=FALSE and the full legend cannot be displayed, the legend
might be dropped.
1282 Chapter 9 / Legend Statements
Syntax
AXISLEGEND "axis-name" < /options >;
Location options
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether the legend is automatically aligned within its parent
layout when nested within an overlay-type layout.
HALIGN=CENTER | LEFT | RIGHT | number
specifies the horizontal alignment of the legend within its parent layout
when nested within an overlay-type or REGION layout.
LOCATION=OUTSIDE | INSIDE
specifies whether the legend appears inside or outside the plot area when
the legend is specified within an overlay-type or REGION layout.
AXISLEGEND Statement 1283
Text options
TITLE="string"
specifies the title of the legend.
TITLEATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the legend title.
Required Argument
"axis-name"
references an axis’s name. The name controls which axis determines the legend
entries.
Optional Arguments
ACROSS=positive-integer
specifies the number of legend entries that are placed horizontally before the
next row begins.
Default The entries are placed to best fit the available area. This “best fit”
approach works only when the legend is nested in the template’s
outermost layout.
NONE
does not automatically align the legend within its parent layout.
AUTO
within the parent layout, attempts to center the legend in the area that is
farthest from any surrounding data point markers.
(location-list)
within the parent layout, restricts the legend’s possible locations to those
locations in the specified location-list, and uses the location-list position
that least collides with the parent layout’s other graphics features.
Default NONE
Restriction AUTO is available only when the parent layout contains a scatter
plot. Otherwise, it is ignored.
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type layout.
BACKGROUNDCOLOR=style-reference | color
specifies the color of the legend background.
style-reference
specifies a style reference in the form style-element:style-attribute.
BORDER=TRUE | FALSE
specifies whether a border is displayed around the legend.
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element
DISPLAYCLIPPED=TRUE | FALSE
specifies whether the legend is displayed when any portion of the legend cannot
be rendered entirely. Based on the legend contents and placement, or when the
graph size is reduced, parts of the legend (title, legend symbol, or legend value)
AXISLEGEND Statement 1285
might be clipped (truncated). When clipping occurs and this option is set to
FALSE, the entire legend is removed from the graph. The space for that legend is
then reclaimed by the remainder of the graph. When this option is set to TRUE,
the legend always appears, even if some parts of it have been clipped.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
DOWN=positive-integer
specifies the number of legend entries that are placed vertically before the next
column begins.
Default The entries are placed to best fit the available area. This “best fit”
approach works only when the legend is nested in the template’s
outermost layout.
number
specifies an explicit position in the containing layout.
Default CENTER
Restriction This option is available only when this statement is nested within
an overlay-type or REGION layout.
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type or REGION
layout.
LOCATION=OUTSIDE | INSIDE
specifies whether the legend appears inside or outside the plot area when the
legend is specified within an overlay-type or REGION layout.
Default OUTSIDE
1286 Chapter 9 / Legend Statements
Restriction This option has effect only when the legend statement appears
within an overlay-type or REGION layout and at least one
standalone plot statement is referenced by the parent layout.
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type or REGION
layout.
OPAQUE=TRUE | FALSE
specifies whether the legend background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether legend entries are organized into rows or into columns.
Default ROWMAJOR
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the legend border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
RIGHT=dimension
specifies the amount of extra space added to the right side.
AXISLEGEND Statement 1287
TOP=dimension
specifies the amount of extra space added to the top.
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is reserved inside the legend perimeter.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the legend perimeter.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
RIGHT=dimension
specifies the amount of extra space added to the right side.
TOP=dimension
specifies the amount of extra space added to the top.
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
TITLE="string"
specifies the title of the legend.
Default No title
1288 Chapter 9 / Legend Statements
Interactions For this option to have any effect, the TITLE= option must also be
specified.
If one or more text options are specified and they do not include all
the font properties (color, family, size, weight, style), then non-
specified properties will be derived from the GraphLabelText style
element.
Note When you specify style-element, only the style attributes COLOR,
FONTFAMILY, FONTSIZE, FONTSTYLE, and FONTWEIGHT are
used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
number
specifies an explicit position in the containing layout.
Default CENTER
Restriction This option is available only when this statement is nested within
an overlay-type or REGION layout. It is ignored if the parent layout
is not an overlay-type or REGION layout.
AXISLEGEND Statement 1289
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type or REGION
layout.
Interaction If one or more text options are specified and they do not include all
the font properties (color, family, size, weight, style), then non-
specified properties will be derived from the GraphLabelText style
element.
Note When you specify style-element, only the style attributes COLOR,
FONTFAMILY, FONTSIZE, FONTSTYLE, and FONTWEIGHT are
used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Details
An AXISLEGEND statement is used to consolidate the axis display so that a large
number of tick values can be clearly displayed without collision. In an axis legend,
the legend symbol is a positive integer that is generated to represent a specific axis
tick position, and the legend value displays the axis tick value. In the “Example:
AXISLEGEND Statement” on page 1290 , the first legend symbol is the integer 1 and
the first legend value is Neon SE 4dr.
n The AXISLEGEND statement must reference the axis name that was specified
in the parent layout’s NAME= axis option.
When all of these requirements are satisfied, the tick values of the named discrete
axis can be replaced with consecutive positive integers. The axis legend displays
those integer values and the corresponding tick values that the integers represent.
Within an overlay-type layout, when an axis legend is placed inside the plot area
with LOCATION= INSIDE,
n The axis legend is always placed on top of plot lines and markers.
Within an overlay-type layout, when an axis legend is placed outside the plot area
with LOCATION=OUTSIDE,
n By default, its background is fully opaque (OPAQUE=TRUE).
n Its position can be controlled with the HALIGN= and VALIGN= options.
Example Program
proc template;
define statgraph axislegend ;
begingraph;
entrytitle "Mileage for Vehicles Made by Dodge";
layout overlay / xaxisopts=(name="xaxis"
discreteopts=(tickvaluefitpolicy=extract)) ;
barchart category=model response=mpg_highway / stat=mean ;
axislegend "xaxis";
endlayout;
endgraph;
end;
CONTINUOUSLEGEND Statement
Creates a legend with a color ramp corresponding to a range of values.
1292 Chapter 9 / Legend Statements
Syntax
CONTINUOUSLEGEND "graph-name" < /options >;
Location options
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether the legend is automatically aligned within its parent
layout when nested within an overlay-type layout.
HALIGN=CENTER | LEFT | RIGHT | number
specifies the horizontal alignment of the legend within its parent layout
when nested within an overlay-type or REGION layout.
LOCATION=OUTSIDE | INSIDE
specifies whether the legend appears inside or outside the plot area when
the legend is specified within an overlay-type or REGION layout.
VALIGN=CENTER | TOP | BOTTOM | number
CONTINUOUSLEGEND Statement 1293
specifies the vertical alignment of the legend within its parent layout
when nested within an overlay-type or REGION layout.
Scale options
EXTRACTSCALE=TRUE | FALSE
specifies whether to extract a scale factor from the tick values and use it
to reduce the tick value width.
EXTRACTSCALETYPE=DEFAULT | SCIENTIFIC
specifies whether to extract a named scale or a scientific-notation scale.
Text options
TITLE="string"
specifies the title of the legend.
TITLEATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the legend title.
Required Argument
"graph-name"
specifies the plot to be represented by the legend. The plot is identified by the
name that is assigned to it on the plot statement’s NAME= option.
Optional Arguments
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether the legend is automatically aligned within its parent layout
when nested within an overlay-type layout.
NONE
does not automatically align the legend within its parent layout.
AUTO
within the parent layout, attempts to center the legend in the area that is
farthest from any surrounding data point markers.
(location-list)
within the parent layout, restricts the legend’s possible locations to those
locations in the specified location-list, and uses the location-list position
that least collides with the parent layout’s other graphics features.
Default NONE
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type layout.
BACKGROUNDCOLOR=style-reference | color
specifies the color of the legend background.
style-reference
specifies a style reference in the form style-element:style-attribute.
BORDER=TRUE | FALSE
specifies whether a border is displayed around the legend.
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
Tip The color of the frame around the color ramp and the color ramp tick
lines is controlled by the ContrastColor attribute of the
GraphAxisLines style element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element
EXTRACTSCALE=TRUE | FALSE
specifies whether to extract a scale factor from the tick values and use it to
reduce the tick value width. The scale can be a named scale or a scientific-
notation scale. The EXTRACTSCALETYPE= option specifies the scale type. The
scale used is appended to the legend title as shown in the following example.
Total Sales (millions)
CONTINUOUSLEGEND Statement 1295
For long legend titles, if the scale does not fit the available space, then the title
is truncated, and the scale is appended to the truncated title. Ellipses indicate
that the label was truncated as shown in the following example.
Total Sales for the Fourth Quarter Of ... (millions)
In extreme cases where the title does not fit even with truncation, the title is
dropped.
See “boolean ” on page xii for other Boolean values that you can use.
EXTRACTSCALETYPE=DEFAULT | SCIENTIFIC
specifies whether to extract a named scale or a scientific-notation scale.
DEFAULT
extracts a named scale.
A named scale can be millions, billions, or trillions for values of 999 trillion or
less, or a multiple of 10 (denoted as 10^n) for values over 999 trillion. For
small fractional tick values, the scale factor is set to ensure that the
absolute value of the smallest value is greater than 1. The scale can be
millionth, billionth, or trillionth for values of 1 trillionth or more, or a multiple
of 1/10 (10^–n) for values less than 1 trillionth.
SCIENTIFIC
extracts a scientific-notation scale.
number
specifies an explicit position in the containing layout.
Restriction This option is available only when this statement is nested within
an overlay-type or REGION layout.
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type or REGION
layout.
INTEGER=TRUE | FALSE
specifies whether only integer tick values are used in the continuous legend.
Default FALSE
Restriction This option applies only to smooth color gradients. For leveled
gradients such as those used with contour plots of type FILL,
LINEFILL or LABELEDLINEFILL, this option is ignored. See
CONTOURTYPE=.
LOCATION=OUTSIDE | INSIDE
specifies whether the legend appears inside or outside the plot area when the
legend is specified within an overlay-type or REGION layout.
Default OUTSIDE
Restriction This option has effect only when the legend statement appears
within a 2-D overlay-type layout and there is at least one
standalone plot statement with XY axes that is referenced by the
legend.
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type or REGION
layout.
OPAQUE=TRUE | FALSE
specifies whether the legend background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
ORIENT=VERTICAL | HORIZONTAL
specifies the orientation of the legend.
Default VERTICAL
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the legend border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
RIGHT=dimension
specifies the amount of extra space added to the right side.
TOP=dimension
specifies the amount of extra space added to the top.
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
1298 Chapter 9 / Legend Statements
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is reserved inside the legend perimeter.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the legend perimeter.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
RIGHT=dimension
specifies the amount of extra space added to the right side.
TOP=dimension
specifies the amount of extra space added to the top.
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
TITLE="string"
specifies the title of the legend. The title is placed below the legend body.
Default No title
Interactions For this option to have any effect, the TITLE= option must also be
specified.
If one or more text options are specified and they do not include all
the font properties (color, family, size, weight, style), then non-
specified properties will be derived from the GraphLabelText style
element.
Note When you specify style-element, only the style attributes COLOR,
FONTFAMILY, FONTSIZE, FONTSTYLE, and FONTWEIGHT are
used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
number
specifies an explicit position in the containing layout.
Default CENTER
Restriction This option is available only when this statement is nested within
an overlay-type or REGION layout. It is ignored if the parent layout
is not an overlay-type or REGION layout.
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type or REGION
layout.
Interaction If one or more text options are specified and they do not include all
the font properties (color, family, size, weight, style), then non-
specified properties will be derived from the GraphLabelText style
element.
Note When you specify style-element, only the style attributes COLOR,
FONTFAMILY, FONTSIZE, FONTSTYLE, and FONTWEIGHT are
used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
VALUECOUNTHINT=positive-integer
recommends a number of values for the continuous legend to use to label the
data range.
Default 6
Restriction The associated plot must be displayed with smooth gradient for
this option to have any effect. For example, in a contour plot,
CONTOURTYPE must be set to GRADIENT or LINEGRADIENT.
Details
A continuous legend consists of a color ramp and a numeric scale indicating color
values.
In the following figure, the continuous legend references a contour plot with a fixed
number of levels. The color ramp and legend values automatically reflect these
discrete levels. The legend option VALUECOUNTHINT= has no effect.
CONTINUOUSLEGEND Statement 1301
In this next figure, the continuous legend references a contour plot with a
continuous gradient. The number of legend values displayed is automatically
determined by the legend, or decided by the contributing plot, such as the
CONTOURPLOTPARM with CONTOURTYPE=FILL. For plots with a continuous
gradient, you can use the legend option VALUECOUNTHINT= to control how many
legend values appear. (This option is ignored if there is no gradient.)
Within an overlay-type layout, when a continuous legend is placed inside the plot
area with LOCATION= INSIDE,
n It is always placed on top of plot lines and markers.
Within an overlay-type layout, when a continuous legend is placed outside the plot
area with LOCATION=OUTSIDE,
1302 Chapter 9 / Legend Statements
n Its position can be controlled with the HALIGN= and VALIGN= options.
Example Program
proc template;
define statgraph continuouslegend;
begingraph;
entrytitle "Height and Weight Distribution";
layout overlay;
scatterplot x=height y=weight /
markercolorgradient=density
markerattrs=(symbol=squarefilled size=6px)
name="scatter";
continuouslegend "scatter" / orient=vertical
location=outside valign=center halign=right
valuecounthint=10 title="Density";
endlayout;
endgraph;
end;
run;
ods graphics / reset width=475px;
DISCRETELEGEND, MERGEDLEGEND Statements 1303
Restrictions: The MERGEDLEGEND statement can be used for grouped plots only.
The MERGEDLEGEND statement supports only line and marker overlays.
Notes: Often the data in a plot is classified by a group variable. Or, multiple columns of
data are plotted in the same graph. These groups or columns are represented in the
graph by different color or line patterns or marker symbols. In these cases, a
DISCRETELEGEND can be added to the graph to help decode the data. The
MERGEDLEGEND statement can be used to consolidate legend entries when the
graph displays grouped data for two plots. The MERGEDLEGEND statement must
specify exactly two names that reference the source for the legend entry values.
Prior to SAS 9.4M3, when a discrete attribute map is used for group values in a plot
that contributes to a discrete legend and attributes are overridden in the plot
statement, the attributes of some plot features and their corresponding legend
items might not match. Starting with SAS 9.4M3, the attributes of the legend items
always match the attributes of the corresponding plot features.
See: “LEGENDITEM Statement” on page 1322
Syntax
DISCRETELEGEND "graph-name-1" | "legend-item-name-1" | "discrete-attr-name-1"
<"graph-name-2" | "legend-item-name-2" | "discrete-attr-name-2"…> </options>;
BORDER=TRUE | FALSE
specifies whether a border is displayed around the legend.
BORDERATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the border line around the legend.
DISPLAYCLIPPED=TRUE | FALSE
specifies whether the legend is displayed when any portion of the legend
cannot be rendered entirely.
DOWN=positive-integer
specifies the number of legend entries that are placed vertically before
the next column begins.
FILLITEMOUTLINE=AUTO | ON
specifies whether the fill swatches are outlined only when enabled by the
contributing statements or are always outlined.
ITEMSIZE=(size-options)
specifies the size of specific types of items that are in a discrete or
merged legend.
OPAQUE=TRUE | FALSE
specifies whether the legend background is opaque (TRUE) or
transparent (FALSE).
ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether legend entries are organized into rows or into columns.
OUTERPAD=AUTO | dimension | (pad-options)
specifies the amount of extra space that is added outside the legend
border.
PAD=dimension | (pad-options)
specifies the amount of extra space that is reserved inside the legend
perimeter.
SORTBY=LABEL | TEXT
specifies whether text legend items are sorted by label or by text.
SORTORDER=AUTO | REVERSEAUTO | ASCENDINGFORMATTED |
DESCENDINGFORMATTED
specifies the sort order to use for the legend entry labels.
TITLEBORDER=TRUE | FALSE
specifies a border around the legend title that separates it from the
legend body.
VALUEATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the legend values.
Content options
ADDITIONALNAMES=("graph-name" | "legend-item-name" | "discrete-attr-name"
<"graph-name" | "legend-item-name" | "discrete-attr-name"> …)
specifies additional legend items that are to be added to the two items
that are required in the MERGEDLEGEND statement.
EXCLUDE=(item-names)
specifies a list of legend entries to exclude from the display.
TYPE=ALL | FILL | FILLCOLOR | LINE | LINECOLOR | LINEPATTERN | MARKER
| MARKERCOLOR | MARKERSYMBOL | TEXT
specifies which visual attributes to display for legend entries in the
legend.
DISCRETELEGEND, MERGEDLEGEND Statements 1305
Location options
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether the legend is automatically aligned within its parent
layout when nested within an overlay-type layout.
HALIGN=CENTER | LEFT | RIGHT | number
specifies the horizontal alignment of the legend within its parent layout
when nested within an overlay-type or REGION layout.
LOCATION=OUTSIDE | INSIDE
specifies whether the legend appears inside or outside the plot area when
the legend is specified within an overlay-type or REGION layout.
VALIGN=CENTER | TOP | BOTTOM | number
specifies the vertical alignment of the legend within its parent layout
when nested within an overlay-type or REGION layout.
Text options
TITLE="string"
specifies the title of the legend.
TITLEATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the legend title.
Required Arguments
"graph-name"
references one or more unique names that are specified by the NAME= option of
a plot statement. These names control which plots contribute to the legend, and
the order in which the legend entries occur. If a contributing plot uses a
GROUP= option, then there is a legend entry for each group value that is present
in the data.
"legend-item-name"
references one or more unique values specified by the NAME= option of a
LEGENDITEM statement. Each legend-item-name must be enclosed in quotation
marks.
"discrete-attr-name"
references one or more unique values that are specified by the NAME= option in
a DISCRETEATTRMAP statement. The discrete attribute map that the name
references contributes all of its value statements as legend items, regardless of
whether they match the data.
Optional Arguments
ACROSS=positive-integer
specifies the number of legend entries that are placed horizontally before the
next row begins. A legend entry typically consists of two parts, such as a marker
symbol and an associated value.
Default The entries are placed to best fit the available area. This “best fit”
approach works only when the legend is nested in the template’s
outermost layout.
The items from the sources that are specified in this option are not included in
the merging of the legend items. They are appended to the legend after the
items from the sources that are specified in the required arguments are merged.
NONE
does not automatically align the legend within its parent layout.
AUTO
within the parent layout, attempts to center the legend in the area that is
farthest from any surrounding data point markers.
(location-list)
within the parent layout, restricts the legend’s possible locations to those
locations in the specified location-list, and uses the location-list position
that least collides with the parent layout’s other graphics features.
Default NONE
Restriction AUTO is available only when the parent layout contains a scatter
plot. Otherwise, it is ignored.
Note Prior to SAS 9.4M5, the legend might overlap other legends or
insets. Starting with SAS 9.4M5, alignments that cause the legend
to overlap another legend or inset are avoided.
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type layout.
AUTOITEMSIZE=TRUE | FALSE
specifies that all markers, lines, and filled symbols in the legend are sized in
proportion to the font size used for the legend entry labels. These proportional
sizes take effect regardless of the size reported by the plot or LEGENDITEM.
The line segments are drawn as deemed appropriate by the legend, regardless of
the line thickness reported by the plot.
Default FALSE
Interaction When set to TRUE, this setting considers the font size in effect from
the VALUEATTRS= option.
See “boolean ” on page xii for other Boolean values that you can use.
BACKGROUNDCOLOR=style-reference | color
specifies the color of the legend background.
1308 Chapter 9 / Legend Statements
style-reference
specifies a style reference in the form style-element:style-attribute.
BORDER=TRUE | FALSE
specifies whether a border is displayed around the legend.
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element
DISPLAYCLIPPED=TRUE | FALSE
specifies whether the legend is displayed when any portion of the legend cannot
be rendered entirely. Based on the legend contents and placement, or when the
graph size is reduced, parts of the legend (title, legend symbol, or legend value)
might be clipped (truncated). When clipping occurs and this option is set to
FALSE, the entire legend is removed from the graph. The space for that legend is
then reclaimed by the remainder of the graph. When this option is set to TRUE,
the legend always appears, even if some parts of it have been clipped.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
DOWN=positive-integer
specifies the number of legend entries that are placed vertically before the next
column begins. A legend entry typically consists of two parts, such as a marker
symbol and an associated value.
DISCRETELEGEND, MERGEDLEGEND Statements 1309
Default The entries are placed to best fit the available area. This “best fit”
approach works only when the legend is nested in the template’s
outermost layout.
EXCLUDE=(item-names)
specifies a list of legend entries to exclude from the display.
Note When the specified names are compared with the legend entry
names, leading blanks are honored and trailing blanks are ignored.
Tip For plots with groups, you can exclude specific group values.
Example The following example excludes items Truck and Wagon from the
legend.
exclude=("Truck" "Wagon")
FILLITEMOUTLINE=AUTO | ON
specifies whether the fill swatches are outlined only when enabled by the
contributing statements or are always outlined.
AUTO
honors the DISPLAY= option settings for the contributing plot or the
FILLDISPLAY= setting of the legend item.
ON
always outlines the fill swatches.
Default ON
Requirement TYPE= on page 1317 must be FILL, FILLCOLOR, or ALL for this
option to have any effect.
Note The outlines are always 1 pixel wide with a solid pattern.
number
specifies an explicit position in the containing layout.
Default CENTER
Restriction This option is available only when this statement is nested within
an overlay-type or REGION layout.
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type or REGION
layout.
ITEMSIZE=(size-options)
specifies the size of specific types of items that are in a discrete or merged
legend.
AUTO
uses an equal width and height for color swatches with solid color fills, or
uses the golden ratio for swatches with pattern fills.
GOLDEN
specifies the golden ratio of 1.618 (width = 1.618 * height) for both solid
color and pattern fill swatches.
DISCRETELEGEND, MERGEDLEGEND Statements 1311
positive-number
specifies a custom aspect ratio.
Default AUTO
This option does not apply to bubble plot fill color swatches
(filled circle).
Interactions The legend must display fill entries for this option to have any
effect.
AUTO
enables the SAS system to determine the fill color swatch height.
BIG
specifies sizes that were developed as defaults for SAS Visual Analytics,
which results in color swatches that are larger than the SAS system
defaults.
dimension
specifies a custom height for the fill swatches.
style-reference
specifies a style attribute that controls the height of the fill swatches.
Default AUTO
Interactions The legend must display fill entries for this option to have any
effect.
HEIGHTSCALE=positive-number
specifies a scale factor that is to be applied to the fill swatch height.
Values greater than 1 increase the height of the fill swatches, and values less
than 1 reduce the height.
Default 1
Interactions The legend must display fill entries for this option to have any
effect.
LINELENGTH=dimension
specifies the length of the line glyph for line entries in the legend.
Default 48 pixels
Interaction The legend must display line entries for this option to have any
effect.
LOCATION=OUTSIDE | INSIDE
specifies whether the legend appears inside or outside the plot area when the
legend is specified within an overlay-type or REGION layout.
Default OUTSIDE
Restriction This option has effect only when the legend statement appears
within an overlay-type or REGION layout and at least one
standalone plot statement is referenced by the parent layout.
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type or REGION
layout.
OPAQUE=TRUE | FALSE
specifies whether the legend background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
ORDER=ROWMAJOR | COLUMNMAJOR
specifies whether legend entries are organized into rows or into columns.
Default ROWMAJOR
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the legend border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
RIGHT=dimension
specifies the amount of extra space added to the right side.
TOP=dimension
specifies the amount of extra space added to the top.
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
1314 Chapter 9 / Legend Statements
Default AUTO
Starting with SAS 9.4M1, the default padding between the discrete
legend and the plot area (including the axes) is increased to 10 pixels,
depending on the context. If the new default padding is not desirable,
then use the OUTERPAD= option to adjust it.
PAD=dimension | (pad-options)
specifies the amount of extra space that is reserved inside the legend perimeter.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the legend perimeter.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
RIGHT=dimension
specifies the amount of extra space added to the right side.
TOP=dimension
specifies the amount of extra space added to the top.
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
SORTBY=LABEL | TEXT
specifies whether text legend items are sorted by label or by text.
Default LABEL
DISCRETELEGEND, MERGEDLEGEND Statements 1315
AUTO
presents groups of legend entries in the order in which they are listed in the
legend statement.
The internal ordering of the entries is derived from the constituent plot-
statement options.
REVERSEAUTO
presents groups of legend entries in the reverse order in which they are listed
in the legend statement.
Tip This option is useful for grouped, stacked vertical bar charts when you
want the legend entries to be drawn in the same order as the bar group
segments.
ASCENDINGFORMATTED
DESCENDINGFORMATTED
performs a linguistic sort on the group items. It has the same effect as
sorting the input data, but the data is not changed.
Entries from separate plots, and separate legend items are combined and
ordered as a single list.
Default AUTO. Groups of legend entries are presented in the order in which
they are listed in the legend statement. The internal ordering of the
entries is derived from the constituent plot-statement options.
Interaction This option overrides the order that is set by any constituent plot
statement’s GROUPORDER= option.
TITLE="string"
specifies the title of the legend. The title is placed to the left of the legend body,
except in the following cases:
n The legend contains two or more rows of items.
n The legend title length exceeds the space that is available on the left side of
the legend.
1316 Chapter 9 / Legend Statements
Default No title
Interactions For this option to have any effect, the TITLE= option must also be
specified.
If one or more text options are specified and they do not include all
the font properties (color, family, size, weight, style), then non-
specified properties will be derived from the GraphLabelText style
element.
Note When you specify style-element, only the style attributes COLOR,
FONTFAMILY, FONTSIZE, FONTSTYLE, and FONTWEIGHT are
used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TITLEBORDER=TRUE | FALSE
specifies a border around the legend title that separates it from the legend
body.
Default FALSE
Tip The line attributes of the title border are set by the
BORDERATTRS= options.
See “boolean ” on page xii for other Boolean values that you can use.
DISCRETELEGEND, MERGEDLEGEND Statements 1317
Some keywords can be used to create specialized legends that display a single
visual attribute. For example, keywords FILLCOLOR or MARKERSYMBOL result
in the display of a single attribute. Other keywords (for example, FILL, LINE, or
MARKER) result in legends that display a set of visual attributes. For example,
keyword LINE results in the display of both line color and line pattern for legend
entries that include lines in their display.
Default ALL
number
specifies an explicit position in the containing layout.
1318 Chapter 9 / Legend Statements
Default CENTER
Restriction This option is available only when this statement is nested within
an overlay-type or REGION layout. It is ignored if the parent layout
is not an overlay-type or REGION layout.
See LAYOUT OVERLAY on page 159 for more information about how
child positions are determined in an overlay-type or REGION
layout.
Interaction If one or more text options are specified and they do not include all
the font properties (color, family, size, weight, style), then non-
specified properties will be derived from the GraphLabelText style
element.
Note When you specify style-element, only the style attributes COLOR,
FONTFAMILY, FONTSIZE, FONTSTYLE, and FONTWEIGHT are
used.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Details
A discrete legend consists of one or more units called legend entries. Each legend
entry consists of a legend symbol and a legend value. The legend symbol is
typically a marker, line, or filled symbol that represents a specific area in the plot.
The legend value is descriptive text that is derived from group values, or that is
assigned by the plot’s LEGENDLABEL= option or by the LEGENDITEM statement’s
LABEL= option. To specify a discrete legend, you can use the DISCRETELEGEND
statement. To consolidate legend entries for common grouped values that are
represented by two separate plots, you can use the MERGEDLEGEND statement.
For grouped plots, a discrete legend represents all of the values that are present in
the data. To ensure that legend entries are displayed for group values, regardless of
whether those values are present in the data, you can use a discrete attribute map
as described in “Displaying Legend Entries for Group Values That Are Not in the
Data” on page 1512.
In the DISCRETELEGEND statement, you can specify one or more names that
reference the source for the legend entry values. You can use the TYPE= option to
control the visual attributes for the legend display.
For legend items that represent fills or colors without a specific shape, a filled
symbol with a one-pixel-wide, solid outline is used to represent the data values. If
the feature being represented by the legend item has an outline, then the default
outline color is derived from the feature’s outline color. If the feature being
represented is an outline only or is a filled outlined marker, then the outline
thickness is derived from the plot. If the feature does not have an outline, then the
default outline color for its corresponding legend entry is derived from the
GraphOutline style element.
You can use the MERGEDLEGEND statement to consolidate lines and marker
symbols from discrete legend entries when a graph displays grouped values for
exactly two plots. With a MERGEDLEGEND statement, the legend values from the
group variables in two plots are compared. For each common value, the
corresponding legend lines and marker symbols are combined, and only one legend
entry is created for each matching set of group values. You can use the
MERGEDLEGEND statement only for grouped plots. You must specify two names
that reference the source for the legend entry values.
When a discrete legend is placed inside the plot area of an overlay type layout and
LOCATION= INSIDE, the following conditions apply:
n The discrete legend is always placed on top of plot lines and markers.
When a discrete legend is placed outside the plot area of an overlay type layout
and LOCATION=OUTSIDE, the following conditions apply:
1320 Chapter 9 / Legend Statements
When a discrete legend is placed within nested layouts, you might need to do one
of the following to obtain the legend organization that you want:
n use the ACROSS= option, and also set ORDER= ROWMAJOR
A legend might be dropped if the total legend area in the graph exceeds the
percentage that is set by the MAXLEGENDAREA= option in an ODS GRAPHICS ON
statement that is in effect for the output destination. A legend might also be
dropped if DISPLAYCLIPPED= FALSE and the full legend cannot be displayed.
Examples
Example Program
proc template;
define statgraph discretelegend;
begingraph;
entrytitle "Prediction Ellipses";
layout overlayequated / equatetype=equate;
scatterplot x=petallength y=petalwidth /
group=species name="s";
ellipse x=petallength y=petalwidth /
type=predicted alpha=0.2
name="p80" legendlabel="80%"
outlineattrs=graphconfidence;
ellipse x=petallength y=petalwidth /
type=predicted alpha=0.05
name="p95" legendlabel="95%"
outlineattrs=graphconfidence2;
discretelegend "s" / title="Species:" ;
discretelegend "p80" "p95" / across=1
autoalign=(topleft) location=inside ;
endlayout;
entryfootnote halign=left "Fisher's Iris Data";
endgraph;
end;
Example Program
proc sort data=sashelp.class
out =class;
by sex;
run;
proc template;
define statgraph mergedLegend;
begingraph;
entrytitle "Linear Regression By Gender";
layout overlay;
scatterplot x=height y=weight / group=sex name="scat";
regressionplot x=height y=weight/ group=sex name="reg";
mergedlegend "scat" "reg" / border=true;
endlayout;
endgraph;
end;
LEGENDITEM Statement
Creates the definition for a legend item that can be included in a discrete legend.
LEGENDITEM Statement 1323
Syntax
LEGENDITEM TYPE=type NAME="string" </options>;
Label options
LABEL="string"
specifies a label to be used for the legend item.
LABELATTRS
specifies the color and font attributes of the legend item’s label.
1324 Chapter 9 / Legend Statements
Required Arguments
TYPE=FILL | MARKER | MARKERLINE | LINE | TEXT
specifies a type for the legend item.
FILL
specifies a fill (displayed as a filled square).
MARKER
specifies a marker.
MARKERLINE
specifies a marker and a line.
LINE
specifies a line. The appearance can be managed with the LINEATTRS=
option.
TEXT
specifies text that can be displayed in the legend area.
The text string is defined with the TEXT= option, and the text appearance
can be managed with the TEXTATTRS= option.
NAME="string"
assigns a name to the legend item for reference in a DISCRETELEGEND or
MERGEDLEGEND statement.
Restrictions The string is case sensitive and must define a unique name within
the template.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Optional Arguments
FILLATTRS=style-element | style-element (fill-options) | (fill-options)
specifies the color of the fill when TYPE= is set to FILL.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
STANDARD
ALL
displays the fill and outline.
(fill-option)
specifies a list of one or more fill options.
FILL
displays only the fill.
OUTLINE
displays only the outline.
Default STANDARD
Requirement You must specify TYPE=FILL for this option to have any effect.
FILLEDOUTLINEDMARKERS=TRUE | FALSE
specifies whether markers are drawn with both fill and an outline.
TRUE
draws filled markers (marker symbols with the suffix FILLED) using both fill
and an outline.
Interaction When this option is TRUE, the marker fill is drawn using the
FILLATTRS= specification, and the outline is drawn using the
OUTLINEATTRS= specification.
FALSE
draws the markers using fill or an outline, but not both.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
LABEL="string"
specifies a label to be used for the legend item.
Tip The font and color attributes for the label are specified by the
LABELATTRS= option.
LABELATTRS
specifies the color and font attributes of the legend item’s label.
Interaction For this option to take effect, the LABEL= option must also be
specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
Interaction The Weight attribute cannot be derived from the style element, but
it can be set with this option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Restriction This option uses only the color specification in the style element or
line options. The line pattern and line thickness specifications are
ignored.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
TEXT="string"
specifies the text to display when TYPE= is set to TEXT. The font and color
attributes for the text are specified by the TEXTATTRS= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
Details
The LEGENDITEM statement creates a definition for a legend item that can be
included in a legend. The item that you define is independent of the data and
enables you to customize the legend to enhance or replace a standard legend. For
example, to display annotation text within the legend area, you can define a
LEGENDITEM statement with TYPE=TEXT and specify the text in the TEXT=
option.
The LEGENDITEM statement must be located within the BEGINGRAPH block but
outside of the outermost layout block. You can use multiple LEGENDITEM
statements to define multiple definitions. In that case, each definition specifies a
single legend entry and each item name must be referenced in the legend
statement.
Note: A single legend statement can reference multiple item names and also
multiple plot names.
Example Program
proc template;
define statgraph scatterplot;
begingraph;
entrytitle "Team Tryouts: Height and Weight by Sex";
discreteattrmap name="symbols" / ignorecase=true
trimleading=true;
value "m" / markerattrs=(color=blue symbol=diamondfilled);
value "f" / markerattrs=(color=red symbol=circlefilled);
enddiscreteattrmap;
discreteattrvar attrvar=groupmarkers var=sex attrmap="symbols";
legendItem type=marker name="m_marker" /
markerattrs=(color=blue symbol=diamondfilled)
label="70% of boys present" ;
legendItem type=marker name="f_marker" /
LEGENDTEXTITEMS Statement 1329
markerattrs=(color=red symbol=circlefilled)
label="75% of girls present" ;
legendItem type=text name="status" /
text=" (5 health forms missing)" ;
layout overlay;
scatterplot x=height y=weight / group=groupmarkers;
discretelegend "m_marker" "f_marker" "status" /
autoitemsize=true;
endlayout;
endgraph;
end;
proc sgrender data=sashelp.class template=scatterplot;
run;
LEGENDTEXTITEMS Statement
Creates the definition for data-driven text items that can be included in a discrete legend.
Syntax
LEGENDTEXTITEMS NAME="string" TEXT=column </options>;
Required Arguments
NAME="string"
assigns a name to the legend items for reference in a DISCRETELEGEND or
MERGEDLEGEND statement.
1330 Chapter 9 / Legend Statements
Restriction This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
TEXT=column
specifies the column in the plot data set that contains the text items.
Notes One item is added for each observation. Grouping is not supported.
The TEXT column should not contain missing values. A missing TEXT
column value is treated as if no text is specified. If an observation
contains a missing TEXT column value and a valid LABEL column value,
only the label value is added to the legend for that observation. If both
values are missing, nothing is added to the legend.
If the plot data is a SAS data set, the text items are arranged in data
order in the plot legend. If the plot data is a CAS in-memory table, the
text items are arranged in ascending order of the text column values.
Optional Arguments
LABEL=column
specifies the column that contains the labels for the legend items.
Note Each observation that has a LABEL column value should have a
corresponding TEXT column value. If an observation contains a valid
LABEL column value and a missing TEXT column value, only the label
value is added to the legend for that observation.
Tip The font and color attributes for the label are specified by the
LABELATTRS= option.
Note Space is reserved in the legend for the height of the legend label text
regardless of whether the LABEL= option is specified.
See “General Syntax for Attribute Options” on page 1599 for the syntax for
using a style-element value.
See “General Syntax for Attribute Options” on page 1599 for the syntax for
using a style-element value.
Details
The LEGENDTEXTITEMS statement creates a definition for data-driven text legend
items that can be included in a discrete legend. The items that you define in the
data are independent of the plot and enable you to customize the legend in order to
enhance or replace a standard legend. The text items are stored in the plot data set
in the column that is specified by the TEXT= option. The LEGENDTEXTITEMS
statement must be located within the BEGINGRAPH block but outside of the
outermost layout block. You reference the LEGENDTEXTITEMS statement in your
legend statement by the name specified in the NAME= option. You must not
reference the plot statement itself in the legend statement. To add items from
multiple columns, specify one LEGENDTEXTITEMS statement for each column,
and then reference all of the LEGENDTEXTITEMS statements in your legend
statement. Although no direct connection would exist between the plot data and
the legend, you could communicate the connection by managing the visual
attributes in both the plot and the legend.
Example Program
In this example program, a LEGENDTEXTITEMS statement is used to create the
legend of IDs and names in the right margin of the graph. The name IDLEGEND is
assigned to the LEGENDTEXTITEMS statement. The ID column provides the legend
text items, and the Name column provides a name as the label for each text item.
Here is the SAS code.
/* Assign a numeric ID to each name */
data class;
set sashelp.class;
id=_N_;
run;
discretelegend "idlegend" /
title="ID/Name" titleattrs=(weight=bold)
valign=top border=false
order=rowmajor across=1;
endlayout;
endlayout;
endgraph;
end;
PART 7
Text Statements
Chapter 10
Managing Text Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1337
Chapter 11
Text Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1347
1336
1337
10
Managing Text Items
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1337
Using Prefix Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1338
Available Prefix Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1338
Managing Horizontal Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1338
Managing Font Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1339
Using Text Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1341
Available Text Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1341
Subscripting and Superscripting Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1341
Using UNICODE Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1342
Rules for Unicode and Special Character Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . 1342
Reserved Keywords and Unicode Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1343
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1343
Lowercase Greek Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1344
Uppercase Greek Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1345
Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1346
Overview
The ENTRY, ENTRYTITLE, and ENTRYFOOTNOTE statements all use the same
syntax for specifying one or more pieces of text called text items. For example, here
is the ENTRYTITLE syntax:
In this example, the string “Height and Weight by Sex” is formatted as the graph
title and displayed in the title position. If multiple strings are specified, then they
are concatenated into a single line of text. This second specification generates the
same title:
entrytitle "Height " "and " "Weight " "by " "Sex";
To provide control over the text, multiple prefix options can precede each text item,
and the text item can be a string literal, a dynamic, or a text command. All text
items with the same HALIGN= setting are concatenated into one string. Up to three
strings with different horizontal alignment can result for each ENTRY statement.
Leading and trailing blanks in the concatenated string are always used.
n a string must be enclosed in quotation marks.
When used, a prefix option applies not only to immediately following piece of text
but also to ALL subsequent text strings and text-commands. If the same prefix
option appears more than once, then each use overrides the last used prefix of the
same name.
entry "One" " Two" " Three" " Four" " Five" " Six";
The HALIGN= option can be used to change the horizontal alignment to LEFT,
CENTER, or RIGHT. The following specification left-justifies the text:
entry halign=left
"One" " Two" " Three" " Four" " Five" " Six";
Text items are positionally concatenated by alignment area. For example, the
following specification left-justifies the first three strings and right-justifies the last
three strings:
Even if the HALIGN= specifications are jumbled, the final text is nevertheless
positionally concatenated by alignment area:
Note: When long strings are used or the bounding container is constrained, the
alignment areas might overlap.
For example, the following ENTRYTITLE statement uses prefix options to create
this title line:
1340 Chapter 10 / Managing Text Items
n The TEXTATTRS= options are reset each time a new TEXTATTRS= appears—
there is no “carry over” or accumulation of the settings.
n Blanks (spaces) must be provided as needed to achieve the desired
concatenation. When concatenating dynamic variables that are stripped of
leading and trailing blanks, a literal space must be inserted to separate them, as
shown in the following example:
entrytitle
halign=left
textattrs=GraphTitleText(color=black style=italic) "Left"
textattrs=GraphTitleText(color=red style=italic) " side"
halign=center
textattrs=(color=black) "Center"
textattrs=(color=red) " Text"
halign=right
textattrs=GraphTitleText(color=black weight=bold) "Right "
textattrs=GraphTitleText(color=red weight=bold) "side" ;
Dynamic variables can also be used in the text strings. In the following
ENTRYTITLE statement, assume that _DEPLABEL and _MODELLABEL are dynamic
variables that are specified on PROC TEMPLATE’s DYNAMIC statement:
n The default style element for ENTRYTITLE is GraphTitleText, so all three text
items (one literal and two dynamic variables) get these font properties as a
starting point.
n The text "Residual by Predicted for " _DEPLABEL is center-aligned by default.
n The prefix options HALIGN= and TEXTATTRS= override the center alignment
and font properties for the text _MODELLABEL.
entrytitle halign=left
textattrs=GraphTitleText _MODELLABEL
halign=center textattrs=()
"Residual by Predicted for " _DEPLABEL;
Using Text Commands 1341
In this example, the second HALIGN= and TEXTATTRS=() are necessary to reset
alignment and font properties to their defaults.
The string length of the resolved dynamic _MODELLABEL does not affect the
placement of the center-aligned text.
{command argument(s)}
The opening and closing braces are required to denote the scope of the command.
The textattrs=() option cancels all style overrides and reverts to the default text
properties.
1342 Chapter 10 / Managing Text Items
n a reserved keyword for a commonly used code point (for example, BETA)
The tables in “Reserved Keywords and Unicode Values” on page 1343 provide a list
of the commonly used reserved keywords and Unicode values (the tables are not
complete, but they provide an idea about what is possible).
Multiple arguments can be used within the scope of a single UNICODE text
command. For example, the following two specifications are equivalent:
The default formatting for the UNICODE text is derived from the
GraphUnicodeText style element.
By combining the TEXTATTRS= prefix option with the {SUB} and {UNICODE} text
commands, you can generate the following text:
For more information about using text throughout GTL (for example, using Unicode
values in labels), see SAS Graph Template Language: User’s Guide.
Overview
The tables in this section show some of the reserved keywords and Unicode values
that can be used with the UNICODE text command. For information about
rendering Unicode characters, see “Managing the String on Text Statements” in SAS
Graph Template Language: User’s Guide.
mu μ 03BC lowercase mu
nu ν 03BD lowercase nu
xi ξ 03BE lowercase xi
pi π 03C0 lowercase pi
Special Characters
Keyword Glyph Unicode Description
11
Text Statements
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1347
ENTRY Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1347
ENTRYFOOTNOTE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1356
ENTRYTITLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1364
Dictionary
ENTRY Statement
Displays a line of text in the graphical area.
Syntax
ENTRY text-item <text-item …> </options>;
Location options
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether the text is automatically aligned within its parent when
nested within an overlay-type layout.
VALIGN=CENTER | TOP | BOTTOM
specifies the vertical alignment of the text.
Text options
HALIGN=CENTER | LEFT | RIGHT
as a statement option, specifies the horizontal alignment of the text. As a
prefix-option, specifies the horizontal alignment of individual text-items.
Required Argument
text-item <…<text-item>>
specifies one or more pieces of text for the entry. Each text-item has the
following form:
Each piece of text can have multiple prefix settings that precede the piece of
text. A piece of text is either a string literal, a dynamic, or a text command. All
text-items with the same HALIGN= setting are concatenated into one string. Up
to three strings can result for each ENTRY statement. Leading and trailing
blanks in the concatenated string are always used.
When a prefix option is used, it applies not only to the text that immediately
follows the prefix option, but also to all subsequent text strings and text
commands. If the same prefix option appears more than once, then that prefix
overrides the last used prefix of the same name for the subsequent text strings
and text commands.
ENTRY Statement 1349
Restriction The maximum length for the entry text is 512 characters in SAS
9.4 and earlier releases. Starting with SAS 9.4M1, this restriction is
removed.
Note Leading spaces are preserved, and trailing spaces are stripped.
Optional Arguments
AUTOALIGN=NONE | AUTO | (location-list)
specifies whether the text is automatically aligned within its parent when
nested within an overlay-type layout. For more information about how child
positions are determined in an overlay-type layout, see the “LAYOUT OVERLAY
Statement” on page 159.
NONE
does not automatically align the text within the area.
AUTO
within the parent layout, attempts to center the text in the area that is
farthest from any surrounding data point markers.
(location-list)
within the available area, restricts the text’s possible locations to those
locations in the specified location-list, and uses the location-list position
that least collides with the other graphics features in the area.
Default NONE
Requirement For this option to take effect, the ENTRY statement must be in a
LAYOUT OVERLAY or LAYOUTOVERLAYEQUATED block.
BACKGROUNDCOLOR=style-reference | color
specifies the color of the text background.
1350 Chapter 11 / Text Statements
style-reference
specifies a style reference in the form style-element:style-attribute.
Interaction OPAQUE= TRUE must be in effect in order for the color to be seen.
By default, OPAQUE=FALSE.
BORDER=TRUE | FALSE
specifies whether a border is displayed around the text.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Default CENTER
Interaction This option is ignored when AUTOALIGN= is not NONE and the
parent layout is an overlay-type layout.
OPAQUE=TRUE | FALSE
specifies whether the text background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
specifies that the default outside padding for this component is used.
ENTRY Statement 1351
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the entry border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is reserved inside the entry border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the entry border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
1352 Chapter 11 / Text Statements
Note Sides that are not assigned padding are padded with the default
amount.
Interaction The bounding box is the determined by the size of the text in the
current font plus any horizontal and vertical padding. See
TEXTATTRS= and PAD= .
Notes This option can be used as both a prefix option and a statement option.
When used as a prefix option, it overrides the statement option.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
Default CENTER
ENTRY Statement 1353
Interaction This option is ignored when AUTOALIGN= is not NONE and the
parent layout is an overlay-type layout.
Prefix Options
HALIGN=CENTER | LEFT | RIGHT
specifies the horizontal alignment of the text that follows.
Text Commands
{ SUB "string" | dynamic }
text-command that specifies that the string or dynamic is to appear as subscript
text.
See “Rules for Unicode and Special Character Specifications” on page 1342
Example entry "y = " b{sub "0"} " + b" {sub "1"} "x";
See “Rules for Unicode and Special Character Specifications” on page 1342
Example entry "R" {sup "2"} " = " {format (6.4) RSQUARED} ;
"hex-string"x
a four-byte hexadecimal constant that represents a UNICODE character in
the current font.
keyword
a SAS keyword for a UNICODE character.
dynamic
a dynamic variable that resolves to either "hex-string"x or a keyword for a
UNICODE character.
Details
An ENTRY statement creates one line of text in the plot area. The statement must
be specified within a LAYOUT, HEADER, SIDEBAR, or CELL statement block. It
cannot be specified outside of one of these blocks, where global statements like
ENTRYTITLE and ENTRYFOOTNOTE are used.
The text line specified in an ENTRY statement can be made of several pieces of the
text called text-items. Statement options that are used establish properties for the
entire line of text (that is, all text-items). These properties can be overridden with
prefix-options that are specific to one or more text-items. See “Required Argument”
on page 1348 for more information.
You can specify an ENTRY statement inside or outside of a nested statement block:
n When you specify an ENTRY statement inside a nested LAYOUT, HEADER,
SIDEBAR, or CELL statement block, then, by default, the text is placed inside
the bounding area of the results that the nested statement block creates.
n When you specify an ENTRY statement outside of a nested LAYOUT, HEADER,
SIDEBAR, or CELL statement block, then the text is placed outside of the
bounding area of the results that the nested statement block creates.
Example Program
proc template;
define statgraph entry;
begingraph;
layout overlay;
histogram weight;
endlayout;
endgraph;
end;
run;
ENTRYFOOTNOTE Statement
Displays a footnote.
Requirement: You must place the ENTRYFOOTNOTE statement directly inside the BEGINGRAPH
block. Do not embed it in any other GTL statement block.
Syntax
ENTRYFOOTNOTE text-item <text-item …> </options>;
Text options
HALIGN=CENTER | LEFT | RIGHT
as a statement option, specifies the horizontal alignment of the text. As a
prefix-option, specifies the horizontal alignment of individual text-items.
HALIGNCENTER=AUTO | GRAPH
specifies whether the text is centered automatically by the system or is
always centered in the graph area.
SHORTTEXT=(text-item <...text-item>)
specifies alternate text to use if the specified text is too long for the
output width.
ENTRYFOOTNOTE Statement 1357
Required Argument
text-item <…text-item>
specifies one or more pieces of text for the footnote. Each text-item has the
following form:
Each piece of text can have multiple prefix options that precede the piece of
text. A piece of text is either a string literal, a dynamic, or a text command. All
text-items with the same HALIGN= setting are concatenated into one string. Up
to three strings can result for each ENTRY statement. Leading and trailing
blanks in the concatenated string are always used.
When a prefix option is used, it applies not only to the text that immediately
follows the prefix option, but also to all subsequent text strings and text
commands. If the same prefix option appears more than once, then that prefix
overrides the last used prefix of the same name for the subsequent text strings
and text commands.
Restriction The maximum length for the footnote text is 512 characters in
SAS 9.4 and earlier releases. Starting with SAS 9.4M1, this
restriction is removed.
Note Leading spaces are preserved, and trailing spaces are stripped.
Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the text background.
style-reference
specifies a style reference in the form style-element:style-attribute.
Interaction OPAQUE= TRUE must be in effect in order for the color to be seen.
By default, OPAQUE=FALSE.
BORDER=TRUE | FALSE
specifies whether a border is displayed around the text.
1358 Chapter 11 / Text Statements
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Default CENTER
HALIGNCENTER=AUTO | GRAPH
specifies whether the text is centered automatically by the system or is always
centered in the graph area.
AUTO
specifies that the system determines how the text is centered.
GRAPH
specifies that the text is always centered in the graph area.
Default AUTO
Interaction The prefix option HALIGN= must specify CENTER for this option to
have any effect.
OPAQUE=TRUE | FALSE
specifies whether the text background is opaque (TRUE) or transparent
(FALSE).
ENTRYFOOTNOTE Statement 1359
Default FALSE
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the entry border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is reserved inside the entry border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the entry border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
1360 Chapter 11 / Text Statements
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
SHORTTEXT=(text-item <...text-item>)
specifies alternate text to use if the specified text is too long for the output
width. If the shortened text is itself too long, then it is truncated.
Notes This option can be used as both a prefix option and a statement option.
When used as a prefix option, it overrides the statement option.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
WRAP
specifies that the text wraps to the next line(s).
SHORT
specifies that the text indicated by the SHORTTEXT= option be substituted
when the text does not fit.
Requirement You must specify the SHORTTEXT= option for this option to
take effect.
TRUNCATE
specifies that the text is truncated to make it fit.
Default WRAP
Prefix Options
HALIGN=CENTER | LEFT | RIGHT
specifies the horizontal alignment of the text that follows.
Text Commands
{ SUB "string" | dynamic }
text-command that specifies that the string or dynamic is to appear as subscript
text.
See “Rules for Unicode and Special Character Specifications” on page 1342
Example entryfootnote "y = " b{sub "0"} " + b" {sub "1"} "x";
See “Rules for Unicode and Special Character Specifications” on page 1342
"hex-string"x
a four-byte hexadecimal constant that represents a UNICODE character in
the current font.
keyword
a SAS keyword for a UNICODE character.
dynamic
a dynamic variable that resolves to either "hex-string"x or a keyword for a
UNICODE character.
Details
The ENTRYFOOTNOTE statement places footnote text below the graphical area.
More than one ENTRYFOOTNOTE statement can be used. Footnotes appear in the
order of the ENTRYFOOTNOTE statements within the template.
n All ENTRYFOOTNOTE statements that appear in the template are gathered and
placed in the ENTRYFOOTNOTE area.
n The placement of an ENTRYFOOTNOTE statement is relevant only in relation
to other ENTRYFOOTNOTE statements.
n As the number of ENTRYFOOTNOTE statements increases, the size of the
graphical area is reduced.
Footnotes always span the entire width of the output. By default, footnotes are
“center-aligned,” based on the type of the outermost layout. The meaning of
“center-aligned” varies by layout type and the number of columns in the layout:
Example Program
proc template;
define statgraph entryfootnote;
begingraph;
layout overlay;
histogram weight;
endlayout;
endgraph;
end;
run;
ENTRYTITLE Statement
Displays a title.
ENTRYTITLE Statement 1365
Requirement: You must place the ENTRYTITLE statement directly inside the BEGINGRAPH
block. Do not embed it in any other GTL statement block.
Syntax
ENTRYTITLE text-item <text-item …> </options>;
Text options
HALIGN=CENTER | LEFT | RIGHT
as a statement option, specifies the horizontal alignment of the text. As a
prefix-option, specifies the horizontal alignment of individual text-items.
HALIGNCENTER=AUTO | GRAPH
specifies whether the text is centered automatically by the system or is
always centered in the graph area.
SHORTTEXT=(text-item <…text-item>)
specifies alternate text to use if the specified text is too long for the
output width. If the shortened text is itself too long, then it is truncated.
TEXTFITPOLICY=WRAP | SHORT | TRUNCATE
specifies how to handle text that is too long to fit in the output width.
1366 Chapter 11 / Text Statements
Required Argument
text-item <text-item …>
specifies one or more pieces of text for the entry. Each text-item has the
following form:
Each piece of text can have multiple prefix options that precede the piece of
text. A piece of text is either a string literal, a dynamic, or a text command. All
text-items with the same HALIGN= setting are concatenated into one string. Up
to three strings can result for each ENTRY statement. Leading and trailing
blanks in the concatenated string are always used.
When a prefix option is used, it applies not only to the text that immediately
follows the prefix option, but also to all subsequent text strings and text
commands. If the same prefix option appears more than once, then that prefix
overrides the last used prefix of the same name for the subsequent text strings
and text commands.
Restriction The maximum length for the title text is 512 characters in SAS 9.4
and earlier releases. Starting with SAS 9.4M1, this restriction is
removed.
Note Leading spaces are preserved, and trailing spaces are stripped.
See Chapter 10, “Managing Text Items,” on page 1337 for more
information and several examples.
Optional Arguments
BACKGROUNDCOLOR=style-reference | color
specifies the color of the text background.
style-reference
specifies a style reference in the form style-element:style-attribute.
Interaction OPAQUE= TRUE must be in effect in order for the color to be seen.
By default, OPAQUE=FALSE.
BORDER=TRUE | FALSE
specifies whether a border is displayed around the text.
Default FALSE
ENTRYTITLE Statement 1367
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER= TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Default CENTER
HALIGNCENTER=AUTO | GRAPH
specifies whether the text is centered automatically by the system or is always
centered in the graph area.
AUTO
specifies that the system determines how the text is centered.
GRAPH
specifies that the text is always centered in the graph area.
Default AUTO
Interaction The prefix option HALIGN= must specify CENTER for this option to
have any effect.
OPAQUE=TRUE | FALSE
specifies whether the text background is opaque (TRUE) or transparent
(FALSE).
Default FALSE
1368 Chapter 11 / Text Statements
Interaction When this option is set to FALSE, the background color is not used.
See “boolean ” on page xii for other Boolean values that you can use.
AUTO
specifies that the default outside padding for this component is used.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the entry border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
Default AUTO
PAD=dimension | (pad-options)
specifies the amount of extra space that is reserved inside the entry border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the entry border.
(pad-options)
a space-separated list of one or more name-value pair pad options, enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space to add to the left side.
ENTRYTITLE Statement 1369
RIGHT=dimension
specifies the amount of extra space to add to the right side.
TOP=dimension
specifies the amount of extra space to add to the top.
BOTTOM=dimension
specifies the amount of extra space to add to the bottom.
Note Sides that are not assigned padding are padded with the default
amount.
SHORTTEXT=(text-item <…text-item>)
specifies alternate text to use if the specified text is too long for the output
width. If the shortened text is itself too long, then it is truncated.
Notes This option can be used as both a prefix option and a statement option.
When used as a prefix option, it overrides the statement option.
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
WRAP
specifies that the text wraps to the next line(s).
SHORT
specifies that the text indicated by the SHORTTEXT= option be substituted
when the text does not fit.
Requirement You must specify the SHORTTEXT= option for this option to
take effect.
TRUNCATE
specifies that the text is truncated to make it fit.
Default WRAP
Prefix Options
HALIGN=CENTER | LEFT | RIGHT
specifies the horizontal alignment of the text that follows.
Text Commands
{ SUB "string" | dynamic }
text-command that specifies that the string or dynamic is to appear as subscript
text.
See “Rules for Unicode and Special Character Specifications” on page 1342
Example entrytitle "y = " b{sub "0"} " + b" {sub "1"} "x";
See “Rules for Unicode and Special Character Specifications” on page 1342
"hex-string"x
a four-byte hexadecimal constant that represents a UNICODE character in
the current font.
keyword
a SAS keyword for a UNICODE character.
dynamic
a dynamic variable that resolves to either "hex-string"x or a keyword for a
UNICODE character.
Details
The ENTRYTITLE statement places title text above the graphical area. More than
one ENTRYTITLE statement can be used. Titles appear in the order of the
ENTRYTITLE statements within the template.
n All ENTRYTITLE statements that appear in the template are gathered and
placed in the ENTRYTITLE area.
n The placement of an ENTRYTITLE statement is relevant only in relation to
other ENTRYTITLE statements.
n As the number of ENTRYTITLE statements increases, the size of the graphical
area is reduced.
Titles always span the entire width of the output. By default, titles are “center-
aligned,” based on the type of the outermost layout. The meaning of “center-
aligned” varies by layout type and the number of columns in the layout:
Example Program
proc template;
define statgraph entrytitle;
begingraph;
layout overlay;
histogram weight;
endlayout;
endgraph;
end;
run;
PART 8
Chapter 12
Custom Marker Definition Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1377
1376
1377
12
Custom Marker Definition
Statements
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1377
SYMBOLCHAR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1377
SYMBOLIMAGE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1384
Dictionary
SYMBOLCHAR Statement
Defines a marker symbol using a Unicode character so that the symbol can be referenced in other
statements.
Requirement: The SYMBOLCHAR statement must be a child of the BEGINGRAPH block. It cannot
be embedded in any other GTL statement block.
Note: This statement is valid starting in SAS 9.4M1.
Syntax
SYMBOLCHAR NAME=marker-name CHAR="""hex-stringx | keyword | dynamic
</ options>;
1378 Chapter 12 / Custom Marker Definition Statements
Required Arguments
NAME=marker-name
specifies a name for the marker symbol. The name can be used in statements
that support marker symbols.
Interaction If the name matches one of the system-provided symbol names such
as CIRCLE, then the system symbol is replaced by the user-defined
symbol. See “Marker Options” on page 1604 for a list of the system-
provided symbols.
"hex-string"x
specifies a four-byte hexadecimal constant that represents a Unicode
character in the current font.
You can find a complete listing of the Unicode hexadecimal constants at the
following URL:http://www.unicode.org/charts/charindex.html
keyword
specifies a SAS keyword for a Unicode character.
dynamic
specifies a reference to a dynamic variable that resolves to either a "hex-
string"x constant or a Unicode character keyword.
Tip This statement attempts to access the specified Unicode value in the
current font. Some fonts do not support accessing characters by using their
Unicode value. Other fonts support only a limited set of Unicode values. If
the Unicode value is not accessible, then this statement might be ignored
or a nonprintable character might be substituted.
Optional Arguments
HOFFSET=number
specifies a horizontal offset for the marker symbol.
Range -0.5–+0.5, where 0.5 represents one-half of the original marker size.
Interaction Starting with SAS 9.4M3, the specified offset is also applied to the
marker symbol that is displayed in the legend.
SYMBOLCHAR Statement 1379
Notes Prior to SAS 9.4M3, a positive offset moves the marker symbol
bounding box to the right. A negative offset moves it to the left.
Starting with SAS 9.4M3, a positive offset moves the marker symbol
to the right within its bounding box, and a negative offset moves it
to the left. The bounding box remains centered on the data point.
After the offset, size, and rotation are applied to the marker symbol,
any portion of the symbol that falls outside of the marker bounding
box is clipped.
Tip If clipping occurs, use this option, the VOFFSET= and SCALE=
options, and the suboption SIZE= in the MARKERATTRS= option to
remove the clipping.
ROTATE=number
specifies the angle of rotation for the marker symbol in degrees. Positive angles
are measured in the counter-clockwise direction, and negative angles are
measured in the clockwise direction.
Note An angle that exceeds 360 degrees in absolute value can be specified.
SCALE=number
specifies a scale factor for the marker symbol as a percentage. The scale factor
is applied to the character's height and width.
Note The outer edges of the image might be clipped by the bounding box
when a large scale factor is specified.
Restriction Only the text attributes FAMILY=, STYLE=, and WEIGHT= are
used. The COLOR= and SIZE= text attributes are derived from the
plot statement's MARKERATTRS= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
VOFFSET=number
specifies a vertical offset for the marker symbol.
Range -0.5–+0.5, where 0.5 represents one-half of the original marker size.
1380 Chapter 12 / Custom Marker Definition Statements
Interaction Starting with SAS 9.4M3, the specified offset is also applied to the
marker symbol that is displayed in the legend.
Notes Prior to SAS 9.4M3, a positive offset moves the marker symbol
bounding box up. A negative offset moves it down.
Starting with SAS 9.4M3, a positive offset moves the marker symbol
up within its bounding box, and a negative offset moves it down. The
bounding box remains centered on the data point. After the offset,
size, and rotation are applied to the marker symbol, any portion of
the symbol that falls outside of the marker bounding box is clipped.
Tip If clipping occurs, use this option, the HOFFSET= and SCALE=
options, and the suboption SIZE= in the MARKERATTRS= option to
remove the clipping.
Details
The SYMBOLCHAR statement defines a custom marker symbol from a Unicode
character. You can use the marker symbol that is created in the following options:
n the DATASYMBOLS= option in the BEGINGRAPH statement
Symbol specifications are not checked for uniqueness. More than one
SYMBOLCHAR statement can define the same character. Therefore, you can use
SYMBOLCHAR statements in IF/ELSE statements. Symbol specifications also are
not validated at compile time. An invalid specification might not generate a warning
when the output is rendered and might create unexpected results.
You can use the COLOR=, SIZE=, and TRANSPARENCY= suboptions of the
MARKERATTRS= option to modify the appearance of markers that are created by
the SYMBOCHAR statement. The WEIGHT= suboption has no effect on these
markers.
The markers are clipped to the original marker size after rotation, scaling, and
offsets are applied. If clipping occurs, then you can use the SIZE= suboptions of the
MARKERATTRS= option in the plot statement and the SCALE= option in the
SYMBOLCHAR statement to adjust the size and scaling to eliminate the clipping.
SYMBOLCHAR Statement 1381
Example Program
/* Summarize the data in SASHELP.FAILURE to compute the
failure count by day and process */
proc sort data=sashelp.failure out=temp;
by day process;
run;
data failure;
length stat $20;
set failure;
if (count <= (&target*1.2)) then
stat=strip(cat(substr(process,index(process,' '),2),"-NORM"));
if (count > (&target*1.2)) then
stat=strip(cat(substr(process,index(process,' '),2),"-HIGH"));
label day="Weekday" count="Failure Count" stat="Status";
run;
/* Define the template */
proc template;
define statgraph failures;
begingraph;
/* Define the norm/high marker symbols */
symbolchar name=norm char='2714'x;
symbolchar name=high char='2718'x;
/* Create legend entries for the norm/high markers */
legenditem type=marker name="norm" /
markerattrs=(symbol=norm size=15pt color=green)
label="Normal Failure Count";
legenditem type=marker name="high" /
markerattrs=(symbol=high size=15pt color=red)
label="High Failure Count";
Program Description
Here is the SAS code for this example.
Create the graph data. The data in Sashelp.Failure is the source data. To get the
daily counts, the data is summarized by weekday and process. The Stat column is
then added to indicate whether the count is acceptable or high. Acceptable values
are values that do not exceed 120% of the target value. Values over 120% are
considered high. Acceptable values are A-NORM and B-NORM, and high values are
A-HIGH and B-HIGH, where A and B identify the process.
/* Summarize the data in SASHELP.FAILURE to compute the
failure count by day and process */
proc sort data=sashelp.failure out=temp;
by day process;
run;
Define the custom marker symbols. The NAME= option specifies an identifier for
the markers, and the CHAR= option specifies the Unicode value. Unicode value
'2714'x specifies a heavy check mark, and value '2718'x specifies a heavy ballot X.
/* Define the norm/high marker symbols */
symbolchar name=norm char='2714'x;
symbolchar name=high char='2718'x;
Create legend entries for the custom markers. Suboption SYMBOL= in the
MARKERATTRS= option specifies the identifier of the custom markers.
/* Create legend entries for the norm/high markers */
legenditem type=marker name="norm" /
markerattrs=(symbol=norm size=15pt color=green)
label="Normal Failure Count";
1384 Chapter 12 / Custom Marker Definition Statements
Create a discrete attribute map to map the custom markers to the Stat column
values. Suboption SYMBOL= in the MARKERATTRS= option specifies the identifier
of the custom markers. Suboption COLOR= sets the color of the Unicode marker
character and the associated data label. The DISCRETEATTRVAR statement
creates attribute map variable STATUS.
/* Define an attribute map for the status markers */
discreteattrmap name="statsymmap";
value "A-NORM" / markerattrs=(symbol=norm color=green);
value "B-NORM" / markerattrs=(symbol=norm color=green);
value "A-HIGH" / markerattrs=(symbol=high color=red);
value "B-HIGH" / markerattrs=(symbol=high color=red);
enddiscreteattrmap;
discreteattrvar attrvar=status var=stat attrmap="statsymmap" ;
Define the graph and close the template definition. The SCATTERPLOT statement
GROUP= option references the STATUS attribute map variable. The EVAL
statement in the Y= option positions each character just above the top of its bar.
The SIZE= suboption of the MARKERATTRS= option sets the marker size. The
custom markers are included in the DISCRETELEGEND statement.
/* Define the graph */
entrytitle "Daily Failure Report By Process";
entryfootnote "A failure count that is more than 120% of the
target is considered high.";
layout overlay / yaxisopts=(offsetmax=0.1);
barchartparm category=day response=count / name="barchart"
group=process groupdisplay=cluster;
scatterplot x=day y=eval(count+2) / datalabel=count
group=status
groupdisplay=cluster markerattrs=(size=15pt);
referenceline y=&target /
lineattrs=(color=lightred pattern=dot)
curvelabel="Target";
discretelegend "barchart" "norm" "high" / down=2
order=columnmajor;
endlayout;
endgraph;
end;
run;
SYMBOLIMAGE Statement
Defines a marker symbol using an image file so that the image can be referenced in other statements.
SYMBOLIMAGE Statement 1385
Syntax
SYMBOLIMAGE NAME=marker-name IMAGE="image-file-spec" < / options >;
Required Arguments
NAME=marker-name
specifies a name for the marker symbol. The name can be used in statements
that support marker symbols.
Interaction If the name matches one of the system-provided symbol names such
as CIRCLE, then the system symbol is replaced by the user-defined
symbol. See “Marker Options” on page 1604 for a list of the system-
provided symbols.
IMAGE="image-file-spec"
specifies the name and location of the image file. The supported image types
are GIF, JPEG, and PNG.
The image file must be located on the local file system. URL
access is not supported.
Example image="c:\temp\saslogo.gif"
Optional Arguments
HOFFSET=number
specifies a horizontal offset for the marker symbol.
Range -0.5–+0.5, where 0.5 represents one-half of the original marker size.
Notes A positive offset moves the marker symbol bounding box to the right. A
negative offset moves it to the left.
ROTATE=number
specifies the angle of rotation for the marker symbol in degrees. Positive angles
are measured in the counter-clockwise direction, and negative angles are
measured in the clockwise direction.
Note An angle that exceeds 360 degrees in absolute value can be specified.
SCALE=number
specifies a scale factor for the marker symbol as a percentage. The scale factor
is applied to the character's height and width.
Note The outer edges of the image might be clipped by the bounding box
when a large scale factor is specified.
VOFFSET=number
specifies a vertical offset for the marker symbol.
Range -0.5–+0.5, where 0.5 represents one-half of the original marker size.
Notes A positive offset moves the marker symbol bounding box up. A
negative offset moves it down.
Details
The SYMBOLIMAGE statement defines a custom marker symbol from an image
that is stored in an image file. The image file must exist on the local file system.
URL access is not supported. The supported image formats are GIF, JPG, and PNG.
The marker symbol that is created can be used in the following options:
n the DATASYMBOLS= option in the BEGINGRAPH statement
Symbol specifications are not checked for uniqueness. More than one
SYMBOLIMAGE statement can define the same character. Therefore, you can use
SYMBOLIMAGE statements in IF/ELSE statements.
SYMBOLIMAGE Statement 1387
The following options normally affect the appearance of markers. However, they
have no effect on image marker symbols that are created by the SYMBOLIMAGE
statement.
n the BEGINGRAPH statement DATACONTRASTCOLORS= option
The markers are clipped to the original marker size after rotation, scaling, and
offsets are applied. If clipping occurs, then you can use the SIZE= suboptions of the
MARKERATTRS= option in the plot statement and the SCALE= option in the
SYMBOLIMAGE statement to adjust the size and scaling to eliminate the clipping.
Example Program
/* Summarize the data in SASHELP.FAILURE to compute the
failure count by day and process */
proc sort data=sashelp.failure out=temp;
by day process;
run;
Program Description
Here is the SAS code for this example.
Create the graph data. The data in Sashelp.Failure is the source data. To get the
daily counts, the data is summarized by weekday and process. The Stat column is
then added to indicate whether the count is acceptable or high. Acceptable values
are values that do not exceed 120% of the target value. Values over 120% are
considered high. Acceptable values are A-NORM and B-NORM, and high values are
A-HIGH and B-HIGH, where A and B identify the process.
/* Summarize the data in SASHELP.FAILURE to compute the
failure count by day and process */
proc sort data=sashelp.failure out=temp;
by day process;
run;
Define the custom marker symbols. The NAME= option specifies an identifier for
the markers, and the IMAGE= option specifies the image file. The VOFFSET= option
raises the markers 50% from their data points in order to prevent them from
overlapping the bars in the bar chart.
/* Define the norm/high marker symbols */
symbolimage name=norm image="C:\temp\check_green.gif" /
voffset=0.5;
symbolimage name=high image="C:\temp\alert_orange.gif" /
voffset=0.5;
Create legend entries for the custom markers. Suboption SYMBOL= in the
MARKERATTRS= option specifies the identifier of the custom markers.
/* Create legend entries for the norm/high markers */
legenditem type=marker name="norm" /
markerattrs=(symbol=norm size=16px)
label="Normal Failure Count";
legenditem type=marker name="high" /
markerattrs=(symbol=high size=16px)
label="High Failure Count";
Create a discrete attribute map to map the custom markers to the Stat column
values. Suboption SYMBOL= in the MARKERATTRS= option specifies the identifier
of the custom markers. Suboption COLOR= sets the color of the associated data
label. It does not affect the color of the image. The DISCRETEATTRVAR statement
creates attribute map variable STATUS.
/* Define an attribute map for the status markers
Note: COLOR= affects marker labels only in this case. */
discreteattrmap name="statsymmap";
value "A-NORM" / markerattrs=(symbol=norm color=green);
value "B-NORM" / markerattrs=(symbol=norm color=green);
value "A-HIGH" / markerattrs=(symbol=high color=orange);
value "B-HIGH" / markerattrs=(symbol=high color=orange);
enddiscreteattrmap;
discreteattrvar attrvar=status var=stat attrmap="statsymmap";
Define the graph and close the template definition. The SCATTERPLOT statement
GROUP= option references the STATUS attribute map variable. The SIZE=
suboption of the MARKERATTRS= option sets the marker size. The custom markers
are included in the DISCRETELEGEND statement.
/* Define the graph */
entrytitle "Daily Failure Report By Process";
entryfootnote "A failure count that is more than 120% of the
target is considered high.";
layout overlay / yaxisopts=(offsetmax=0.1);
barchartparm category=day response=count / name="barchart"
group=process groupdisplay=cluster;
scatterplot x=day y=count / datalabel=count group=status
groupdisplay=cluster markerattrs=(size=16px);
SYMBOLIMAGE Statement 1391
referenceline y=&target /
lineattrs=(color=lightred pattern=dot)
curvelabel="Target";
discretelegend "barchart" "norm" "high" / down=2
order=columnmajor;
endlayout;
endgraph;
end;
run;
PART 9
Draw Statements
Chapter 13
Key Concepts for Using Draw Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1395
Chapter 14
Draw Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1405
1394
1395
13
Key Concepts for Using Draw
Statements
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1395
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1395
Types of Elements That Can Be Drawn . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1398
About the Drawing Space and Drawing Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1398
How the Drawn Elements Are Anchored . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1401
About Drawing Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1402
Introduction
The draw statements enable you to customize a graph by drawing visual elements
anywhere within the graph. The following sections provide a comprehensive
example and a brief overview to the major drawing concepts. For more details
about the individual draw statements and a simple example of each, see the
discussion for each individual statement. For complete usage information for the
draw statements, consult the SAS Graph Template Language: User’s Guide.
Example
The following example shows a bar chart of the top global automobile makers in
2008. To focus the graph on the 2008 merger between Chrysler and Fiat, the
example uses DRAWRECTANGLE to highlight the three bars in the chart that
correspond to the unit sales for the two auto makers. The example also uses a
DRAWARROW statement and two BEGINPOLYLINE blocks to point to the sales
1396 Chapter 13 / Key Concepts for Using Draw Statements
All of the draw statements in this example use the data space (see “About the
Drawing Space and Drawing Units” on page 1398 ) to integrate the drawn elements
into the graph’s data area.
/* Create the data and the macro variables for Chrysler, Fiat, and
Chrysler+Fiat widths */
data mydata;
length automaker $30;
input automaker $ 1-30 million_units;
FORMAT million_units 3.1;
select (automaker);
when ("Fiat") do;
colorvar=1;
call symput( "fwidth", million_units);
end;
when ("Chrysler") do;
colorvar=1;
call symput( "cwidth", million_units);
end;
when ("Fiat + Chrysler") do;
colorvar=2;
Example 1397
datalines;
Toyota 8.7
GM 7.7
Volkswagen 6.0
Renault-Nissan 5.8
Ford 5.4
Fiat + Chrysler 4.5
Hyundai 4.2
Honda 3.8
PSA 3.2
Fiat 2.5
Suzuki 2.4
Chrysler 2.0
Daimler 1.9
BMW 1.4
Mazda 1.4
Mitsubishi 1.1
;
endpolyline;
drawarrow x1=eval(&cfwidth + 1.5) x2=eval(&cfwidth + 0.5)
y1="Fiat + Chrysler" y2="Fiat + Chrysler"
/ arrowheadscale=0.5 arrowheadshape=barbed;
drawtext "Alliance creates the #6 Global Automaker by volume" /
y="Honda" x=eval(&cfwidth+2.5) width=2 widthunit=data;
endlayout;
endlayout;
endgraph;
end;
Using these elements individually and especially by combining them, you can
describe the non-data aspects of your graph. For example, you can display a
company logo in a specified location within the graph. Or you can create custom
features that are difficult to create by other means—for example, you could draw a
broken axis. Using the draw statements creatively, you can direct viewer attention
to features of interest in the graph by drawing elements that highlight those
features.
The images that accompany the following descriptions all use pixel data units.
Each, however, was drawn in a different drawing space using this same LAYOUT
OVERLAY definition block:
layout overlay /
xaxisopts=(display=(line ticks tickvalues))
yaxisopts=(display=(line ticks tickvalues));
scatterplot x=height y=weight;
drawrectangle x=0 y=0 width=50 height=50 /
anchor=bottomleft display=(fill) fillattrs=(color=green)
transparency=0.75 widthunit=pixel heightunit=pixel ;
drawline x1=0 y1=0 x2=18 y2=18 / lineattrs=(color=red) ;
endlayout;
Drawin Drawing
g Space Units Description Example
Drawin Drawing
g Space Units Description Example
To specify the drawing space for both the X and the Y dimension, you use the
DRAWSPACE= option. To specify the drawing space individually for either the X or
the Y dimension, you use the options XSPACE=, X1SPACE=, X2SPACE=, YSPACE=,
Y1SPACE=, or Y2SPACE=, depending on the draw statement. The value that you set
on any of these options is a single composite value that specifies both the drawing
space and the drawing units in the following format:
<DrawingSpace><Units>
For the DATA drawing space, the VALUE drawing units specify that the coordinates
are expressed as values along the axis. When you specify the DATA drawing space,
you can use the draw statement’s XAXIS= and YAXIS= options to specify which
axis scale to use for the coordinates.
n If the specified axis does not exist in the plot or is not valid for the draw
statement's layout container, then the draw statement is ignored.
n For a discrete axis, if the statement’s specified X or Y value does not exist in the
data, then the draw statement is ignored.
n For a continuous axis, if the statement’s specified X or Y value does not exist in
the data, then the value is extrapolated.
When specifying the drawing space and drawing units, you can set a common
setting for all of the X and Y coordinates. Or you can specify different settings for
each individual coordinate. The DRAWSPACE= setting in the BEGINGRAPH
statement applies the global space and unit settings to all of the draw statements
within the BEGINGRAPH/ENDGRAPH block. The DRAWSPACE= setting in an
individual draw statement applies the space and unit setting only to the
coordinate(s) for that statement. Thus, for lines and arrows, the setting applies to
both the X1, Y1 coordinate and the X2, Y2 coordinate.
To specify the drawing space and drawing units separately for the X coordinate and
for the Y coordinate, use the XSPACE=, YSPACE=, X1SPACE=, Y1SPACE=,
X2SPACE=, and Y2SPACE= options, as applicable, in each draw statement. These
options override the DRAWSPACE= option.
The default anchor position is CENTER. To change the anchor position, use the
draw statement’s ANCHOR= option.
1402 Chapter 13 / Key Concepts for Using Draw Statements
To prevent a drawn element for blocking the view of other graphics elements in the
graph, you can use the draw statement’s TRANSPARENCY= option to add
transparency to the drawn element. With an appropriate transparency setting, you
should be able to see any graphics elements that are behind the drawn element.
Alternatively, you can use the draw statement’s LAYER= option to draw the
element in the back layer, which places the drawn element behind all other graphics
elements in the graph. For example, the following figure shows two different
versions of a graph that uses DRAWLINE to draw a diagonal line across the axis
area. The version to the left draws the line in the front layer, which causes the line
to cover some of the data labels in the graph and portions of the series line. The
version to the right uses LAYER=BACK to draw the line in the back layer. This
prevents the line from covering the data labels and the portions of the series line.
The following code fragment shows the code that positions the line in the back
layer:
layout overlay / walldisplay=(outline)
About Drawing Layers 1403
The Back Layer is Behind the Background. Although drawing elements in the back
layer prevents them from obstructing other data elements in the graph, it is not
always the right solution to the problem.
If a draw statement uses LAYER=BACK, then it draws the element behind all other
graphics elements, such as the layout background or a discrete legend’s
background. To ensure that the element is visible in the graph, you might have to do
one or more of the following:
n In overlay-type layouts or in a SCATTERPLOTMATRIX, you can use the parent
layout’s WALLDISPLAY= option to turn off the display of the plot wall. In the
example code just shown, WALLDISPLAY=(OUTLINE) displays an outline
around the graph wall but does not display the wall fill. Suppressing the fill
ensures that the drawn line is visible behind the plot wall.
n If a layout container uses OPAQUE=TRUE so that it can set visual attributes for
the background, then the opaque background covers and therefore hides any
drawn element that is behind the background. When assigning visual attributes
to a graph background, therefore, it might be better to use TRANSPARENCY=
rather than LAYER= to prevent drawn elements from covering other graphics
elements in the graph.
n If the results of a plot statement or other GTL-statement covers the drawn
element, then you can use transparency to reveal the drawn element. For
example, you could use a plot statement’s DATATRANSPARENCY= option to
set an appropriate transparency level for the plot.
1404 Chapter 13 / Key Concepts for Using Draw Statements
1405
14
Draw Statements
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1405
BEGINPOLYGON Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1405
BEGINPOLYLINE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1413
DRAWARROW Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1420
DRAWIMAGE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1427
DRAWLINE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1437
DRAWOVAL Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1444
DRAWRECTANGLE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1452
DRAWTEXT Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1461
Dictionary
BEGINPOLYGON Statement
Defines the starting point for drawing a polygon in the graph.
Syntax
BEGINPOLYGON X=constant | scalar-expression
Y=constant | scalar-expression </options>;
DRAW X=constant | scalar-expression
Y=constant | scalar-expression </options>;
<… more DRAW statements …>
ENDPOLYGON;
1406 Chapter 14 / Draw Statements
Axes options
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is
interpreted using the primary X-axis scale or to the secondary X (X2) axis
scale.
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is
interpreted using the primary Y-axis scale or to the secondary Y (Y2) axis
scale.
ODS options
URL="string" | string-expression
BEGINPOLYGON Statement 1407
specifies an HTML page that is displayed when the output of this draw
statement is selected.
Required Arguments
The following options are required in the BEGINPOLYGON statement and the DRAW
statement.
X=constant | scalar-expression
specifies the X value for a point in the polygon. When used in the
BEGINPOLYGON statement, it specifies the X value of the starting point of the
polygon.
Interaction The value that is set for this argument is interpreted using the
XSPACE= option. When XSPACE=DATAVALUE, the value is
interpreted using the XAXIS= option.
Y=constant | scalar-expression
specifies the Y value for a point in the polygon. When used in the
BEGINPOLYGON statement, it specifies the Y value of the starting point of the
polygon.
Interaction The value that is set for this argument is interpreted using the
YSPACE= option. When YSPACE=DATAVALUE, the value is
interpreted using the YAXIS= option.
Optional Arguments
The following options can be used in the BEGINPOLYGON statement.
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. If the X axis is discrete, then a positive offset is to the
right. If the Y axis is discrete, then a positive offset is up. If
REVERSE=TRUE on the X or Y axis, then the offset direction is also
reversed.
Restriction This option applies only when the options XSPACE= or YSPACE=
use DATAVALUE, and when X or Y are values on a discrete axis. For
nondiscrete axes, this option is ignored.
1408 Chapter 14 / Draw Statements
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
STANDARD
displays an outlined polygon.
ALL
displays an outlined, filled polygon.
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
OUTLINE
displays an outlined polygon
FILL
displays a filled polygon
Default STANDARD
Default LAYOUTPERCENT
Interactions This statement and all of the draw statements inherit the global
DRAWPSACE= setting from the DRAWSPACE= option in the
BEGINGRAPH statement. Setting this option changes the setting
for only this BEGINPOLYGON statement.
This option sets the default drawing space, but individual settings
in the X or Y dimension can be overridden by the XSPACE= and
YSPACE= options.
See “About the Drawing Space and Drawing Units” on page 1398
Tip The TRANSPARENCY= option sets the transparency for the fill and the
outline. You can combine this option with TRANSPARENCY= to set one
transparency for the outlines but a different transparency for the fill.
Example:
transparency=0.2 fillattrs=(transparency=0.6)
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
LAYER=FRONT | BACK
specifies the layer on which this BEGINPOLYGON block’s output is drawn.
FRONT
draws the output on top of the graph.
BACK
draws the output behind the background areas, such as a layout or legend
background.
Default FRONT
Tip For elements that are obstructed because they are in the back layer,
you can suppress the display of filled areas in the graph. You can also
use transparency to manage the element visibility. For more
information, see “About Drawing Layers” on page 1402 .
Interaction For this option to have any effect, the outline must be enabled by
the DISPLAY= option.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element .
TRANSPARENCY=number
specifies the degree of the transparency of this BEGINPOLYGON block’s output.
Default 0
Tip The FILLATTRS option can be used to set transparency for just the
polygon’s filled area. You can combine this option with FILLATTRS= to
set one transparency for the outlines but a different transparency for
the fill. Example:
transparency=0.2 fillattrs=(transparency=0.6)
1410 Chapter 14 / Draw Statements
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
"string"
string-expression
specifies a valid HTML page reference (HREF) for the graphical element that
is drawn by this draw statement.
Example http://www.sas.com
Restriction Links specified with URL= are not supported in SVG output in
HTML. In that case, use a raster image format such as PNG.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is interpreted
using the primary X-axis scale or to the secondary X (X2) axis scale.
Default X
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is interpreted
using the primary Y-axis scale or to the secondary Y (Y2) axis scale.
Default Y
DRAWSPACE Specifies a default drawing space and drawing units for the
drawn lines.
XSPACE Specifies the drawing space and drawing units for interpreting
the X value.
YSPACE Specifies the drawing space and drawing units for interpreting
the Y value.
Details
Statement Description
A polygon is built by using the BEGINPOLYGON statement to specify the polygon’s
starting X,Y coordinate, and then specifying the remaining points by nesting a series
of DRAW statements (see “DRAW Statement” on page 1411 ) within the
BEGINPOLYGON block. The block is closed with an ENDPOLYGON statement. To
manage the location and drawing units for the polygon, you can use the XAXIS=,
YAXIS=, XSPACE=, and YSPACE= options.
For general information about the types of elements that can be drawn with the
draw statements, the drawing space and drawing units that they use, and how the
drawn elements are anchored, see Chapter 13, “Key Concepts for Using Draw
Statements,” on page 1395 . For detailed usage information, consult the SAS Graph
Template Language: User’s Guide.
DRAW Statement
The nested DRAW statements within a BEGINPOLYGON block specify a series of
points for a polygon. Each DRAW statement draws a straight line from the previous
point to the endpoint that is specified in the DRAW statement's X and Y arguments.
The first DRAW statement starts its line from the X,Y point that is specified in the
BEGINPOLYGON statement.
You can specify as many DRAW statements as needed to complete the polygon. If
the last DRAW statement does not end at the first point in the polygon (specified
1412 Chapter 14 / Draw Statements
Example Program
proc template;
define statgraph discretelegend;
begingraph / drawspace=datavalue;
entrytitle "Iris Petal Dimensions";
layout overlayequated / equatetype=equate;
scatterplot x=petallength y=petalwidth / group=species
name="s";
ellipse x=petallength y=petalwidth / type=predicted alpha=.2
name="p80" legendlabel="80%" outlineattrs=graphconfidence;
BEGINPOLYLINE Statement 1413
BEGINPOLYLINE Statement
Defines the starting point for drawing a polyline in the graph.
Syntax
BEGINPOLYLINE X=constant | scalar-expression
Y=constant | scalar-expression </options>;
DRAW X=constant | scalar-expression
Y=constant | scalar-expression </options>;
<… more DRAW statements …>
ENDPOLYLINE;
LAYER=FRONT | BACK
specifies the layer on which this BEGINPOLYLINE block’s output is
drawn.
LINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the line attributes for this BEGINPOLYLINE block.
TRANSPARENCY=number
specifies the degree of the transparency of the BEGINPOLYLINE block’s
output.
Axes options
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is
interpreted using the primary X-axis scale or to the secondary X (X2) axis
scale.
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is
interpreted using the primary Y-axis scale or to the secondary Y (Y2) axis
scale.
ODS options
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
Required Arguments
The following options are required in the BEGINPOLYLINE statement and the DRAW
statement.
X=constant | scalar-expression
specifies the X value for the starting point in the polyline.
BEGINPOLYLINE Statement 1415
Interaction The value that is set for this argument is interpreted using the
XSPACE= option. When XSPACE=DATAVALUE, the value is
interpreted using the XAXIS= option.
Y=constant | scalar-expression
specifies the Y value for the starting point in the polyline.
Interaction The value that is set for this argument is interpreted using the
YSPACE= option. When YSPACE=DATAVALUE, the value is
interpreted using the YAXIS= option.
Optional Arguments
The following options can be used in the BEGINPOLYLINE statement.
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. If the X axis is discrete, then a positive offset is to the
right. If the Y axis is discrete, then a positive offset is up. If
REVERSE=TRUE on the X or Y axis, then the offset direction is also
reversed.
Restriction This option applies only when the options XSPACE= or YSPACE=
use DATAVALUE, and when X or Y are values on a discrete axis. For
nondiscrete axes, this option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
Default LAYOUTPERCENT
Interactions This statement and all of the draw statements inherit the global
DRAWPSACE= setting from the DRAWSPACE= option in the
BEGINGRAPH statement. Setting this option changes the setting
for only this BEGINPOLYLINE statement.
This option sets the default drawing space, but individual settings
in the X or Y dimension can be overridden by the XSPACE= and
YSPACE= options.
See “About the Drawing Space and Drawing Units” on page 1398
LAYER=FRONT | BACK
specifies the layer on which this BEGINPOLYLINE block’s output is drawn.
FRONT
draws the output on top of the graph.
BACK
draws the output behind the background areas, such as a layout or legend
background.
Default FRONT
Tip For elements that are obstructed because they are in the back layer,
you can suppress the display of filled areas in the graph. You can also
use transparency to manage the element visibility. For more
information, see “About Drawing Layers” on page 1402 .
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element .
TRANSPARENCY=number
specifies the degree of the transparency of the BEGINPOLYLINE block’s output.
Default 0
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
"string"
string-expression
specifies a valid HTML page reference (HREF) for the graphical element that
is drawn by this draw statement.
Example http://www.sas.com
Restriction Links specified with URL= are not supported in SVG output in
HTML. In that case, use a raster image format such as PNG.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is interpreted
using the primary X-axis scale or to the secondary X (X2) axis scale.
Default X
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is interpreted
using the primary Y-axis scale or to the secondary Y (Y2) axis scale.
Default Y
DRAWSPACE Specifies a default drawing space and drawing units for the
drawn lines.
XSPACE Specifies the drawing space and drawing units for interpreting
the X value.
YSPACE Specifies the drawing space and drawing units for interpreting
the Y value.
Details
Statement Description
A polyline is built by using the BEGINPOLYLINE statement to specify the polyline’s
starting X,Y coordinate, and then specifying the remaining points by nesting a series
of DRAW statements (see “DRAW Statement” on page 1418 ) within the
BEGINPOLYLINE block. The block is closed with an ENDPOLYLINE statement. To
manage the location and drawing units for the polyline, you can use the XAXIS=,
YAXIS=, XSPACE=, and YSPACE= options.
For general information about the types of elements that can be drawn with the
draw statements, the drawing space and drawing units that they use, and how the
drawn elements are anchored, see Chapter 13, “Key Concepts for Using Draw
Statements,” on page 1395 . For detailed usage information, consult the SAS Graph
Template Language: User’s Guide.
DRAW Statement
The nested DRAW statements within a BEGINPOLYLINE block specify a series of
points for a polyline. Each DRAW statement draws a straight line from the previous
point to the endpoint that is specified in the DRAW statement's X and Y arguments.
The first DRAW statement starts its line from the X,Y point that is specified in the
BEGINPOLYLINE statement. You can specify as many DRAW statements as needed
to complete the polyline.
The example also uses two DRAWTEXT statements to label the data points of
interest.
Example Program
proc template;
define statgraph drawoval;
begingraph / drawspace=datavalue;
entrytitle "Regression Fit Plot";
layout overlay;
modelband "myclm";
scatterplot x=height y=weight;
regressionplot x=height y=weight / alpha=0.01 clm="myclm";
drawtext "Alfred" / x=69 y=112 anchor=top;
drawtext "Barbara" / x=65.4 y=97 anchor=top width=15;
beginpolyline x=69 y=105 ;
draw x=69 y=85 ;
draw x=65.3 y=85 ;
draw x=65.3 y=90 ;
endpolyline ;
beginpolyline x=67 y=85 ;
draw x=67 y=78 ;
endpolyline ;
drawtext "New in Class" / x=67 y=77 anchor=top width=15;
endlayout;
endgraph;
end;
DRAWARROW Statement
Draws an arrow (a directed line segment) from one point to another point.
Syntax
DRAWARROW X1=constant | scalar-expression
Y1=constant | scalar-expression
X2=constant | scalar-expression
Y2=constant | scalar-expression < /options >;
Arrow options
ARROWHEADDIRECTION=OUT | IN | BOTH
specifies the direction of the arrowhead(s) at the end(s) of the arrow
shaft.
ARROWHEADSCALE=positive-number
specifies an arrowhead scale factor based on the thickness of the arrow
shaft.
ARROWHEADSHAPE=OPEN | CLOSED | FILLED | BARBED
specifies the shape of the arrowhead(s).
Axes options
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is
interpreted using the primary X-axis scale or to the secondary X (X2) axis
scale.
YAXIS=Y | Y2
DRAWARROW Statement 1421
ODS options
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
Required Arguments
X1=constant | scalar-expression
specifies the X value of one arrow-shaft endpoint.
Interactions This value that is set for this option is interpreted using the
X1SPACE= option.
Y1=constant | scalar-expression
specifies the Y value of one arrow-shaft endpoint.
Interactions This value that is set for this option is interpreted using the
Y1SPACE= option.
X2=constant | scalar-expression
specifies the X value of one arrow-shaft endpoint.
Interactions This value that is set for this option is interpreted using the
X2SPACE= option.
Y2=constant | scalar-expression
specifies the Y value of one arrow-shaft endpoint.
Interactions This value that is set for this option is interpreted using the
Y2SPACE= option.
Optional Arguments
ARROWHEADDIRECTION=OUT | IN | BOTH
specifies the direction of the arrowhead(s) at the end(s) of the arrow shaft.
OUT
specifies a single arrowhead drawn at (X2,Y2) and pointing away from
(X1,Y1)
IN
specifies a single arrowhead drawn at (X1,Y1) and pointing away from
(X2,Y2)
BOTH
specifies two arrowheads, one at the IN position and one at the OUT
position
DRAWARROW Statement 1423
Default OUT
Default OPEN
ARROWHEADSCALE=positive-number
specifies an arrowhead scale factor based on the thickness of the arrow shaft.
Default 1.0
Restriction The minimum size for arrowheads is 8 pixels. If you specify a value
for ARROWHEADSCALE= that scales the arrowhead below 8 pixels,
an 8-pixel arrowhead is used instead. There is no restriction on the
maximum size.
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. If the X axis is discrete, then a positive offset is to the
right. If the Y axis is discrete, then a positive offset is up. If
REVERSE=TRUE on the X or Y axis, then the offset direction is also
reversed.
Restriction This option applies only when the options X1SPACE=, X2SPACE=,
Y1SPACE=, or Y2SPACE= use DATAVALUE, and when X1, X2, Y1, or
Y2 are values on a discrete axis. For nondiscrete axes, this option is
ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
1424 Chapter 14 / Draw Statements
Default LAYOUTPERCENT
Interactions This statement and all of the draw statements inherit the global
DRAWPSACE= setting from the DRAWSPACE= option in the
BEGINGRAPH statement. Setting this option changes the setting
for only this draw statement.
This option sets the default drawing space, but individual settings
in the X or Y dimension can be overridden by the options
X1SPACE=, Y1SPACE=, X2SPACE=, or Y2SPACE=.
See “About the Drawing Space and Drawing Units” on page 1398
LAYER=FRONT | BACK
specifies the layer on which this draw statement’s output is drawn.
FRONT
draws the output on top of the graph.
BACK
draws the output behind the background areas, such as a layout or legend
background.
Default FRONT
Tip For elements that are obstructed because they are in the back layer,
you can suppress the display of filled areas in the graph. You can also
use transparency to manage the element visibility. For more
information, see “About Drawing Layers” on page 1402 .
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
TRANSPARENCY=number
specifies the degree of the transparency of this draw statement’s output.
Default 0
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
"string"
string-expression
specifies a valid HTML page reference (HREF) for the graphical element that
is drawn by this draw statement.
Example http://www.sas.com
Restriction Links specified with URL= are not supported in SVG output in
HTML. In that case, use a raster image format such as PNG.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is interpreted
using the primary X-axis scale or to the secondary X (X2) axis scale.
Default X
Interaction This option overrides the DRAWSPACE= setting only for the X1
value.
Interaction This option overrides the DRAWSPACE= setting only for the X2
value.
1426 Chapter 14 / Draw Statements
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is interpreted
using the primary Y-axis scale or to the secondary Y (Y2) axis scale.
Default Y
Interaction This option overrides the DRAWSPACE= setting only for the Y1
value.
Interaction This option overrides the DRAWSPACE= setting only for the Y2
value.
Details
A DRAWARROW statement draws a line (arrow shaft) from a specified starting
point (X1,Y1) to a specified ending point (X2,Y2). It also displays an arrowhead at
either or both ends of the line. DRAWARROW is similar to a DRAWLINE statement,
using many of the same options, but it has additional options for controlling the
arrowhead(s).
For general information about the types of elements that can be drawn with the
draw statements, the drawing space and drawing units that they use, and how the
drawn elements are anchored, see Chapter 13, “Key Concepts for Using Draw
Statements,” on page 1395 . For detailed usage information, consult the SAS Graph
Template Language: User’s Guide.
Example Program
proc template;
define statgraph arrow;
begingraph;
entrytitle "Micosoft Stock Prices between 2000 and 2002";
layout overlay;
seriesplot x=date y=close;
drawarrow x1="01NOV2001"d y1=75 x2="01NOV2001"d y2=64.21 /
x1space=datavalue y1space=wallpercent
x2space=datavalue y2space=datavalue
arrowheadshape=filled lineattrs=(color=red) ;
drawtext "Introduction of Windows XP" / width=25 anchor=bottom
border=true borderattrs=(color=red)
x="01NOV2001"d y=75 xspace=datavalue yspace=wallpercent;
endlayout;
endgraph;
end;
DRAWIMAGE Statement
Draws an image in the graph.
1428 Chapter 14 / Draw Statements
Syntax
DRAWIMAGE "image-file-spec" < /options >;
Axes options
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is
interpreted using the primary X-axis scale or to the secondary X (X2) axis
scale.
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is
interpreted using the primary Y-axis scale or to the secondary Y (Y2) axis
scale.
Location options
ANCHOR=CENTER | TOPLEFT | TOP | TOPRIGHT | LEFT | RIGHT |
BOTTOMLEFT | BOTTOM | BOTTOMRIGHT
specifies an anchor point for the image.
X=constant | scalar-expression
specifies the anchor point’s X coordinate.
Y=constant | scalar-expression
specifies the anchor point’s Y coordinate.
ODS options
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
Size options
HEIGHT=positive-number
specifies the height of the image’s bounding box.
HEIGHTUNIT=PERCENT | PIXEL | DATA
specifies whether the positive-number that is specified in the HEIGHT=
option is interpreted as a percentage value, a pixel value, or a value that
is in the units of the data.
SCALE=FIT | FITHEIGHT | FITWIDTH | TILE
specifies how the image is scaled within the bounding box.
SIZEUNIT=PERCENT | PIXEL | DATA
specifies whether the default units for the size of the image’s bounding
box are percentage values, or pixel values, or values that are in the unit of
the data.
WIDTH=positive-number
specifies the width of the image’s bounding box.
WIDTHUNIT=PERCENT | PIXEL | DATA
specifies whether the positive-number that is specified in the WIDTH=
option is interpreted as a percentage value, a pixel value, or a value that
is in the units of the data.
Required Argument
image-file-spec
specifies the name, image type, and location of the image. The image-file-spec
value must be enclosed in double quotation marks and must be specified as a
local, physical file path (for example, "c:\temp\saslogo.gif"). The supported
image types are GIF, JPEG, and PNG raster or bitmap format.
Restrictions URL access to image files is not supported. The image file must
exist on the file system.
In SAS 9.4 and earlier releases, you cannot use a dynamic variable
for the image-file-spec value. This restriction is removed starting
with SAS 9.4M1.
1430 Chapter 14 / Draw Statements
Optional Arguments
ANCHOR=CENTER | TOPLEFT | TOP | TOPRIGHT | LEFT | RIGHT | BOTTOMLEFT
| BOTTOM | BOTTOMRIGHT
specifies an anchor point for the image. The anchor point is relative to the
unrotated image. The anchor point can be at the center of the image or at eight
points on the border of the image bounding box. The following figure shows the
anchor points for TOPLEFT and LEFT.
The coordinates of the anchor point are set by the X= and Y= options, and by
the XSPACE= and YSPACE= options. The XAXIS= and YAXIS= option might
affect positioning when the XSPACE= or YSPACE= options are set to
DATAPIXEL, DATAPERCENT, or DATAVALUE.
The image has a fixed height and a fixed width, determined by the HEIGHT=,
HEIGHTUNIT=, WIDTH= and WIDTHUNIT= options. The height of the text
grows in a direction that is related to the anchor point. For example, if
ANCHOR=TOPLEFT, then the image height extends downward from the anchor
point and its width extends to the right. If ANCHOR=CENTER, then half the
image width and half the image height extend equally left and right, as well as
top to bottom from the anchor point. If ANCHOR=BOTTOM, then the image
height extends upward from the anchor point and the image width is centered at
the anchor point.
When the image is rotated, the anchor point remains relative to the unrotated
image while the image is rotated on its anchor point. See ROTATE= on page
1432.
Default CENTER
BORDER=TRUE | FALSE
specifies whether a border is drawn around the image.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER=TRUE must be set for this option to have any effect.
DRAWIMAGE Statement 1431
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. If the X axis is discrete, then a positive offset is to the
right. If the Y axis is discrete, then a positive offset is up. If
REVERSE=TRUE on the X or Y axis, then the offset direction is also
reversed.
Restriction This option applies only when the options XSPACE= or YSPACE=
use DATAVALUE, and when X or Y are values on a discrete axis. For
nondiscrete axes, this option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
Default LAYOUTPERCENT
Interactions This statement and all of the draw statements inherit the global
DRAWPSACE= setting from the DRAWSPACE= option in the
BEGINGRAPH statement. Setting this option changes the setting
for only this draw statement.
This option sets the default drawing space, but individual settings
in the X or Y dimension can be overridden by the options XSPACE=,
YSPACE=, HEIGHTUNIT=, or WIDTHUNIT=.
See “About the Drawing Space and Drawing Units” on page 1398
HEIGHT=positive-number
specifies the height of the image’s bounding box.
Default PERCENT
Interaction This setting combines with the YSPACE= setting to interpret the
height that is set in the HEIGHT= option.
LAYER=FRONT | BACK
specifies the layer on which this draw statement’s output is drawn.
FRONT
draws the output on top of the graph.
BACK
draws the output behind the background areas, such as a layout or legend
background.
Default FRONT
Tip For elements that are obstructed because they are in the back layer,
you can suppress the display of filled areas in the graph. You can also
use transparency to manage the element visibility. For more
information, see “About Drawing Layers” on page 1402 .
ROTATE=number
specifies the angle of rotation for the image, measured in degrees. The image is
rotated around its anchor point. The angle is measured from a horizontal line
passing through the anchor point of the image to the right. The following figure
shows the rotation of an image around a top anchor point.
Positive angles rotate the image counter clockwise, and negative angles rotate
the image clockwise. The angle specification can exceed 360 degrees in
absolute value.
Note If you specify the SVG format for your graph and your graph includes a
rotated image, then the graph is rendered as a bitmapped image rather
DRAWIMAGE Statement 1433
than an SVG image. In that case, a note is written to the SAS log
indicating the change in format.
FIT
scales the image to fit the bounding box.
FITHEIGHT
scales the image to fit the height of the bounding box.
The width is computed from the height and the image's aspect ratio.
FITWIDTH
scales the image to fit the width of the bounding box.
The height is computed from the width and the image's aspect ratio.
TILE
tiles the image as needed to fit the bounding image.
The last tile in a row or column might be clipped by the bounding box.
Default FIT
Default PERCENT
TRANSPARENCY=number
specifies the degree of the transparency of this draw statement’s output.
Default 0
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
"string"
string-expression
specifies a valid HTML page reference (HREF) for the graphical element that
is drawn by this draw statement.
Example http://www.sas.com
Restriction Links specified with URL= are not supported in SVG output in
HTML. In that case, use a raster image format such as PNG.
WIDTH=positive-number
specifies the width of the image’s bounding box.
Default PERCENT
Interaction This setting combines with the XSPACE= setting to interpret the
width that is set in the WIDTH= option.
X=constant | scalar-expression
specifies the anchor point’s X coordinate.
Default 50
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is interpreted
using the primary X-axis scale or to the secondary X (X2) axis scale.
DRAWIMAGE Statement 1435
Default X
Y=constant | scalar-expression
specifies the anchor point’s Y coordinate.
Default 50
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is interpreted
using the primary Y-axis scale or to the secondary Y (Y2) axis scale.
Default Y
Details
A DRAWIMAGE statement draws an image in a graph. By default, the image is
drawn in the center of the graph. You can change the default position with the
options ANCHOR=, X=, Y=, XSPACE=, and YSPACE=. By default, the image is drawn
in the actual image size. You can change the default size with the WIDTH= and
HEIGHT= options.
For general information about the types of elements that can be drawn with the
draw statements, the drawing space and drawing units that they use, and how the
1436 Chapter 14 / Draw Statements
drawn elements are anchored, see Chapter 13, “Key Concepts for Using Draw
Statements,” on page 1395 . For detailed usage information, consult the SAS Graph
Template Language: User’s Guide.
Example Graph
The following graph was generated by the “Example Program” on page 1436. The
example shows how to display an image in the bottom right corner of the graph
wall.
Example Program
proc template;
define statgraph image;
begingraph;
entrytitle "Regression Fit Plot";
layout overlay;
modelband "myclm";
scatterplot x=height y=weight / primary=true;
regressionplot x=height y=weight / alpha=0.01 clm="myclm";
drawimage "c:\temp\saslogo.gif" /
DRAWLINE Statement 1437
DRAWLINE Statement
Draws a line from one point to another point.
Syntax
DRAWLINE X1=constant | scalar-expression
Y1=constant | scalar-expression
X2=constant | scalar-expression
Y2=constant | scalar-expression < /options >;
Axes options
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is
interpreted using the primary X-axis scale or to the secondary X (X2) axis
scale.
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is
interpreted using the primary Y-axis scale or to the secondary Y (Y2) axis
scale.
ODS options
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
Required Arguments
X1=constant | scalar-expression
specifies the X value of the starting point for the line.
Interactions This value that is set for this option is interpreted using the
X1SPACE= option.
Y1=constant | scalar-expression
specifies the Y value of the starting point for the line.
Interactions This value that is set for this option is interpreted using the
Y1SPACE= option.
DRAWLINE Statement 1439
X2=constant | scalar-expression
specifies the X value of the endpoint for the line.
Interactions This value that is set for this option is interpreted using the
X2SPACE= option.
Y2=constant | scalar-expression
specifies the Y value of the endpoint for the line.
Interactions This value that is set for this option is interpreted using the
Y2SPACE= option.
Optional Arguments
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. If the X axis is discrete, then a positive offset is to the
right. If the Y axis is discrete, then a positive offset is up. If
REVERSE=TRUE on the X or Y axis, then the offset direction is also
reversed.
Restriction This option applies only when the options X1SPACE=, X2SPACE=,
Y1SPACE=, or Y2SPACE= use DATAVALUE, and when X1, X2, Y1, or
Y2 are values on a discrete axis. For nondiscrete axes, this option is
ignored.
1440 Chapter 14 / Draw Statements
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
Default LAYOUTPERCENT
Interactions This statement and all of the draw statements inherit the global
DRAWPSACE= setting from the DRAWSPACE= option in the
BEGINGRAPH statement. Setting this option changes the setting
for only this draw statement.
This option sets the default drawing space, but individual settings
in the X or Y dimension can be overridden by the options
X1SPACE=, Y1SPACE=, X2SPACE=, or Y2SPACE=.
See “About the Drawing Space and Drawing Units” on page 1398
LAYER=FRONT | BACK
specifies the layer on which this draw statement’s output is drawn.
FRONT
draws the output on top of the graph.
BACK
draws the output behind the background areas, such as a layout or legend
background.
Default FRONT
Tip For elements that are obstructed because they are in the back layer,
you can suppress the display of filled areas in the graph. You can also
use transparency to manage the element visibility. For more
information, see “About Drawing Layers” on page 1402 .
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
TRANSPARENCY=number
specifies the degree of the transparency of this draw statement’s output.
DRAWLINE Statement 1441
Default 0
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
"string"
string-expression
specifies a valid HTML page reference (HREF) for the graphical element that
is drawn by this draw statement.
Example http://www.sas.com
Restriction Links specified with URL= are not supported in SVG output in
HTML. In that case, use a raster image format such as PNG.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is interpreted
using the primary X-axis scale or to the secondary X (X2) axis scale.
Default X
Interaction This option overrides the DRAWSPACE= setting only for the X1
value.
Interaction This option overrides the DRAWSPACE= setting only for the X2
value.
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is interpreted
using the primary Y-axis scale or to the secondary Y (Y2) axis scale.
Default Y
Interaction This option overrides the DRAWSPACE= setting only for the Y1
value.
Interaction This option overrides the DRAWSPACE= setting only for the Y2
value.
Details
A DRAWLINE statement draws a line from a starting point that is specified with the
X1 and Y1 arguments, to an ending point that is specified with the X2 and Y2
arguments. DRAWLINE is similar to a DRAWARROW statement, using many of the
same options, but without the options for controlling the arrowhead(s).
For general information about the types of elements that can be drawn with the
draw statements, the drawing space and drawing units that they use, and how the
drawn elements are anchored, see Chapter 13, “Key Concepts for Using Draw
Statements,” on page 1395 . For detailed usage information, consult the SAS Graph
Template Language: User’s Guide.
can set LAYER= BACK and use the parent layout statement to turn off the display
of the wall.
Example Program
proc template;
define statgraph diagonal;
begingraph;
entrytitle "Open vs. Close Price for Intel Stock 2003";
layout overlay / walldisplay=(outline)
xaxisopts=(griddisplay=on)
yaxisopts=(griddisplay=on);
seriesplot x=open y=close / datalabel=date;
drawline x1=0 y1=0 x2=100 y2=100 /
x1space=wallpercent y1space=wallpercent
x2space=wallpercent y2space=wallpercent
lineattrs=GraphReference layer=back ;
endlayout;
endgraph;
end;
DRAWOVAL Statement
Draws an oval in the graph.
Syntax
DRAWOVAL X=constant | scalar-expression
Y=constant | scalar-expression
WIDTH=constant | scalar-expression
HEIGHT=constant | scalar-expression < /options >;
Axes options
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is
interpreted using the primary X-axis scale or to the secondary X (X2) axis
scale.
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is
interpreted using the primary Y-axis scale or to the secondary Y (Y2) axis
scale.
Location options
ANCHOR=CENTER | TOPLEFT | TOP | TOPRIGHT | LEFT | RIGHT |
BOTTOMLEFT | BOTTOM | BOTTOMRIGHT
specifies an anchor point for the oval.
ODS options
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
Size options
HEIGHTUNIT=PERCENT | PIXEL | DATA
specifies whether the positive-number that is specified in the HEIGHT=
option is interpreted as a percentage value, a pixel value, or a value that
is in the units of the data.
WIDTHUNIT=PERCENT | PIXEL | DATA
specifies whether the positive-number that is specified in the WIDTH=
option is interpreted as a percentage value, a pixel value, or a value that
is in the units of the data.
Required Arguments
X=constant | scalar-expression
specifies the X value of the anchor point.
Interactions The value that is set for this argument is interpreted using the
XSPACE= option.
Y=constant | scalar-expression
specifies the Y value of the anchor point.
Interactions The value that is set for this argument is interpreted using the
YSPACE= option.
WIDTH=constant | scalar-expression
specifies the width of the oval.
Interactions The value that is set for this argument is interpreted using the
WIDTHUNIT= and XSPACE= options.
HEIGHT=constant | scalar-expression
specifies the height of the oval.
Interactions The value that is set for this argument is interpreted using the
HEIGHTUNIT= and YSPACE= options.
Optional Arguments
ANCHOR=CENTER | TOPLEFT | TOP | TOPRIGHT | LEFT | RIGHT | BOTTOMLEFT
| BOTTOM | BOTTOMRIGHT
specifies an anchor point for the oval. The anchor point is relative to the
unrotated oval. The anchor point can be at the center of the oval or at eight
points on the bounding box of the rectangle. The following figure shows the
anchor points for TOPLEFT and CENTER.
The coordinates of the anchor point are set by the statement’s X and Y values,
and by the settings for the XSPACE= and YSPACE= options. The XAXIS= and
YAXIS= option might affect positioning when the XSPACE= or YSPACE= options
are set to DATAPIXEL, DATAPERCENT, or DATAVALUE.
When the oval is rotated, the anchor point remains relative to the unrotated
oval while the oval is rotated on its anchor point. See ROTATE= on page 1449.
DRAWOVAL Statement 1447
Default CENTER
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. If the X axis is discrete, then a positive offset is to the
right. If the Y axis is discrete, then a positive offset is up. If
REVERSE=TRUE on the X or Y axis, then the offset direction is also
reversed.
Restriction This option applies only when the options XSPACE= or YSPACE=
use DATAVALUE, and when X or Y are values on a discrete axis. For
nondiscrete axes, this option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
STANDARD
displays an outlined oval.
ALL
displays an outlined, filled oval.
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
Default STANDARD
Default LAYOUTPERCENT
1448 Chapter 14 / Draw Statements
Interactions This statement and all of the draw statements inherit the global
DRAWPSACE= setting from the DRAWSPACE= option in the
BEGINGRAPH statement. Setting this option changes the setting
for only this draw statement.
This option sets the default drawing space, but individual settings
in the X or Y dimension can be overridden by the options XSPACE=,
YSPACE=, HEIGHTUNIT=, or WIDTHUNIT=.
See “About the Drawing Space and Drawing Units” on page 1398
Tip The TRANSPARENCY= option sets the transparency for the fill and the
outline. You can combine this option with TRANSPARENCY= to set one
transparency for the outline but a different transparency for the fill.
Example:
transparency=0.2 fillattrs=(transparency=0.6)
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
Default PERCENT
Interaction This setting combines with the YSPACE= setting to interpret the
height that is set in the HEIGHT= option.
LAYER=FRONT | BACK
specifies the layer on which this draw statement’s output is drawn.
FRONT
draws the output on top of the graph.
BACK
draws the output behind the background areas, such as a layout or legend
background.
Default FRONT
Tip For elements that are obstructed because they are in the back layer,
you can suppress the display of filled areas in the graph. You can also
use transparency to manage the element visibility. For more
information, see “About Drawing Layers” on page 1402 .
DRAWOVAL Statement 1449
Interaction For this option to have any effect, the outline must be enabled by
the DISPLAY= option or by the ODS style that is in effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
ROTATE=number
specifies the angle of rotation for the oval, measured in degrees. The angle is
measured as if a horizontal line extended to the right through the oval anchor
point as shown in the following figure.
Positive angles rotate the oval counter clockwise, and negative angles rotate
the oval clockwise. The angle specification can exceed 360 degrees in absolute
value.
TRANSPARENCY=number
specifies the degree of the transparency of this draw statement’s output.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
filled area. You can combine this option with FILLATTRS= to set one
transparency for the outline but a different transparency for the fill.
Here is an example:
transparency=0.2 fillattrs=(transparency=0.6)
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
1450 Chapter 14 / Draw Statements
"string"
string-expression
specifies a valid HTML page reference (HREF) for the graphical element that
is drawn by this draw statement.
Example http://www.sas.com
Restriction Links specified with URL= are not supported in SVG output in
HTML. In that case, use a raster image format such as PNG.
Default PERCENT
Interaction This setting combines with the XSPACE= setting to interpret the
width that is set in the WIDTH= option.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is interpreted
using the primary X-axis scale or to the secondary X (X2) axis scale.
Default X
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is interpreted
using the primary Y-axis scale or to the secondary Y (Y2) axis scale.
Default Y
DRAWOVAL Statement 1451
Details
A DRAWOVAL statement draws an oval in a graph. The oval position is determined
by the X and Y anchor points, and the size is determined by the HEIGHT and
WIDTH settings. You can manage the oval position with the options ANCHOR= ,
XSPACE= , and YSPACE= . You can manage the oval size with the HEIGHTUNIT=
and WIDTHUNIT= options.
For general information about the types of elements that can be drawn with the
draw statements, the drawing space and drawing units that they use, and how the
drawn elements are anchored, see Chapter 13, “Key Concepts for Using Draw
Statements,” on page 1395 . For detailed usage information, consult the SAS Graph
Template Language: User’s Guide.
Example Program
proc template;
define statgraph drawoval;
begingraph / drawspace=datavalue;
entrytitle "Regression Fit Plot";
layout overlay;
modelband "myclm";
scatterplot x=height y=weight;
regressionplot x=height y=weight / alpha=0.01 clm="myclm";
drawoval x=69 y=112.5 width=15 height=20 /
display=all fillattrs=(color=green)
transparency=0.75 ;
drawtext "Alfred" / x=69 y=112 anchor=top;
endlayout;
endgraph;
end;
DRAWRECTANGLE Statement
Draws a rectangle in the graph.
DRAWRECTANGLE Statement 1453
Syntax
DRAWRECTANGLE X=constant | scalar-expression
Y=constant | scalar-expression
WIDTH=constant | scalar-expression
HEIGHT=constant | scalar-expression < /options >;
Axes options
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is
interpreted using the primary X-axis scale or to the secondary X (X2) axis
scale.
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is
interpreted using the primary Y-axis scale or to the secondary Y (Y2) axis
scale.
specifies the drawing space and drawing units for interpreting the value
that is specified in the X= option.
YSPACE=GRAPHPERCENT | GRAPHPIXEL | LAYOUTPERCENT |
LAYOUTPIXEL | WALLPERCENT | WALLPIXEL | DATAPERCENT | DATAPIXEL |
DATAVALUE
specifies the drawing space and drawing units for interpreting the value
that is specified in the Y= option.
Location options
ANCHOR=CENTER | TOPLEFT | TOP | TOPRIGHT | LEFT | RIGHT |
BOTTOMLEFT | BOTTOM | BOTTOMRIGHT
specifies an anchor point for the rectangle.
ODS options
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
Size options
HEIGHTUNIT=PERCENT | PIXEL | DATA
specifies whether the positive-number that is specified in the HEIGHT=
option is interpreted as a percentage value, a pixel value, or a value that
is in the units of the data.
WIDTHUNIT=PERCENT | PIXEL | DATA
specifies whether the positive-number that is specified in the WIDTH=
option is interpreted as a percentage value, a pixel value, or a value that
is in the units of the data.
Required Arguments
X=constant | scalar-expression
specifies the X value of the anchor point.
Interactions The value that is set for this argument is interpreted using the
XSPACE= option.
Y=constant | scalar-expression
specifies the Y value of the anchor point.
Interactions The value that is set for this argument is interpreted using the
YSPACE= option.
WIDTH=constant | scalar-expression
specifies the width of the rectangle.
Interactions The value that is set for this argument is interpreted using the
WIDTHUNIT= and XSPACE= options.
HEIGHT=constant | scalar-expression
specifies the height of the rectangle.
Interactions The value that is set for this argument is interpreted using the
HEIGHTUNIT= and YSPACE= options.
Optional Arguments
ANCHOR=CENTER | TOPLEFT | TOP | TOPRIGHT | LEFT | RIGHT | BOTTOMLEFT
| BOTTOM | BOTTOMRIGHT
specifies an anchor point for the rectangle. The anchor point is relative to the
unrotated rectangle. The anchor point can be at the center of the rectangle or at
eight points on the rectangle border. The following figure shows the anchor
points for TOPLEFT and CENTER.
The coordinates of the anchor point are set by the statement’s X and Y values,
and by the settings for the XSPACE= and YSPACE= options. The XAXIS= and
YAXIS= option might affect positioning when the XSPACE= or YSPACE= options
are set to DATAPIXEL, DATAPERCENT, or DATAVALUE.
When the rectangle is rotated, the anchor point remains relative to the
unrotated rectangle while the rectangle is rotated on its anchor point. See
ROTATE= on page 1458.
Default CENTER
CORNERRADIUS=number
specifies the radius of the rectangle corners.
Default 0
1456 Chapter 14 / Draw Statements
Range 0–1, where 0 specifies square corners and 1 specifies the most rounded
corners
Example cornerradius=0.2
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. If the X axis is discrete, then a positive offset is to the
right. If the Y axis is discrete, then a positive offset is up. If
REVERSE=TRUE on the X or Y axis, then the offset direction is also
reversed.
Restriction This option applies only when the options XSPACE= or YSPACE=
use DATAVALUE, and when X or Y are values on a discrete axis. For
nondiscrete axes, this option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
STANDARD
displays an outlined rectangle.
ALL
displays an outlined, filled rectangle.
(display-options)
specifies a space-separated list of one or more display options, enclosed in
parentheses.
Default STANDARD
Default LAYOUTPERCENT
Interactions This statement and all of the draw statements inherit the global
DRAWPSACE= setting from the DRAWSPACE= option in the
BEGINGRAPH statement. Setting this option changes the setting
for only this draw statement.
This option sets the default drawing space, but individual settings
in the X or Y dimension can be overridden by the options XSPACE=,
YSPACE=, HEIGHTUNIT=, or WIDTHUNIT=.
See “About the Drawing Space and Drawing Units” on page 1398
Tip The TRANSPARENCY= option sets the transparency for the fill and the
outline. You can combine this option with TRANSPARENCY= to set one
transparency for the outline but a different transparency for the fill.
Example:
transparency=0.2 fillattrs=(transparency=0.6)
See “General Syntax for Attribute Options” on page 1599 for the syntax on
using a style-element.
Default PERCENT
Interaction This setting combines with the YSPACE= setting to interpret the
height that is set in the HEIGHT= option.
LAYER=FRONT | BACK
specifies the layer on which this draw statement’s output is drawn.
FRONT
draws the output on top of the graph.
BACK
draws the output behind the background areas, such as a layout or legend
background.
Default FRONT
1458 Chapter 14 / Draw Statements
Tip For elements that are obstructed because they are in the back layer,
you can suppress the display of filled areas in the graph. You can also
use transparency to manage the element visibility. For more
information, see “About Drawing Layers” on page 1402 .
Interaction For this option to have any effect, the outline must be enabled by
the DISPLAY= option or by the ODS style that is in effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
ROTATE=number
specifies the angle of rotation for the rectangle, measured in degrees. The angle
is measured as if a horizontal line extended to the right through the rectangle
anchor point as shown in the following figure.
Positive angles rotate the rectangle counter clockwise, and negative angles
rotate the rectangle clockwise. The angle specification can exceed 360 degrees
in absolute value.
TRANSPARENCY=number
specifies the degree of the transparency of this draw statement’s output.
Default 0
Tip The FILLATTRS= option can be used to set transparency for just the
filled area. You can combine this option with FILLATTRS= to set one
transparency for the outline but a different transparency for the fill.
Here is an example:
DRAWRECTANGLE Statement 1459
transparency=0.2 fillattrs=(transparency=0.6)
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
"string"
string-expression
specifies a valid HTML page reference (HREF) for the graphical element that
is drawn by this draw statement.
Example http://www.sas.com
Restriction Links specified with URL= are not supported in SVG output in
HTML. In that case, use a raster image format such as PNG.
Default PERCENT
Interaction This setting combines with the XSPACE= setting to interpret the
width that is set in the WIDTH= option.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is interpreted
using the primary X-axis scale or to the secondary X (X2) axis scale.
Default X
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is interpreted
using the primary Y-axis scale or to the secondary Y (Y2) axis scale.
Default Y
Details
A DRAWRECTANGLE statement draws a rectangle in a graph. The rectangle
position is determined by the X and Y anchor points, and the size is determined by
the HEIGHT and WIDTH settings. You can manage the rectangle position with the
options ANCHOR= , XSPACE= , and YSPACE= . You can manage the rectangle size
with the HEIGHTUNIT= and WIDTHUNIT= options.
For general information about the types of elements that can be drawn with the
draw statements, the drawing space and drawing units that they use, and how the
drawn elements are anchored, see Chapter 13, “Key Concepts for Using Draw
Statements,” on page 1395 . For detailed usage information, consult the SAS Graph
Template Language: User’s Guide.
Example Program
proc template;
define statgraph drawrectangle;
begingraph / drawspace=datavalue;
entrytitle "Regression Fit Plot";
layout overlay;
modelband "myclm";
scatterplot x=height y=weight;
regressionplot x=height y=weight / alpha=0.01 clm="myclm";
drawrectangle x=69 y=112.5 width=10 height=15 /
display=all fillattrs=(color=green)
transparency=0.75 ;
drawtext "Alfred" / x=69 y=112 anchor=top;
endlayout;
endgraph;
end;
DRAWTEXT Statement
Draws and anchors in a graph a text box that contains one or more lines of formatted text.
1462 Chapter 14 / Draw Statements
Syntax
DRAWTEXT text-item <text-item …> < /options >;
Axes options
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is
interpreted using the primary X-axis scale or to the secondary X (X2) axis
scale.
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is
interpreted using the primary Y-axis scale or to the secondary Y (Y2) axis
scale.
Location options
ANCHOR=CENTER | TOPLEFT | TOP | TOPRIGHT | LEFT | RIGHT |
BOTTOMLEFT | BOTTOM | BOTTOMRIGHT
specifies an anchor point for the text box.
JUSTIFY=LEFT | CENTER | RIGHT
specifies the alignment of text that wraps within the text box.
X=constant | scalar-expression
specifies the anchor point’s X coordinate.
Y=constant | scalar-expression
specifies the anchor point’s Y coordinate.
ODS options
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
Size options
WIDTH=positive-number
specifies the width of the text box.
WIDTHUNIT=PERCENT | PIXEL | DATA
specifies whether the positive-number that is specified in the WIDTH=
option is interpreted as a percentage value, a pixel value, or a value that
is in the units of the data.
Required Argument
text-item <…text-item>
specifies one or more pieces of text for the text box. Each text-item has the
following form:
Each piece of text can have a prefix setting that precedes the piece of text. A
piece of text is either a string literal, a dynamic, or a text command. All text-
items are concatenated into one string, which might be wrapped, based on the
settings for the WIDTH= and WIDTHUNIT= settings. Leading and trailing blanks
in the concatenated string are always used.
When used, a prefix option applies to the immediately following piece of text
and also to all subsequent text strings and text-commands until another prefix
option is specified.
Optional Arguments
ANCHOR=CENTER | TOPLEFT | TOP | TOPRIGHT | LEFT | RIGHT | BOTTOMLEFT
| BOTTOM | BOTTOMRIGHT
specifies an anchor point for the text box. The anchor point is relative to the
unrotated text. It can be at the center of the text box or at eight points on the
border of the text box bounding box. The following figure shows the anchor
points for TOPLEFT and LEFT.
The coordinates of the anchor point are set by the X= and Y= options, and by
the XSPACE= and YSPACE= options. The XAXIS= and YAXIS= option might
affect positioning when the XSPACE= or YSPACE= options are set to
DATAPIXEL, DATAPERCENT, or DATAVALUE.
The text box has a fixed width, determined by the WIDTH= and WIDTHUNIT=
options. The height of the text box is based on the amount of text specified and
the font size. The height of the text grows in a direction that is related to the
anchor point. For example, if ANCHOR=TOPLEFT, then the text box height
extends downward from the anchor point and its width extends to the right. If
ANCHOR=CENTER, then half the text box width and half the text box height
extend equally left and right, as well as top to bottom from the anchor point. If
ANCHOR=BOTTOM, the text box height extends upward from the anchor point
and the text box width is centered at the anchor point.
When the text is rotated, the anchor point remains relative to the unrotated text
box while the text box is rotated on its anchor point. See ROTATE= on page
1467.
Default CENTER
BORDER=TRUE | FALSE
specifies whether a border is drawn around the text box.
Default FALSE
See “boolean ” on page xii for other Boolean values that you can use.
Interaction BORDER=TRUE must be set for this option to have any effect.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
DISCRETEOFFSET=number
specifies an amount to offset from the discrete X values, or the discrete Y
values, or both.
Range –0.5 to +0.5, where 0.5 represents half the distance between
discrete ticks. If the X axis is discrete, then a positive offset is to the
right. If the Y axis is discrete, then a positive offset is up. If
REVERSE=TRUE on the X or Y axis, then the offset direction is also
reversed.
Restriction This option applies only when the options XSPACE= or YSPACE=
use DATAVALUE, and when X or Y are values on a discrete axis. For
nondiscrete axes, this option is ignored.
Tip Setting the discrete offset for the plots does not affect the axis
minimum and maximum offsets. In some cases, setting a discrete
offset can cause clipping at each end of the axis. In those cases, use
the OFFSETMIN= and OFFSETMAX= axis options to increase the
axis minimum and maximum offsets to accommodate the discrete
offset.
Default LAYOUTPERCENT
Interactions This statement and all of the draw statements inherit the global
DRAWPSACE= setting from the DRAWSPACE= option in the
BEGINGRAPH statement. Setting this option changes the setting
for only this draw statement.
This option sets the default drawing space, but individual settings
in the X or Y dimension can be overridden by the options XSPACE=,
YSPACE=, HEIGHTUNIT=, or WIDTHUNIT=.
See “About the Drawing Space and Drawing Units” on page 1398
LEFT
forces the first character of each line to appear at the left margin (distance
from the left border plus the left pad amount).
CENTER
forces each line to be centered in the text box between the left and right pad
amounts.
RIGHT
forces the last character of each line to appear at the right margin (distance
from the right border minus the right pad amount).
Default LEFT
Interaction Text is wrapped based on the width of the specified text, the font
size, and the setting in the PAD= option.
LAYER=FRONT | BACK
specifies the layer on which this draw statement’s output is drawn.
FRONT
draws the output on top of the graph.
BACK
draws the output behind the background areas, such as a layout or legend
background.
Default FRONT
Tip For elements that are obstructed because they are in the back layer,
you can suppress the display of filled areas in the graph. You can also
use transparency to manage the element visibility. For more
information, see “About Drawing Layers” on page 1402 .
PAD=dimension | (pad-options)
specifies the amount of extra space that is reserved inside the text box’s border.
dimension
specifies a dimension to use for the extra space at the left, right, top, and
bottom of the text box border.
(pad-options)
a space-separated list of one or more name-value-pair pad options enclosed
in parentheses.
The list can include one or more of the following pad options:
LEFT=dimension
specifies the amount of extra space added to the left side.
RIGHT=dimension
specifies the amount of extra space added to the right side.
TOP=dimension
specifies the amount of extra space added to the top.
BOTTOM=dimension
specifies the amount of extra space added to the bottom.
DRAWTEXT Statement 1467
Note Sides that are not assigned padding are padded with the default
amount.
ROTATE=number
specifies the angle of rotation of the text box, measured in degrees. The text
box is rotated around its anchor point. The angle is measured from a horizontal
line passing through the anchor point of the text box to the right. The following
figure shows the rotation of text around a top anchor point.
Positive angles rotate the text box counter clockwise, and negative angles
rotate the text box clockwise. The angle specification can exceed 360 degrees
in absolute value.
TRANSPARENCY=number
specifies the degree of the transparency of this draw statement’s output.
Default 0
URL="string" | string-expression
specifies an HTML page that is displayed when the output of this draw
statement is selected.
"string"
string-expression
specifies a valid HTML page reference (HREF) for the graphical element that
is drawn by this draw statement.
Example http://www.sas.com
Restriction Links specified with URL= are not supported in SVG output in
HTML. In that case, use a raster image format such as PNG.
WIDTH=positive-number
specifies the width of the text box.
Default 10
Default PERCENT
Interaction This setting combines with the XSPACE= setting to interpret the
width that is set in the WIDTH= option.
X=constant | scalar-expression
specifies the anchor point’s X coordinate.
Default 50
XAXIS=X | X2
specifies whether the data value for the arguments X1 and X2 is interpreted
using the primary X-axis scale or to the secondary X (X2) axis scale.
Default X
Y=constant | scalar-expression
specifies the anchor point’s Y coordinate.
Default 50
YAXIS=Y | Y2
specifies whether the data value for the arguments Y1 and Y2 is interpreted
using the primary Y-axis scale or to the secondary Y (Y2) axis scale.
Default Y
Prefix Option
TEXTATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font properties of the entire text string or individual text-
items.
Interaction When multiple TEXTATTRS= prefix options are used, each one
cancels the last, resetting all text properties to the default set by
the GraphAnnoText style element. Subsequent text-items to the
right are then assigned the text properties specified in the closest
TEXTATTRS= setting to their left. Thus, to vary the text properties
across text-items, you do not have to override settings from a
previous TEXTATTRS= setting. Each TEXTATTRS= specification
resets all text properties to the default so that only the new settings
are applied to subsequent text-items.
Tip To ensure that all text has the same text properties, use this prefix
option once only and place it before the first text-item.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
Text Commands
{ SUB "string" | dynamic }
text-command that specifies that the string or dynamic is to appear as subscript
text.
See “Rules for Unicode and Special Character Specifications” on page 1342
Example drawtext "y = " b{sub "0"} " + b" {sub "1"} "x";
See “Rules for Unicode and Special Character Specifications” on page 1342
Example drawtext "R" {sup "2"} " = " {format (6.4) RSQUARED} ;
"hex-string"x
a four-byte hexadecimal constant that represents a UNICODE character in
the current font. For a complete listing, see http://unicode.org/charts/
charindex.html.
keyword
a SAS keyword for a UNICODE character.
dynamic
a dynamic variable that resolves to either "hex-string"x or a keyword for a
UNICODE character.
DRAWTEXT Statement 1471
Example The following statements show how to use the {UNICODE} text
command:
drawtext {unicode alpha} "=" CONF;
Details
A DRAWTEXT statement draws a text box that contains one or more lines of text.
The text can be formatted, using the TEXTATTRS= prefix option. By default, the
text box is drawn in the center of the graph. You can change the default position
with the options ANCHOR= , X= , Y= , XSPACE= , and YSPACE= .
For general information about the types of elements that can be drawn with the
draw statements, the drawing space and drawing units that they use, and how the
drawn elements are anchored, see Chapter 13, “Key Concepts for Using Draw
Statements,” on page 1395 . For detailed usage information, consult the SAS Graph
Template Language: User’s Guide.
Example Program
proc template;
define statgraph modelfit;
begingraph;
entrytitle "Regression Fit Plot";
layout lattice;
layout overlay / xaxisopts=(offsetmin=0.1);
drawtext textattrs=(style=italic size=8pt)
"Band shows 99% Confidence Limit of Mean" /
anchor=bottomleft width=15 widthunit=percent
xspace=wallpercent yspace=wallpercent
x=0 y=10 justify=center ;
modelband "myclm";
scatterplot x=height y=weight / primary=true;
regressionplot x=height y=weight / alpha=0.01 clm="myclm";
endlayout;
endlayout;
drawtext textattrs=(color=gray size=52pt) "CONFIDENTIAL" /
transparency=0.75 rotate=-35
width=110 widthunit=percent justify=center ;
endgraph;
end;
PART 10
Chapter 15
About the GTL Annotation Facility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1475
Chapter 16
The ANNOTATE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1483
1474
1475
15
About the GTL Annotation
Facility
Data-Set-Driven Annotations
GTL supports data-set-driven annotations, which enable you to add the following
graphics elements to your graphs:
n text
n images
Unlike graphics elements that are drawn using GTL draw statements in a GTL
template, data-set-driven annotations are drawn from graphics instructions that
are stored in a SAS data set. The GTL annotation facility is similar to the
SAS/GRAPH Annotate facility. The GTL annotation facility enables you to separate
your annotation instructions from your template statements. To change your
1476 Chapter 15 / About the GTL Annotation Facility
annotations, you can specify a different annotation data set or modify the
instructions in the original data set. You do not have to modify your template code.
The following items are required in order to use the GTL annotation facility:
n a SAS data set that contains the annotation instructions. The annotation
instructions must be stored in a SAS data set. Annotation instructions stored in
a Cloud Analytic Services (CAS) in-memory table are not supported.
n at least one ANNOTATE statement in your GTL template.
This section describes the requirements for using the GTL annotation facility. For
examples of how to use the facility to annotate your graphs, see “Adding Data-
Driven Annotations to Your Graph” in SAS Graph Template Language: User’s Guide.
To create the annotation data set, use the same methods that you would use to
create any SAS data set. You must store the annotation instructions in a SAS data
set. Annotation instructions stored in a CAS in-memory table are not supported.
The most common method for creating a data set is to use a DATA step. For more
information about the DATA step, see SAS Programmer’s Guide: Essentials. Macros
are available that you can run in your DATA step to create the observations for your
annotations. See “Using the SGANNO Macros” on page 1480.
Annotation Data Set 1477
For more information about these functions, see “SG Annotation Function
Dictionary” in SAS ODS Graphics: Procedures Guide.
Each function requires one or more additional columns that provide required
information such as the location coordinates, dimensions, and so on. The following
table lists the additional columns that are required for each function. At a minimum,
you must include the Function column and the columns listed in the following table
in each observation in your annotation data set.
Additional Columns
FUNCTION Required1 Description
Additional Columns
FUNCTION Required1 Description
Y1 or YC1
For the remaining information such as LINECOLOR, TEXTFONT, and so on, default
values are used. To change the default values, you can add the necessary columns
to your instruction observations. For information about other columns that you can
add for each function, see “SG Annotation Function Dictionary” in SAS ODS
Graphics: Procedures Guide
Note: For polylines and polygons, the initial POLYLINE or POLYGON observation
and all of the subsequent POLYCONT observations for the annotation must be
contiguous. For text that is continued, the initial TEXT observation and all of the
subsequent TEXTCONT observations for the annotation must also be contiguous.
required, the numeric coordinates are stored in the X2 and Y2 columns. For
character values, the coordinates are stored in the XC1 and YC1 columns, and when
required, the XC2 and YC2 columns.
Note: If both the numeric and character columns are specified for a coordinate
value, then the numeric column takes precedence and the character column is
ignored.
For more information about these drawing spaces, see “About the Drawing Space
and Drawing Units” on page 1398.
To change the default drawing space for your annotations, you can add the columns
shown in the following table to your annotation observations.
DrawSpace Specifies the drawing space for all coordinates. This value cannot
be used with the POLYCONT function.
X1Space Specifies the drawing space for the X1 coordinate. This value cannot
be used with the TEXTCONT function.
X2Space Specifies the drawing space for the ending X2 coordinate. This
value can be used with the ARROW and LINE functions only.
Y1Space Specifies the drawing space for the Y1 coordinate. This value cannot
be used with the TEXTCONT function.
Y2Space Specifies the drawing space for the ending Y2 coordinate. This value
can be used with the ARROW and LINE functions only.
For information about these columns, see “SG Annotation Function Dictionary” in
SAS ODS Graphics: Procedures Guide
1480 Chapter 15 / About the GTL Annotation Facility
1 The macros listed in this table are valid starting with SAS 9.4M1. You can run these macros in a
DATA step to simplify the process of creating your SG annotation data sets.
For more information about these macros, see SAS ODS Graphics: Procedures
Guide.
See Also
“Adding Observations for Polylines and Polygons” in SAS Graph Template Language:
User’s Guide
ANNOTATE Statement
To render the annotations in your annotation data set, you must include at least
one ANNOTATE statement in the GTL template for your graph. You can place the
ANNOTATE statement anywhere in the template to render your annotations. The
annotations are drawn using the context in which the ANNOTATE statement is
encountered. You can use the ANNOTATE statement with no options to render all
of the annotations in your annotation data set. You can use the ID= option in the
ANNOTATE statement to render only a subset of the annotations.
16
The ANNOTATE Statement
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1483
ANNOTATE Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1483
Dictionary
ANNOTATE Statement
Draws annotations from annotation instructions that are stored in a SAS data set.
Syntax
ANNOTATE </ID="annotation-ID">
Optional Argument
ID="annotation-identifier"
specifies the ID column value of the annotations that are to be drawn. The ID
column of the annotation data set contains a unique character value that
identifies the subset to which each annotation belongs. All annotations in the
annotation data set with an ID column value that matches the specified
annotation identifier are drawn. If the annotation data set does not contain an
ID column or if no ID column value matches the specified identifier, then no
annotations are drawn.
Default All of the annotations in the annotation data set are drawn.
Requirement The annotation data set must contain an ID column, and at least
one ID column value must match the specified identifier value.
Tips The ID= option can be used with the annotation data set ID column
to subset the annotations that are stored in an annotation data set.
Details
You can use the ANNOTATE statement anywhere in a GTL template to render
annotation objects in the current context. The annotation objects are read from an
annotation data set that is specified by the SGANNO= option in the SGRENDER
statement. You must use at least one ANNOTATE statement in the template to
draw the annotations. By default, all of the annotations in the annotation data set
are drawn. You can use the ID column in the annotation data set with the ID= option
in the ANNOTATE statement to draw only a subset of the annotations in the data
set, if you want to. See “Subsetting Annotations” in SAS Graph Template Language:
User’s Guide.
Examples
Example Program
/* Create the annotation data set */
data anno;
length label $30 id $5 anchor $12;
drawspace="wallpercent";
Program Description
Create the annotation data set Anno. The annotation data set contains two
observations, one for each label. The DRAWSPACE is set to WALLPERCENT for
both labels. The ID column specifies an identifier for each label. The bar chart label
is identified as BAR. It is rotated 90 degrees, anchored on TOP, and is placed at 0%
of the wall space along the X axis. The default value 50% percent is used along the
Y axis to center the label vertically. This places the label on inside left edge of the
bar chart wall. This histogram label is identified as HIST. It is rotated 90 degrees,
anchored on BOTTOM, and is placed at 100% of the wall space along the X axis.
Like the bar chart label, the default 50% percent is used along the Y axis. This
places the label on the right inside edge of the histogram plot wall.
/* Create the annotation data set */
data anno;
length label $30 id $5 anchor $12;
drawspace="wallpercent";
Define the graph template. The template defines a two-column, one-row lattice for
the two plots. For both plots, the DISPLAY= Y-axis option suppresses the default
axis label. For the bar chart, the OFFSETMIN= and OFFSETMAX= X-axis options
reserve space for the Y-axis label. The ANNOTATE statement draws the axis label.
The ID="BAR" option in the ANNOTATE statement draws the bar chart Y-axis label
in the context of the bar chart’s OVERLAY layout. For the histogram, the
ANNOTATE statement draws the histogram Y-axis label (ID="HIST") in the context
of the histogram’s OVERLAY layout.
/* Define the template */
proc template;
define statgraph anno;
begingraph;
entrytitle "Vehicle Statistics";
layout lattice / columns=2 columngutter=10;
layout overlay /
xaxisopts=(offsetmin=0.2 offsetmax=0.2)
yaxisopts=(display=(ticks tickvalues));
Render the graph with the annotations. The SGANNO=ANNO option is included in
the SGRENDER statement to specify the name of the annotation data set. When
the graph is rendered, the ANNOTATE statements in the graph template cause the
annotations to be drawn.
/* Render the graph with the annotation */
proc sgrender data=sashelp.cars template=anno sganno=anno;
where type in ("Sedan" "Sports" "SUV");
run;
Example Program
/* Create the annotation data set */
data anno;
/* Compile the annotation macros */
%sganno;
/* Create the bar chart Y-axis label. */
%sgtext(
reset=all,
id=BAR,
drawspace=wallpercent,
x1=0,
label="MPG (City)",
textweight=bold,
anchor=top,
rotate=90,
width=1000,
widthunit=pixel);
/* Create the histogram Y-axis label. */
%sgtext(
id=HIST,
x1=100,
label="Distribution of MPG (Percent)",
anchor=bottom);
run;
Program Description
Here is the SAS code.
Open the DATA step and run the %SGANNO macro. After you open the DATA step,
you must run the %SGANNO macro to compile the SG annotation macros and make
them available for your use. You need to compile the macros only once during a
SAS session.
/* Create the annotation data set */
data anno;
/* Compile the annotation macros */
%sganno;
Create the observation for the bar chart Y-axis label. Use the %SGTEXT macro to
generate the observation for the bar chart Y-axis label.
/* Create the bar chart Y-axis label. */
%sgtext(
reset=all,
id=BAR,
drawspace=wallpercent,
x1=0,
label="MPG (City)",
textweight=bold,
anchor=top,
rotate=90,
width=1000,
ANNOTATE Statement 1489
widthunit=pixel);
Create the histogram Y-axis label, and close the DATA step. Specify the new
values for the ID, X1, Label, and Anchor columns. To carry over the remaining
column values from the previous macro call, do not specify RESET=ALL.
/* Create the histogram Y-axis label. */
%sgtext(
id=HIST,
x1=100,
label="Distribution of MPG (Percent)",
anchor=bottom);
run;
See Also
n Chapter 15, “About the GTL Annotation Facility,” on page 1475
n “Adding Data-Driven Annotations to Your Graph” in SAS Graph Template
Language: User’s Guide
1490 Chapter 16 / The ANNOTATE Statement
1491
PART 11
Attribute Maps
Chapter 17
Key Concepts for Using Attribute Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1493
Chapter 18
Discrete Attribute Map Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1505
Chapter 19
Range Attribute Map Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1521
1492
1493
17
Key Concepts for Using
Attribute Maps
GTL supports two types of attribute maps: discrete attribute maps and range
attribute maps. A discrete attribute map maps discrete values to graphical
properties. A range attribute map maps numeric values or ranges of numeric values
to graphical properties.
1494 Chapter 17 / Key Concepts for Using Attribute Maps
Note: Defining a discrete attribute map in a SAS data set is valid in SAS 9.4M1
and later releases.
n Reference the attribute map in plot statements by using one of the following
methods:
o Include a DISCRETEATTRVAR statement in the template code to create an
attribute map variable. The variable associates the attribute map with a
classification column in the plot data. Then use the attribute map variable to
reference the discrete attribute map in plot statements. This method applies
to an attribute map that is defined in a SAS data set or in a
DISCRETEATTRMAP block in the template code.
o Specify the classification column, which is in the plot data, in the plot
statements where needed. When the graph is rendered, the SGRENDER
DATTRVAR statement is used to associate the attribute map that is defined
in a SAS data set with the classification column in the plot data. This method
applies only to an attribute map that is defined in a SAS data set.
Note: The DATTRVAR statement is valid in SAS 9.4M1 and later releases.
For information about the DATTRVAR statement, see SAS ODS Graphics:
Procedures Guide.
contains one or more VALUE statements that specify the attribute mapping
information. Each VALUE statement specifies a single discrete value and one or
more graphical properties that are assigned to that value. The NAME= option in the
DISCRETEATTRMAP statement specifies the name of the attribute map. The
DISCRETEATTRVAR statement creates the reference variable for the attribute
map. The following options are in the DISCRETEATTRVAR statement:
n The ATTRVAR= option specifies a unique name for the attribute-map-to-data-
set-column association.
n The ATTRMAP= option specifies the value of the NAME= option that is
specified in the DISCRETEATTRMAP statement.
n The VAR= option specifies the name of the numeric or character column in the
plot data set, an expression, or the name of a dynamic variable.
Use the attribute map variable to reference the attribute map in plot statements.
Note: Do not use the attribute variable in an expression. Doing so might produce
unexpected results.
Note: The values and graphical attributes that are defined in a discrete attribute
map cannot be displayed by a CONTINUOUSLEGEND statement.
The following table lists the columns that you can use to specify the graphical
properties for each classification value. Properties that you do not specify default
to the properties that are normally used when an attribute map is not specified.
FillColor Character Specifies the color for the filled areas for this
classification value. When FillStyleElement is also
specified, this column overrides the specified
style element’s Color attribute.
FillTransparency Numeric Specifies the transparency of the fill color for this
classification value. Values are in the range 0
(opaque) to 1 (completely transparent).
MarkerColor Character Specifies the color of the marker symbol for this
classification value. When MarkerStyleElement is
also specified, this column overrides the specified
style element’s ContrastColor attribute.
MarkerSize Numeric Specifies the size of the marker, in pixels, for this
classification value. The values must be integers.
TextSize Numeric Specifies the text font size in points for this
classification value. The values must be integers.
The ID column provides the name of the attribute map, which is specified in the
ATTRMAP= option in the DISCRETEATTRVAR statement or in a DATTRVAR
statement. When the graph is rendered, the name of the attribute map data set
must be specified in the DATTRMAP= option in the SGRENDER statement. See
“DATTRVAR Statement” in SAS ODS Graphics: Procedures Guide. For information
about how to reference the attribute map in your plot statements, see “Referencing
a Discrete Attribute Map in Plot Statements” on page 1499.
Note: Range attribute maps do not support attribute map information that is
stored in a SAS data set.
o The VAR= option specifies the name of the numeric column in the plot data
set with which the range attribute map is to be associated.
n The attribute map variable is used to reference the discrete attribute map in plot
statements.
Note: The values and graphical attributes defined in a range attribute map
cannot be displayed by a DISCRETELEGEND statement.
For information about how to reference a range attribute map, see “Referencing
a Discrete Attribute Map in Plot Statements” on page 1499.
The optional exclusion operator (<) can be placed after the low value or before the
high value to exclude that value from the range endpoint. The low value and high
value can be an unformatted numeric value or a range keyword. For the low value,
keyword MIN, NEGMAX, or NEGMAXABS can be used instead of numeric value. For
the high value, keyword MAX or MAXABS can be used. For information about the
range keywords, see SAS Graph Template Language: Reference.
Note: If two ranges share a common endpoint, such as 10–20 and 20–30, and no
exclusion operator ( < ) is used, then the common endpoint belongs to the lower
range, which is 10–20 in this case.
For more information about how to create a range attribute map, see “Creating and
Using a Range Attribute Map” on page 1527.
When you use a DATTRVAR statement in the SGRENDER statement, the attribute
map is referenced implicitly when a column that is assigned to the attribute map ID
in the DATTRVAR statement is referenced in a plot statement. The following table
lists the statement options that support a reference to a discrete attribute map.
Statement Options
Statement Options
For an example of how to reference an attribute map variable that is created with
the DISCRETEATTRVAR statement, see “Example: DISCRETEATTRVAR Statement
with an Attribute Map Data Set” on page 1517.
by origin;
run;
SAS data set Attrds is created to define attribute map ORIGIN. For each value of
origin, attribute map ORIGIN specifies a fill color and a line color. The SUMMARY
procedure is used to create data set Counts, which contains the counts of vehicle
models by type and origin from table Sashelp.Cars. The TEMPLATE procedure
defines a bar chart of columns Type and Count grouped by column Origin in table
Counts. The SGRENDER procedure renders the graph.
In the SGRENDER procedure step, the DATTRMAP= option specifies the Attrds
attribute map data set. The DATTRVAR statement associates discrete attribute
map ORIGIN with classification column Origin in table Counts. A WHERE
statement eliminates cars that are manufactured in the USA. The WHERE
statement applies to the data in data set Counts only. It does not apply to the data
in attribute map data set Attrds.
TIP To subset data in your attribute map data set using a WHERE clause,
use a WHERE statement in a DATA step to create a new attribute map data
set or use the data set WHERE option in the SGRENDER procedure
DATTRMAP= option. Here is an example of the latter:
dattrmap=attrds(where=(value ne "USA"))
The following table lists the statement options that support a reference to a range
attribute map variable.
Table 17.4 Statement Options That Support a Range Attribute Map Variable
Reference
Statement Options
BUBBLEPLOT COLORRESPONSE=
HEATMAP COLORRESPONSE=
MOSAICPLOTPARM COLORRESPONSE=
POLYGONPLOT COLORRESPONSE=
1504 Chapter 17 / Key Concepts for Using Attribute Maps
Statement Options
WATERFALLCHART COLORRESPONSE=
For an example, see “Example 1: Using a Range Attribute Map to Control Marker
Colors” on page 1528.
1505
18
Discrete Attribute Map
Statements
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1505
DISCRETEATTRMAP Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1505
DISCRETEATTRVAR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1516
Dictionary
DISCRETEATTRMAP Statement
Defines a set of graphical properties that can be associated with user-defined sets of values.
Requirements: You must place the DISCRETEATTRMAP block directly inside the BEGINGRAPH
block between the BEGINGRAPH statement and the first LAYOUT statement. Do
not embed it in any other GTL statement block.
The DISCRETEATTRMAP block must contain at lease one VALUE statement.
The DISCRETEATTRVAR statement must be used to associate the discrete
attribute map with a data column.
Notes: The graphical properties for a discrete attribute map can also be defined in a SAS
data set. See “Defining a Discrete Attribute Map” on page 1494.
Prior to the third release for SAS 9.4, when a discrete attribute map is used for
group values in a plot that contributes to a discrete legend and attributes are
overridden in the plot statement, the attributes of some plot features and their
corresponding legend items might not match. Starting with SAS 9.4M3, the
attributes of the legend items always match the attributes of the corresponding
plot features.
1506 Chapter 18 / Discrete Attribute Map Statements
Syntax
DISCRETEATTRMAP NAME="string" </options>;
VALUE value-spec </options>;
<… more VALUE statements …>
ENDDISCRETEATTRMAP;
Required Argument
NAME="string "
assigns a name to the attribute definition. The name can be referenced in a
DISCRETEATTRVAR statement, which is used to associate the attribute map
with an input data column. The name can also be referenced in a
DISCRETELEGEND statement to map the specified graphical properties directly
to a discrete legend.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
Optional Arguments
DISCRETELEGENDENTRYPOLICY=DATA | ATTRMAP
specifies whether the items that are contributed to a discrete legend by the plot
associated with this attribute map are only items that appear in the data or only
items that are defined in the attribute map.
DATA
the associated plot contributes to a discrete legend only items that appear in
the data.
ATTRMAP
the associated plot contributes to a discrete legend only items that are
defined in the discrete attribute map.
Interaction If this option is set to ATTRMAP, then data skins, overrides from
the DATATRANSPARENCY= option, and overrides from the
TRANSPARENCY= suboption in the FILLATTRS= and
MARKERATTRS= options are displayed in the discrete legend.
Overrides from other options such as the COLOR= suboption in
the FILLATTRS= option are not displayed.
Default DATA
DISCRETEATTRMAP Statement 1507
IGNORECASE=TRUE | FALSE
specifies whether case is ignored when comparing the values that are specified
in the attribute map with values from an input data column.
Tip The effect of this option can be achieved by applying a function like
UPCASE to the data column and using only uppercase strings in each
VALUE statement.
See “boolean ” on page xii for other Boolean values that you can use.
TRIMLEADING=TRUE | FALSE
specifies whether leading blanks are trimmed (removed) from both the attribute
map values and the input data values before those values are compared. Trailing
blanks are always trimmed.
See “boolean ” on page xii for other Boolean values that you can use.
OTHER
creates a category for all other column values that are not explicitly
assigned with VALUE statements. This keyword is not quoted. The default
attributes for these values are derived from the GraphOther style element.
Note If OTHER is not specified, then data values that are not explicitly
assigned with VALUE statements are mapped to attributes as if a
discrete attribute map is not in effect.
Note When the specified value strings are compared with the data
values, leading blanks are honored and trailing blanks are ignored.
Tip In SAS 9.4M1 and earlier releases, if you create and use a format to
display a special value for missing character values, in some cases,
" " is returned instead of the formatted value. If your attribute map
assigns attributes to the formatted missing value in that case, the
attributes are not assigned to the missing values. To correct this
problem, specify both " " and your formatted missing value in the
VALUE statement for your missing-value attributes. This issue is
resolved in SAS 9.4M2.
Restriction In SAS 9.4 and earlier releases, the TRANSPARENCY= fill option is
ignored. Starting with SAS 9.4M2, the TRANSPARENCY= fill
option is supported.
See “General Syntax for Attribute Options” on page 1599 for the
syntax on using a style-element.
Restrictions In SAS 9.4 and earlier releases, the THICKNESS= line option is
ignored. Starting with SAS 9.4M1, the THICKNESS= line option is
supported.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style-element.
See “General Syntax for Attribute Options” on page 1599 for the syntax
on using a style element.
Details
If you do not want to manage the graphical properties that are associated with each
unique discrete value, then you can simply specify an input column in the grouping
option. In that case, each discrete value is represented by different graphical
properties in the graph. The default properties are derived from options that are set
in the plot statement or from the GraphData1–GraphDataN style elements that are
defined in the ODS style that is in effect. However, to ensure that specific graphical
properties are used to represent a discrete value in the graph, regardless of that
value’s order in the data, you can use an attribute map to create that association.
Any values in the data that are not accounted for in the attribute map are assigned
the graphical properties that they would receive if the attribute map is not defined.
For information about how to use the attribute map, see “Using a Discrete Attribute
Map” on page 1512.
If the discrete attribute map is referenced by a plot statement in the template, then
the graphical properties that are defined in the VALUE statements are used in the
plot. If a discrete legend is generated for the plot, then the graphical properties are
represented in that legend.
If two or more VALUE statements define attributes to associate with the same
classification values, then the last VALUE statement's settings are used.
By default when comparing a column's value to a string that is specified for the
VALUE statement's value-spec,
n the column value is formatted to a string, using the format that is defined for
the column or the default format if no format is defined for the column
1512 Chapter 18 / Discrete Attribute Map Statements
n leading spaces are trimmed from the string that is specified in the VALUE
statement
n a case-sensitive comparison is performed between the column string and the
VALUE string.
To change the default behavior for the comparison, you can use the
DISCRETEATTRMAP statement’s TRIMLEADING= and IGNORECASE= options.
Displaying Legend Entries for Group Values That Are Not in the
Data
To display legend entries for the values in a grouped plot, you typically use the plot
statement’s NAME= option to assign a name to the plot, and then reference that
name in the DISCRETELEGEND statement. In this usage case, the legend displays
entries for the group values that exist in the data.
To represent all of the group values in the legend, regardless of whether they exist
in the data, you can specify DISCRETELEGENDENTRYPOLICY=ATTRMAP in the
DISCRETEATTRMAP statement for the attribute map. When the
DISCRETELEGENDENTRYPOLICY=ATTRMAP option is in effect, the associated
plot contributes all of the items in the attribute map to the discrete legend
regardless of whether they exist in the data.
Displaying all of the items in a discrete attribute map in the legend can be useful for
flagging data in the graph. For example, assume you have weight and height values
for all students in an analysis group and you want to create a scatter plot of the
data. However, some of the observations are incomplete and do not record the
student’s sex. You want to include the incomplete observations in your plot, but
you want to visually distinguish them from the others. In that case, you can do the
following:
n Represent the unknown values in your data by entering the value U for sex.
n Define the discrete attribute map for the plot in a DISCRETEATTRMAP block.
Include the DISCRETELEGENDENTRYPOLICY=ATTRMAP option in the
DISCRETEATTRMAP statement. Include VALUE statements that specify the
properties for the M, F, and U values.
DISCRETEATTRMAP Statement 1513
To test the template, you can generate test data set Testclass from Sashelp.Class
by changing the value of column Sex to U for John and Carol as shown in the
following code.
data testclass;
set sashelp.class;
if (name="John") then sex="U";
if (name="Carol") then sex="U";
run;
The following figure shows the output of this template when it is run with the test
data set Testclass.
1514 Chapter 18 / Discrete Attribute Map Statements
The two red stars in the plot indicate the observations with the value U in column
Sex. The next figure shows the output of this template when it is run with the
complete data in data set Sashelp.Class.
The absence of the red stars in the plot indicates that the value U is no longer
present in the data. All of the observations are now complete. When
DISCRETELEGENDENTRYPOLICY=ATTRMAP is specified for an attribute map, be
aware that the legend entries that are contributed by an associated plot are defined
entirely by the attribute map and are independent of the data.
Example Program
proc template;
define statgraph scatterplot;
begingraph;
entrytitle "Height and Weight by Sex";
/* associate the attribute map with input data column Sex and
assign
* the name GROUPMARKERS to the named association */
discreteattrvar attrvar=groupmarkers var=sex attrmap="symbols" ;
DISCRETEATTRVAR Statement
Creates a named association between a user-defined discrete attribute map and an input data
column.
Requirements: You must place the DISCRETEATTRVAR statement directly inside the
BEGINGRAPH block between the BEGINGRAPH statement and the first LAYOUT
statement. Do not embed it in any other GTL statement block.
A discrete attribute map must be created using the DISCRETEATTRMAP
statement.
See: “Example: DISCRETEATTRMAP and DISCRETEATTRVAR Statements” for an
example.
Syntax
DISCRETEATTRVAR ATTRVAR=attrvar-name
VAR=data-column | expression | dynamic
ATTRMAP="attrmap-name";
Required Arguments
ATTRVAR=attrvar-name
specifies a SAS name for this association between the attribute map and the
input column. This name must be unique within the template and can be
referenced by other statements that can be associated with the attribute map.
The attribute map variable name should not be used in an expression. If it is,
then the results are unpredictable.
Note The assigned SAS name can be the same as the name of the data
input column, but it is not recommended. If an assigned attrvar-
name matches the name of an input data column, then the attrvar-
name takes precedence.
DISCRETEATTRVAR Statement 1517
Interaction If the column is not found or the column is of the wrong type for the
attribute map, then the DISCRETEATTRVAR statement is ignored.
Tip The input data column can be character or numeric, but the values
must match the type of the values that are specified in the attribute
map. For numeric columns, all values are treated as discrete values.
ATTRMAP="attrmap-name "
specifies the name of an existing discrete attribute map.
Details
The DISCRETEATTRVAR statement creates and names an association between
graphical properties that are specified in a DISCRETEATTRMAP block and a
classification column that is in the data. The name that is assigned to the
association in the DISCRETEATTRVAR statement is the name that plot statements
must reference to use the attribute map.
Defining and using a discrete attribute map requires you to coordinate settings on
several statements. For more information, see the DISCRETEATTRMAP
statement’s “Defining a Discrete Attribute Map in a DISCRETEATTRMAP Block” on
page 1510 .
Example Program
Here is the SAS code for this example.
/* Create the attribute map data set */
data attrds;
input ID $1-7 VALUE $9 MARKERSYMBOL $11-23 MARKERCOLOR $25-30;
datalines;
symbols M diamondfilled blue
symbols F circlefilled red
;
run;
/* Associate the attribute map with input data column Sex and
assign
* the name GROUPMARKERS to the named association */
discreteattrvar attrvar=groupmarkers var=sex attrmap="symbols";
endgraph;
end;
Details
The attribute map is defined in data set Attrds. The data set includes the required
columns ID and VALUE, which specify a name for this attribute map and the value
of the classification variable that is to be mapped. The MarkerSymbol and
MarkerColor columns specify the graphical properties that are mapped to each
value. The values specified in the Value column are case-sensitive. Unlike the
DISCRETEATTRMAP statement, when you define your attribute map in a data set,
there is no option that you can specify to ignore case. You must ensure that the
case of the values in your attribute map matches the case in the actual data.
The DISCRETEATTRVAR statement associates the attribute map with the data
column Sex and assigns the name GROUPMARKERS to the attribute map variable.
The ATTRMAP= option specifies the name in the ID column of the attribute map
data set. The value is case-sensitive. The attribute map variable name is specified
in the GROUP= option in the SCATTERPLOT statement.
Finally, in the SGRENDER statement, the DATTRMAP= option specifies the name
of the attribute map data set. When your attribute map is defined in a SAS data set,
you must specify the name of the data set in the DATTRMAP= option in the
SGRENDER statement that renders the graph.
You can also use the DATTRVAR= statement with the SGRENDER statement to
associate the attribute map with the data column Sex. See “Referencing an
Attribute Map in Your Plot Statements” on page 1499.
1520 Chapter 18 / Discrete Attribute Map Statements
1521
19
Range Attribute Map Statements
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1521
RANGEATTRMAP Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1521
RANGEATTRVAR Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1531
Dictionary
RANGEATTRMAP Statement
Creates an attribute map that matches colors to numeric values or numeric ranges so that the colors
can be associated with the values of an input data column.
Syntax
RANGEATTRMAP NAME="string";
1522 Chapter 19 / Range Attribute Map Statements
Required Argument
NAME="string "
assigns a name to the attribute definition for reference in a RANGEATTRVAR
statement.
This option does not support variables that are created by the
DYNAMIC, MVAR, and NMVAR template statements.
If a value at the high end of one range also appears at the low end of another
range and you do not use the < exclusion notation, then the value is assigned to
the first range.
If two or more RANGE statements define colors to associate with the same
numeric values or ranges, then the first RANGE statement's settings are used. If
any RANGE statement's range overlaps another RANGE statement's range (for
example, 10 - 20 and 15 - 25), then the entire attribute map is ignored and
default coloring is used.
If two ranges share a common endpoint (for example, 10 - 20 and 20 - 30) and
no exclusion operator is used, then the common endpoint belongs to the lower
encountered range (10 - 20 in this case). The order of the specification does not
matter.
To set a single numeric value, specify the same value for both the low value and
the high value.
RANGEATTRMAP Statement 1523
If the low value is not less than or equal to the high value, then the range
specification is invalid, and the RANGE statement is ignored in the attribute
map definition.
Note: If a range is not defined for keyword OTHER, then gaps within the
attribute map ranges are assigned the default color that is defined by the
GraphOther:ContrastColor style reference.
Rather than using a numeric value, you can specify one of the following
keywords as the low value or the high value:
Rather than specifying a low-value-to-high-value range, you can use one of the
following keywords for the range specification:
MISSING
indicates a mapping for missing values. The visual attributes for this setting
are obtained from the GraphMissing style element. If one RANGE statement
specifies this value and another RANGE statement specifies keyword
OTHER, then the OTHER range does not include missing values.
UNDER
creates a range for all data values between the lowest mapped value and the
lowest actual data value. The visual attributes for this setting are obtained
from the GraphUnderflow style element. If one RANGE statement specifies
this value and another RANGE statement specifies keyword OTHER, then
the OTHER range does not include underflow values.
OVER
creates a range for all data between the highest mapped value and the
highest actual data value. The visual attributes for this setting are obtained
from the GraphOverflow style element. If one RANGE statement specifies
this value and another RANGE statement specifies keyword OTHER, then
the OTHER range does not include overflow values.
OTHER
creates a category for all other column values not explicitly assigned to a
range. The OTHER values can be composed of several non-contiguous
ranges. The visual attributes for this setting are obtained from the
GraphOther style element.
Example:
rangeattrmap name="incomemap";
range min - 13000 / rangealtcolor=gradientstepper(red,green,4,1);
range 13000 < - 25000 / rangealtcolor=gradientstepper(red,green,4,2);
range 25000 < - 50000 / rangealtcolor=gradientstepper(red,green,4,3);
range 50000 < - max / rangealtcolor=gradientstepper(red,green,4,4);
endrangeattrmap;
Tips Because lines and markers have less surface area, choose a
contrasting color in order to improve visibility.
RANGEALTCOLORMODEL=style-element | (list-of-colors)
specifies either a style element or a list of one or more specific contrast colors
for lines, markers, and text to represent the defined value range in this
argument.
style-element
specifies the name of a style element. To display the range as a gradient
ramp, choose a style element such as TwoColorRamp, TwoColorAltRamp,
ThreeColorRamp, or ThreeColorAltRamp. The style element should contain
the following style attributes:
To display the range or single value contrast color as a color that is defined
in a style, use a style-reference (for example, GraphData1:color) to refer to
a Color attribute. The following style references correspond to the keywords
that are available in this statement’s range-spec argument:
MISSING GraphMissing:ContrastColor
OTHER GraphOther:ContrastColor
UNDER GraphUnderflow:ContrastColor
OVER GraphOverflow:ContrastColor
(list-of-colors)
a space-separated list of two or more color keywords that is enclosed in
parentheses.
Two colors create the endpoints of a ramp. The first color is assigned to the
low value in the range specification, and the second color is assigned to the
high value. Three or more colors partition the range specification into n-1
equal-sized intervals where each adjacent color pair defines a two-color
ramp.
1526 Chapter 19 / Range Attribute Map Statements
Tips Because lines and markers have less surface area, choose
contrasting colors in order to improve visibility.
RANGECOLORMODEL=style-element | (list-of-colors)
specifies either a style element or a list of one or more specific colors for area
fills to represent the defined value range in this range-spec argument.
style-element
specifies the name of a style element. To display the range as a gradient
ramp, choose a style element such as TwoColorRamp, TwoColorAltRamp,
ThreeColorRamp, or ThreeColorAltRamp. The style element should contain
the following style attributes:
To display the range or single value as a color that is defined in a style, use a
style-reference (for example, GraphData1:color) to refer to a color attribute.
The following style references correspond to the keywords that are available
in this statement’s range-spec argument:
MISSING GraphMissing:ContrastColor
OTHER GraphOther:ContrastColor
UNDER GraphUnderflow:ContrastColor
OVER GraphOverflow:ContrastColor
(list-of-colors)
a space-separated list of two or more color keywords that is enclosed in
parentheses.
Two colors create the endpoints of a ramp. The first color is assigned to the
low value in the range specification, and the second color is assigned to the
high value. Three or more colors partition the range specification into n–1
equal-sized intervals, where each adjacent color pair defines a two-color
ramp.
Details
Defining and using the attribute map requires you to coordinate settings on several
statements:
n Use the RANGEATTRMAP statement to start the attribute definition and assign
a name to it.
n Nest within the RANGEATTRMAP block at least one RANGE statement that
specifies a numeric value or numeric range and the color, contrast color, or both,
to associate with that value or range. Use one RANGE statement for each value
range that you want to map. You can use keywords like MIN and MAX in the
range specification. For complete details about the range specifications, see the
RANGE statement.
n Use the RANGEATTRVAR statement to create a named association between
the defined attribute map and the input column that contains the numeric
values. The ATTRMAP= argument identifies the attribute map and the VAR=
argument identifies the input column. Use the ATTRVAR= argument to assign a
name that can be used to reference the named association in plot statements
within the template.
n Reference the attribute map where needed. See “Referencing a Range Attribute
Map in Plot Statements” on page 1503.
values or ranges, specify multiple RANGE statements using the following general
syntax for each of the statements:
Examples
The highest range value specified, which is 0.002 in this example, does not have to
be an actual value in the data. The RANGEATTRVAR statement associates the
attribute map with the data column Density and assigns the name RANGEVAR to
the association. The SCATTERPLOT statement references the named association in
its MARKERCOLORGRADIENT= option.
RANGEATTRMAP Statement 1529
Example Program
proc template;
define statgraph attrmap;
begingraph;
entrytitle "Height and Weight Distribution" ;
/* Associate the attribute map with input data column Density and
assign variable name RANGEVAR to the named association */
rangeattrvar attrvar=rangevar var=density attrmap="densityrange" ;
The RANGEATTRVAR statement associates the attribute map with the data
column Depth and assigns the name DEPTHRANGE to the association. The
SURFACEPLOTPARM statement references the named association in its
COLORRESPONSE= option.
Example Program
proc template;
define statgraph surfaceplot;
dynamic type;
begingraph;
/* Define the attribute map and assign the name "depth." */
rangeattrmap name='depth';
range -10 - MAX / rangecolormodel=(green white);
range -20 - -10 / rangecolormodel=(blue green);
range MIN - -20 / rangecolormodel=(darkred blue);
endrangeattrmap;
/* Associate the attribute map with input data column Depth and
RANGEATTRVAR Statement 1531
RANGEATTRVAR Statement
Creates a named association between a range attribute map of numeric values or value ranges and
an input data column.
Requirements: You must place the RANGEATTRVAR statement directly inside the BEGINGRAPH
block between the BEGINGRAPH statement and the first LAYOUT statement. Do
not embed it in any other GTL statement block.
A range attribute map must be created using the RANGEATTRMAP statement.
See: “Example 1: Using a Range Attribute Map to Control Marker Colors” on page 1528
for an example.
Syntax
RANGEATTRVAR ATTRVAR=attrvar-name
VAR=data-column | expression | dynamic
ATTRMAP="attrmap-name";
Required Arguments
ATTRVAR=attrvar-name
specifies a SAS name for the map. This name must be unique among the
RANGEATTRVAR statements within the template. The assigned name can be
1532 Chapter 19 / Range Attribute Map Statements
referenced by other statements that can be associated with the range attribute
map.the attrvar-name
Interaction If the column is not found or the column is of the wrong type for the
attribute map, then the RANGEATTRVAR statement is ignored.
ATTRMAP="attrmap-name "
specifies the name of an existing range attribute map.
Details
The RANGEATTRVAR statement creates and names an association between colors
that are specified in a RANGEATTRMAP block and a numeric column that is in the
data. Attribute maps can be useful for controlling the application of gradient color
in a graph or specifying data values that are independent of the actual data. The
name that is assigned to the association in the RANGEATTRVAR statement is the
name that plot statements must reference to use the attribute map.
PART 12
Chapter 20
Dynamic Variables and Macro Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1535
Chapter 21
Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1539
Chapter 22
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1543
Chapter 23
Conditional Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1555
1534
1535
20
Dynamic Variables and Macro
Variables
PROC TEMPLATE;
DEFINE STATGRAPH template-name ;
BEGINGRAPH;
GTL statements;
ENDGRAPH;
END;
RUN;
1536 Chapter 20 / Dynamic Variables and Macro Variables
Note: For template readability, it is helpful to adopt a naming convention for these
variables to distinguish them from actual option values or column names. Common
conventions include capitalization, or adding leading or trailing underscores to their
names.
Dynamic variables and macro variables can be referenced within the template
definition as
n argument or option values. For example:
Note that macro variable references should not be prefaced with an ampersand (&)
if you want them to resolve at run time.
Macro variables defined by MVAR are strings when they resolve, as with SYMGET()
in the DATA step.
Macro variables defined by NMVAR are converted to numeric tokens when they
resolve, as with SYMGETN() in the DATA step.
The values for a dynamic variable do not have to be provided by the data source.
Rather, you can provide the values in the DYNAMIC statement in PROC
SGRENDER, specifying the values as a space delimited list, enclosed in quotation
marks. Do not use parentheses in the specification.
Dynamic Variables Compared to Macro Variables 1537
In the following example, the graph template specifies a dynamic variable named
TICKS, which is referenced on the XAXISOPTS= option in LAYOUT OVERLAY. The
DYNAMIC statement in PROC SGRENDER provides values for TICKS:
proc template;
define statgraph regress;
dynamic TICKS ;
begingraph;
layout overlay /xaxisopts=(linearopts=(tickvaluelist=TICKS));
scatterplot x=age y=weight;
endlayout;
endgraph;
end;
run;
For more information about using dynamic variables and macro variables in your
templates, see SAS Graph Template Language: User’s Guide.
For dynamic variables, use the DYNAMIC statement with PROC SGRENDER. For
example,
Values for dynamic variables that resolve to column names or strings should be
quoted. Numeric values should not be quoted.
For macro variables, use the current symbol table (local or global) to look up the
macro variable values at run time. For example,
%let locate=inside;
%let trans=0.3;
1538 Chapter 20 / Dynamic Variables and Macro Variables
21
Expressions
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1539
GTL Expressions Compared to WHERE Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1540
An Expression in Statement Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1540
Overview
In Graph Template Language (GTL), as in Base SAS, an expression is an arithmetic
or logical expression that consists of a sequence of operators, operands, and
functions. An operand is a dynamic, a macro variable, a column, a function, or a
constant. An operator is a symbol that requests a comparison, logical operation, or
arithmetic calculation. In GTL, the expression must be enclosed in an EVAL
function.
n a column
When you are building a text string, you can use the || operator to concatenate the
substrings if none of the substrings are a numeric character value. If one or more of
the substrings are a numeric character value such as “1.5”, then the || operator
might produce unexpected results. In that case, use the CATS function to
concatenate the strings instead. Here is an example of using the CATS function to
build a footnote text string that includes the value of dynamic variable maxWeight,
which stores a numeric character value:
/* indicate the maximum weight in a footnote */
entryfootnote eval(cats("Maximum weight: ", maxWeight," lbs"));
For example, in the following line of code, the expression for the Y= argument does
not reduce the number of observations plotted.
Instead, the computed numeric column for the Y= argument consists of 0s and 1s,
based on whether each observation’s Height column value is between 40 and 60.
Whenever expressions are used to create new columns, a new column name is
internally manufactured so that it does not collide with other columns in use.
For the X= argument, expression means any EVAL(expression) that results in either
a numeric or character column. An expression that yields a constant is not valid
because the X= argument does not accept constants.
Similarly, for the Y= argument, expression means any EVAL(expression) that results
in a numeric column. The expression cannot result in a character column or any
constant because the Y= argument accepts only a numeric column.
Automatic Type Conversion. Although expressions that are used in a DATA step
perform automatic type conversion, GTL expression evaluation does not. Thus, you
must use function(s) to perform required type conversions in an expression.
Otherwise, the expression generates an error condition without warning when the
template is executed.
if(substr(value, 1, 2) = "11")
This expression uses the SUBSTR function to determine whether the first two
characters from VALUE evaluate to the string value "11". If VALUE is a string, then
the expression works properly. However, if VALUE is numeric, then the expression
generates an error condition. For a numeric, you must convert the value to a string
before passing it to the SUBSTR function. The following modification uses the
CATS function to perform the type conversion when necessary:
22
Functions
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1543
SAS Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1544
SAS Functions That Can Be Used in a GTL Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1544
SAS Functions That Can Be Used to Create Flexible Templates . . . . . . . . . . . . . . . . . . 1544
Examples of Using the IFC and IFN SAS Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1545
Functions Defined Only in GTL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1547
GTL Functions Used with the EVAL Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1547
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1548
Using the TYPEOF SAS Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1549
GTL Summary Statistic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1550
Commonly Used Summary Statistic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1550
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1552
Overview
GTL supports a large number of functions, including:
n SAS functions that can be used in the context of a WHERE expression
SAS Functions
Not all SAS functions are available in WHERE expressions. Call routines and other
DATA-step-only functions (for example, LAG, VNAME, OPEN) are some examples
of functions that cannot be used. Not all functions that are available in WHERE
expressions are supported in GTL templates in all cases. The following form of the
PUT function is an example:
markercharacter = eval(put(amount, dollar7.2 -L))
This form results in an error when the template is compiled. However, the following
form is supported.
markercharacter = eval(put(amount, dollar7.2))
If you want to justify a string that is generated by the PUT function, use the LEFT or
RIGHT function with the PUT function as shown in the following example:
markercharacter = eval(left(put(amount, dollar7.2)))
Functions that accept null parameter values also might not be supported when you
specify a null parameter value.
For more information about SAS functions, see “Dictionary of Functions and CALL
Routines” in SAS Functions and CALL Routines: Reference.
Here is an example that uses both the IFN and IFC functions for creating a sales-
based commission chart for employees in a sales group. Each employee in the
group works in one of two sales units: Products and Services. The data for this
example includes the employee ID, total sales, and sales unit code for each member
of the sales group. Here is the data.
data sales;
input empID totalSales salesUnit $18;
format totalSales dollar9.;
datalines;
112876 129489.44 P
112421 169842.97 S
115331 108763.51 S
110765 181009.22 P
113722 147688.78 P
;
The TotalSales column contains the total sales for each employee. The SalesUnit
column contains a code that identifies the sales unit in which each employee works.
The codes are P for the Products unit and S for the Services unit.
The two bar charts show the total sales and earned commission for each employee.
The IFN function is used to compute commission for each employee based on his or
her total sales. Employees that achieved a sales total of $120,000 or more earn a
commission of 5% of their total sales. All other employees earn a commission of
2.5% of their total sales.
An axis table along the X axis shows the sales unit for each employee. The IFC
function is used to convert the P and S SalesUnit codes into more descriptive
values in the axis table. Because only two sales unit codes are used in this case, the
IFC function can be used for this purpose. This eliminates the need to add a new
column to the data in a DATA step or to create and apply a custom format to the
SalesUnit column.
Here is the SAS code that defines the template and generates the graph.
proc template;
define statgraph commission;
begingraph;
entrytitle "Sales-Based Commission";
layout overlay /
xaxisopts=(label="Employee ID")
yaxisopts=(label="Total Sales")
y2axisopts=(label="Commission"
linearopts=(viewmax=15000 tickvalueformat=dollar9.));
/* Generate the sales bar chart. */
barchart category=empID response=totalSales /
name="Sales" legendlabel="Total Sales" barwidth=0.3
discreteoffset=-0.2 fillattrs=graphData1;
/* Add an axis table that shows the sales unit for each
employee. */
innermargin / align=bottom;
axistable x=empID
/* Use IFC to convert the codes to meaningful
values. */
value=eval(ifc(salesUnit = 'P',"Products",
"Services")) / display=(values);
endinnermargin;
discretelegend "Sales" "Commission";
endlayout;
endgraph;
end;
run;
Examples
TYPEOF(column)
This function returns the character ‘C’ if the specified column is a character column
or ‘N’ if it is a numeric column.
You can use the TYPEOF function to take specific actions in your template at run
time based on the input data type. Here is an example that creates a graph of two
columns and uses the TYPEOF function to select a graph type that is appropriate
for the column types. The result returned by the TYPEOF function determines the
graph type as follows:
n If both columns are numeric, then it creates a scatter plot.
Here is the output for the third case, a numeric X column and a character Y column.
proc template;
define statgraph plot;
dynamic cat resp; /* Category and response columns. */
begingraph;
entrytitle "Graph of " eval(collabel(resp)) " and "
eval(collabel(cat));
layout overlay;
/* If cat and resp are numeric, then generate a scatter plot.
Otherwise, generate a bar chart. */
if (typeof(cat) = "N" and typeof(resp) = "N")
scatterplot x=cat y=resp;
else
/* If cat is a character column, then generate a vertical bar
chart. Otherwise, generate a horizontal bar chart. */
if (typeof(cat) = "C")
barchart category=cat response=resp / stat=mean;
else
barchart category=resp response=cat /
stat=mean orient=horizontal;
endif;
endif;
endlayout;
endgraph;
end;
run;
Note: See “Functions Defined Only in GTL” on page 1547 for information about the
COLLABEL function.
The GTL summary statistic functions take precedence over similar multi-argument
DATA step functions. The following table lists the GTL summary statistic functions
that you can use.
CV Coefficient of variation
KURTOSIS Kurtosis
MEAN Mean
P1 1st percentile
P5 5th percentile
Q1 First quartile
Q3 Third quartile
RANGE Range
SKEWNESS Skewness
SUM Sum
T Student’s t statistic
VAR Variance
Example
The following example uses GTL summary statistic functions to dynamically
construct reference lines and a table of statistics for a numeric variable, which is
supplied at run time.
/* create inset */
layout gridded / columns=2 order=rowmajor
autoalign=(topleft topright) border=true;
entry halign=left "N";
entry halign=left eval(strip(put(n(NUMVAR),12.0)));
entry halign=left "Mean";
entry halign=left eval(strip(put(mean(NUMVAR),12.2)));
entry halign=left "Std Dev";
entry halign=left eval(strip(put(stddev(NUMVAR),12.2)));
endlayout;
endlayout;
endgraph;
end;
run;
run;
1555
23
Conditional Logic
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1555
Conditional Logic Determines Statement Rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1556
GTL Does Not Provide ELSE IF Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1557
Overview
GTL supports conditional logic that enables you to include or exclude one or more
GTL statements at run time:
IF (condition)
GTL-statement(s);
ELSE
GTL-statement(s);
ENDIF;
Examples:
/* test a computed value */
if (weekday(today()) in (1 7))
entrytitle "Run during the work week";
else
entrytitle "Run during the weekend";
endif;
referenceline y=0;
referenceline y=-1;
endif;
if (LOGFLAG)
scatterplot x=date y=amount;
else
scatterplot x=date y=log(amount);
endif;
Also, it is seldom necessary to test for the existence of option values set by
columns or dynamic variables. Consider the following statement:
if (exists(GROUPVAR))
scatterplot x=date y=amount / group=GROUPVAR;
else
scatterplot x=date y=amount;
endif;
GTL Does Not Provide ELSE IF Syntax 1557
The GTL code that is conditional must be complete statements, or complete blocks
of statements, or both. The following IF block produces a compile error because
there are more LAYOUT statements than ENDLAYOUT statements:
if (exists(SQUAREPLOT))
layout overlayequated / equatetype=square;
scatterplot x=XVAR y=YVAR;
endlayout;
else
layout overlay;
scatterplot x=XVAR y=YVAR;
endlayout;
endif;
IF (condition-1)
GTL-statement(s);
ELSE
IF (condition-2)
GTL-statement(s);
ELSE
GTL-statement(s);
ENDIF;
ENDIF;
1558 Chapter 23 / Conditional Logic
1559
PART 13
Appendixes
Appendix 1
ODS GRAPHICS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1561
Appendix 2
Reserved Keywords and Unicode Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1595
Appendix 3
Display Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1599
Appendix 4
Format Support in ODS Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1621
Appendix 5
Generalized Macro for BOXPLOTPARM Data . . . . . . . . . . . . . . . . . . . . . . . . . . . 1627
Appendix 6
Memory Management for ODS Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1633
1560
1561
24
ODS GRAPHICS Statement
Dictionary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1561
ODS GRAPHICS Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1561
Dictionary
Default: ON. Beginning in SAS 9.4, ODS Graphics is enabled by default on all platforms
except z/OS. When running SAS in batch mode, the default is OFF.
Interaction: SAS/GRAPH device-based global statements such as GOPTIONS, SYMBOL,
PATTERN, AXIS, and LEGEND do not affect template-based graphics. The ODS
GRAPHICS statement does not affect device-based graphics.
Syntax
ODS GRAPHICS <OFF | ON> </ options> ;
1562 Chapter 24 / ODS GRAPHICS Statement
specifies the maximum number of bins that are processed for heat maps.
OBSMAX=n
specifies the maximum number of observations that are processed.
OUTPUTFMT=file–type | STATIC
specifies the output format used to generate image or vector graphic
files.
PANELCELLMAX=n
specifies the maximum number of cells in a graph panel where the
number of cells is determined dynamically by classification variables.
PUSH
POP
pushes and pops ODS GRAPHICS settings in a stack.
RESET | RESET= option
Reset one or more ODS GRAPHICS options to its default.
SCALE | NOSCALE | SCALE=ON | OFF
specifies whether the content of a graph is scaled proportionally.
SCALEMARKERS | NOSCALEMARKERS | SCALEMARKERS=ON | OFF
specifies whether the plot markers are to be scaled with the graph size.
SHOW
writes the current ODS Graphics settings to the SAS log.
STACKDEPTHMAX=n
specifies the maximum stack depth for PUSH and POP requests.
SUBPIXEL | NOSUBPIXEL | SUBPIXEL=ON | OFF
specifies whether subpixel rendering should be used for rendering ODS
Graphics.
TIPMAX=n
specifies the maximum number of distinct data tip areas allowed before
data tips are disabled.
TOTALCELLMAX=n
specifies the maximum number of total cells in a graph where the number
of cells is determined dynamically by classification variables.
WIDTH=dimension
specifies the width of any graph.
Without Arguments
If ODS Graphics is currently disabled, then specifying the ODS GRAPHICS
statement without options enables it. If ODS Graphics is currently enabled, then
specifying the ODS GRAPHICS statement leaves it enabled.
Required Arguments
ON
enables ODS Graphics processing. This is the default if no argument is used.
Note: Beginning in SAS 9.4, ODS Graphics is enabled by default on all platforms
except z/OS.
1564 Chapter 24 / ODS GRAPHICS Statement
Alias YES
OFF
disables ODS Graphics processing.
Alias NO
Optional Arguments
ANTIALIAS | NOANTIALIAS | ANTIALIAS= ON | OFF
specifies whether anti-aliasing is applied to the rendering of the line and
markers in any graph. Anti-aliasing smooths the appearance of lines and some
markers. Text displayed in the graph is always anti-aliased. For graphical
displays that plot large numbers of points it is recommended that
ANTIALIAS=OFF be specified for performance considerations.
ANTIALIAS
smooths jagged edges of all components in the graph.
NOANTIALIAS
does not smooth jagged edges of components other than text in the graph.
ANTIALIAS=ON | OFF
specifies whether anti-aliasing is applied to the rendering of the line and
markers in the graph.
ON
smooths jagged edges of all components in the graph.
Alias YES
OFF
does not smooth jagged edges of components other than text in the
graph.
Alias NO
Restrictions If the number of markers or lines in the plot exceeds the number
specified by the ANTIALIASMAX= option, then the ANTIALIAS
option is disabled. This is true even if you specify the option
ANTIALIAS=ON or ANTIALIAS.
ANTIALIASMAX= n
specifies the maximum number of graphics elements before anti-aliasing is
disabled. For example, if there are more than 400 scatter point markers to be
anti-aliased and ANTIALIASMAX=400, then no markers are anti-aliased. The
default value is 4000.
Note: Prior to SAS 9.4M3, the ANTIALIASMAX= option specifies the maximum
number of observations in the graph data to be anti-aliased before anti-aliasing
ODS GRAPHICS Statement 1565
is disabled. The default is 4000. When the graph data contains more than 4000
observations, anti-aliasing is disabled for the entire graph. Starting with SAS
9.4M3, the ANTIALIASMAX= option specifies the maximum number of graphics
elements to be anti-aliased in each plot on a per-plot basis. The default remains
at 4000. If any plot in a graph contains more than 4000 elements, anti-aliasing
is disabled for that plot. Anti-aliasing is enabled for the rest of the graph in that
case.
n
specifies a positive integer.
Default 4000
ATTRPRIORITY=COLOR | NONE
specifies a priority for cycling of the group attributes.
COLOR
assigns priority to the color attribute rotation by cycling through the list of
colors while holding the marker symbol and line pattern constant. When all
of the colors are exhausted, the marker symbol and line style attributes
increment to the next element, and then the colors in the list are repeated.
This pattern repeats as needed.
NONE
does not use an attribute priority in the rotation pattern, even if one is set in
the active style’s AttrPriority attribute. The rotation pattern cycles
progressively through the attribute lists.
Default The AttrPriority attribute of the graph style element, or NONE if the
current style does not define the AttrPriority style attribute.
Interaction The default lists of data colors, contrast colors, marker symbols, and
line patterns are set in the active style’s GraphData1–GraphDataN
elements.
BORDER
draws a border around the graph.
NOBORDER
does not draw a border around the graph.
BORDER=ON | OFF
specifies whether to draw the graph with a border on the outermost layout.
ON
draws a border around the graph.
1566 Chapter 24 / ODS GRAPHICS Statement
Alias YES
OFF
does not draw a border around the graph.
Alias NO
You can modify the graph template if you want to change how the BY line is
displayed. Because most graphs have titles and few graphs have footnotes, the
BY line looks better when it is displayed as a footnote. For complete
documentation about the Graph Template Language, see SAS Graph Template
Language: User’s Guide.
When the BYLINE= option is specified, and there are BY groups, ODS creates a
BY line and sets the appropriate special dynamic variables. The following table
lists the special dynamic variables for BY lines. For complete documentation
about special dynamic variables, see “Special Dynamic Variables” in SAS Graph
Template Language: User’s Guide.
Table A12.1 Special Dynamic Variables for BY Lines
_BYLINE_ This variable contains the text string that can be displayed as a
title or footnote.
The variables in the table are set automatically only for analytical procedures
that support ODS Graphics. For all other procedures, the variables are not set
ODS GRAPHICS Statement 1567
automatically (NULL). To determine whether the procedure that you are using
supports ODS Graphics, refer to the procedure documentation.
NOBYLINE
specifies that no BY line is displayed. NOBYLINE is the default.
FOOTNOTE
specifies that the BY line is displayed as a left-justified graph footnote. This
is the recommended setting.
TITLE
specifies that the BY line is displayed as a centered graph title. Specifying
TITLE is not recommended because graphs are not designed to have
additional title lines.
Default NOBYLINE
Restriction This option does not work with the ODS Graphics procedures such
as SGPLOT and SGPANEL. To remove BY lines in those procedures,
use the NOBYLINE SAS system option. Example: options
nobyline;
DATASKINMAX=n
specifies the maximum number of graphical elements allowed per plot when a
data skin is applied.
n
specifies a positive integer.
Default 200
DISCRETEMAX=n
specifies the maximum number of discrete values to be shown in any graph. Bar
charts and box plots are examples of affected plot types. Scatter plots and
other plot types can be affected if the data to be plotted is discrete or the axis is
discrete.
n
specifies a positive integer.
Default 1000
"_blank"
opens a new browser window to display the drilldown output.
"_self"
opens the drill-down output in the same window.
"_parent"
opens the drill-down output in the parent frame.
"_top"
opens the drill-down output in the full body of the window.
"frame-name"
opens the drill down output in the named frame in the current window. If the
name does not exist, the output is opened in a new window.
GROUPMAX=n
specifies the maximum number of group values to be shown in any graph. Any
graph that supports the GROUP= option is affected.
n
specifies a positive integer.
Default 1000
HEIGHT=dimension
specifies the height of a graph.
dimension
is a nonnegative number followed by one of these units of measure:
Table A12.2 Units of Measure for Dimension
cm Centimeters
in Inches
mm Millimeters
pct or % Percentage
px Pixels
Defaults The value of the SAS registry entry "ODS > ODS GRAPHICS >
Design Height" or the value of the DesignHeight= option in a
STATGRAPH template. Typically, the value is 480px.
Tips If only the HEIGHT= option is specified, then the default aspect ratio of
the graph is maintained.
When you change the size of a graph, by default graph elements such as
markers, lines, text, and titles are scaled proportionally. This scaling takes
effect even when you specify dimensions for the graph elements. To
disable the scaling, specify the NOSCALE option.
IMAGEMAP
specifies to generate data tips.
NOIMAGEMAP
specifies not to generate data tips.
IMAGEMAP= ON | OFF
controls data tips generation.
1570 Chapter 24 / ODS GRAPHICS Statement
ON
specifies to generate data tips.
Alias YES
OFF
specifies not to generate data tips.
Alias NO
Restrictions This option applies only when one of the ODS HTML* destinations
is used.
Prior to SAS 9.4M5, an image map is not generated using SVG with
ODS Graphics. The image map data that is used to produce tooltips
and links is written directly in the SVG and is not part of the HTML.
Using HTML5 with the inline SVG mode (the default value), the
tooltips and links are written in the SVG portion of the document.
(If you are using SAS 9.4M5, see the following Note.)
Note Starting with SAS 9.4M5, image maps are supported with SVG
output using HTML5. However, image maps are supported only
when the HTML5 SVG mode is INLINE (the default value).
IMAGENAME="filename"
specifies the base image filename. If more than one image is generated, each is
assigned a filename that consists of a base name followed by a number in order
to create unique names. This numbering can be reset with the RESET=INDEX
option. Path information (if needed) can be set with the GPATH= option on the
ODS destination statement. The default path is the current output directory. A
file extension for filename is automatically generated based on the
OUTPUTFMT= option.
Note: Starting with SAS 9.4M5, if a BY statement is in effect, you can uniquely
name image files based on BY groups. To do this, insert #BY text into the image
name. For more information, see “Substituting BY Values in the Image Name” on
page 1585.
Restrictions filename must be a single name. It must not include any path
specification or image-format name extension.
LABELMAX=n
specifies the maximum number of labeled areas before data label collision
avoidance is disabled. For example, if there are more than 50 points to be
labeled and LABELMAX=50, then collision avoidance is turned off and the
labels are all displayed at the top right of the data points.
n
specifies a positive integer.
Default 200
Restriction Data label collision avoidance is turned off under the following
conditions:
n The number of observations with
nonmissing labels exceeds the
value specified by LABELMAX=.
n The number of observations
exceeds five times the value
specified by LABELMAX=.
A message is then sent to the SAS log.
LABELPLACEMENT= GREEDY | SA
specifies the label-placement algorithm to use for positioning labels in the
graphs. The following labels are affected:
n data labels for needle plots, scatter plots, series plots, step plots, and vector
plots
n vertex labels for line charts
n curve labels when the curve label is positioned at the start or end of the
curve
GREEDY
specifies the Greedy method for managing label collision. The Greedy
method tries different placement combinations in order to find an optimal
approximation that avoids collisions. Label placement using this method is
often less optimal than label placement using the Simulated Annealing (SA)
method. However, depending on the number of data points and the potential
for label collisions, the Greedy process can be significantly faster.
SA
specifies the Simulated Annealing method for managing label collision. The
SA method attempts to determine the global minimization-of-cost function,
which is based on a simulated annealing algorithm. The resulting label
placement is usually better than placement using the Greedy method.
However, depending on the number of data points and the potential for label
collisions, the SA method can be significantly slower.
1572 Chapter 24 / ODS GRAPHICS Statement
Default GREEDY
LEGENDAREAMAX=n
specifies an integer that is interpreted as the maximum percentage of the
overall graphics area that a legend can occupy.
n
specifies a positive integer.
Alias MAXLEGENDAREA=
Default 20
Range 0–100
LINEPATTERNOBSMAX=n
specifies the maximum the number of vertices for a patterned line. If the
number of vertices exceeds the specified limit, the plot is not drawn.
n
specifies a positive integer.
Default 10000
Note If the number of vertices exceeds the specified limit, the plot is not
drawn and a note is written to the SAS log. In that case, increase
LINEPATTERNOBSMAX= to the value suggested in the log message,
or change the line pattern to SOLID.
LOESSOBSMAX=n
specifies an upper limit for the number of observations that can be used with a
loess plot.
ODS GRAPHICS Statement 1573
Note: This feature applies to SAS 9.4M3 and later releases. LOESSOBSMAX=
replaces LOESSMAXOBS=. However, LOESSMAXOBS= is supported as an alias.
It is recommended that you use LOESSOBSMAX=.
If the number of observations of the loess plot exceeds the specified limit, the
loess plot is not drawn.
For example, the following specifies that the most observations a loess plot can
have is 1000.
LOESSOBSMAX=1000
Alias LOESSMAXOBS=
Default 5000
NBINSMAX=n
specifies the maximum number of bins that are processed for histograms. This
option affects both computed and parameterized histograms, when available.
n
specifies a positive integer.
Default 10000
Interaction If you specify the number of bins in the histogram plot statement
NBINS= option, that option is honored if the NBINS= value
specified is less than or equal to the NBINXMAX= value. If the
NBINS= value specified exceeds the NBINSMAX= value, an error
occurs, and the histogram is not drawn.
NXYBINSMAX=n
specifies the maximum number of bins that are processed for heat maps. This
option affects both computed and parameterized heat maps. The option applies
to the product of the X and Y bins.
n
specifies a positive integer.
Default 100000
1574 Chapter 24 / ODS GRAPHICS Statement
Interaction If you specify the number of bins in the heat map statement, that
option is honored regardless of the NXYBINSMAX= option.
OBSMAX=n
specifies the maximum number of observations that are processed. If the
number of observations in the data set exceeds the value specified for
OBSMAX=, the procedure step terminates with a log message.
n
specifies a positive integer.
Alias MAXOBS=
OUTPUTFMT=file–type | STATIC
specifies the output format used to generate image or vector graphic files. If the
image or vector graphic format is not valid for the active output destination, the
format is automatically changed to the default format for that destination.
file-type
is the image or vector graphic format to be generated. See “Supported File
Types for Output Destinations” on page 1590.
STATIC
uses the best quality static image format for the active output destination.
This is the default output format.
TIP The STATIC keyword can be used to reset the output format to
its default state.
Default STATIC
PANELCELLMAX=n
specifies the maximum number of cells in a graph panel where the number of
cells is determined dynamically by classification variables. If the number of cells
in the panel exceeds the specified limit, the panel is not drawn.
n
specifies a positive integer.
ODS GRAPHICS Statement 1575
Default 1000
Tip You can use the TOTALCELLMAX= option to control the total
maximum number of cells in the graph.
PUSH | POP
pushes and pops ODS GRAPHICS settings in a stack. This feature enables you
to temporarily save your custom settings in a stack and later restore those
settings.
PUSH
pushes the current ODS GRAPHICS settings to a stack.
POP
restores the most recently pushed settings from the stack. For each PUSH
action, you can specify a POP request. ODS issues a warning if you specify
POP without a corresponding PUSH. In that case, nothing is popped because
nothing has been pushed.
The pushed settings remain in the stack in the current SAS session until they are
popped or the stack is emptied.
Interaction You can specify PUSH as many times as you like up to the limit that
is defined by the STACKDEPTHMAX= option. You can also use
STACKDEPTHMAX= to empty the stack. For more information, see
“Managing the Stack Depth” on page 1594.
Note Order of specification is important when using the PUSH and POP
options. For more information, see “About PUSH and POP” on page
1593.
Tip Use the SHOW option to show the current ODS GRAPHICS settings.
RESET
resets all options to their defaults.
RESET=
resets one of the following to its default:
ALL
resets all reset-options to their defaults.
1576 Chapter 24 / ODS GRAPHICS Statement
ANTIALIAS
resets the ANTIALIAS= option to its default.
ANTIALIASMAX
resets the ANTIALIASMAX= option to its default.
ATTRPRIORITY
resets the ATTRPRIORITY= option to its default.
BORDER
resets the BORDER= option to its default.
BYLINE
resets the BYLINE= option to its default.
DATASKINMAX
resets the DATASKINMAX= option to its default.
DISCRETEMAX
resets the DISCRETEMAX= option to its default.
DRILLTARGET
resets the DRILLTARGET= option to its default.
GROUPMAX
resets the GROUPMAX= option to its default.
HEIGHT
resets the HEIGHT= option to its default.
IMAGEMAP
resets the IMAGEMAP= option to its default.
IMAGENAME
resets the IMAGENAME= option to its default.
INDEX <(positive-integer)>
resets the index counter that is appended to static image files.
When specifying this option, you can also specify the value for the index
counter. The number that you specify must be enclosed in parentheses.
positive-integer determines the suffix for the next subsequent image, and
increments with each new image.
LABELMAX
resets the LABELMAX= option to its default.
LABELPLACEMENT
specifies the label-placement algorithm to use for positioning labels in
the graphs.
LEGENDAREAMAX
resets the LEGENDAREAMAX= option to its default.
LOESSOBSMAX
resets the LOESSOBSMAX= option to its default.
NBINSMAX
resets the NBINSMAX= option to its default.
NXYBINSMAX
resets the NXYBINSMAX= option to its default.
OUTPUTFMT
resets the OUTPUTFMT= option to its default.
PANELCELLMAX
resets the PANELCELLMAX= option to its default.
SCALE
resets the SCALE= option to its default.
SCALEMARKERS
resets the SCALEMARKERS= option to its default.
STACKDEPTHMAX
resets the STACKDEPTHMAX= option to its default.
SUBPIXEL
resets the SUBPIXEL option to its default.
TIPMAX
resets the TIPMAX= option to its default.
WIDTH
resets the WIDTH= option to its default.
SCALE
scales the components of a graph proportionally.
ODS GRAPHICS Statement 1579
NOSCALE
does not scale the components of a graph proportionally.
SCALE=ON | OFF
specifies whether the content of a graph is scaled proportionally.
ON
scales the components of a graph proportionally.
Alias YES
OFF
does not scale the components of a graph proportionally.
Aliases NOSCALE
NO
SCALEMARKERS
scales the markers with the graph size.
NOSCALE
does not scale the markers with the graph size.
SCALEMARKERS=ON | OFF
specifies whether the plot markers are to be scaled with the graph size.
ON
scales the markers with the graph size.
Alias YES
OFF
does not scale the markers with the graph size.
Aliases NOSCALE
NO
Restriction Scaling is done only if the graph contains multiple cells or single
nested cells.
SHOW
writes the current ODS Graphics settings to the SAS log. This option enables
you to verify which settings are in effect. The option is especially useful when
you use the PUSH and POP options to restore settings. For more information,
see “Temporarily Saving and Restoring ODS GRAPHICS Settings” on page 1593.
1580 Chapter 24 / ODS GRAPHICS Statement
If no options have been specified, then SHOW lists those options for which ODS
currently knows the default values.
The following statement resets all settings and shows the default values.
ods graphics / reset=all show;
If you have specified the settings for one or more options, then SHOW includes
those settings along with the defaults.
Order of specification is important when using the SHOW option. For example,
the following statement shows the current settings and then sets the
NOBORDER option.
ods graphics / show noborder;
However, the following statement sets the NOBORDER option and then shows
the settings. The NOBORDER setting is shown in the log along with the other
settings that are in effect.
ods graphics / noborder show;
The following statement resets all settings. It then sets the image width and
shows the default settings along with the specified width.
ods graphics / reset=all width=5in show;
Here are the default values plus the image width, as displayed in the SAS log:
ODS Graphics Settings
---------------------
Output format: STATIC
By line: NOBYLINE
Antialias: ON
Maximum Loess observations: 5000
Image width: 5in
Maximum stack depth: 1024
Stack depth: 0
MaxObs: 2000000
Maximum Histogram Bins: 10000
Maximum Heatmap Bins: 100000
ODS GRAPHICS Statement 1581
Tip If you have specified the settings for some options but want to see the
default values without losing your specified settings, issue the following
two statements. The first statement pushes your specified settings, resets
all settings, and then lists options for which ODS currently knows the
default values. The second statement restores your previous settings.
ods graphics / push reset=all show;
ods graphics / pop;
STACKDEPTHMAX=n
specifies the maximum stack depth for PUSH and POP requests. The stack is
used to temporarily store ODS GRAPHICS settings when you issue PUSH
requests. PUSH saves the current settings to the stack and increments the stack
depth. POP restores the most recently saved settings from the stack and
decrements the stack depth.
n
specifies a positive integer.
If n is less than the current stack depth, then the stack is popped until its
depth equals n. Popping the stack does not affect other option settings.
Tips To empty the stack and then reset it to the default maximum depth,
issue the following statement:
ods graphics / stackdepthmax=0 reset=stackdepthmax;
You can use any of the following commands to reset the stack to its
default maximum depth:
reset=stackdepthmax
reset=all
reset
stackdepthmax=1024
SUBPIXEL
always uses subpixel rendering, when applicable, for rendering lines and
bars.
1582 Chapter 24 / ODS GRAPHICS Statement
NOSUBPIXEL
never uses subpixel rendering.
SUBPIXEL=ON | OFF
specifies whether subpixel rendering should be used.
ON
always uses subpixel rendering, when applicable, for rendering lines and
bars.
Alias YES
OFF
never uses subpixel rendering.
Alias NO
Requirement Antialiasing must be enabled for this option to have any effect.
Antialiasing is enabled by default. To re-enable antialiasing, use
the ANTIALIAS=ON option in the ODS GRAPHICS statement.
TIPMAX=n
specifies the maximum number of distinct data tip areas allowed before data
tips are disabled. For example, if there are more than 400 points in a
scatterplot, and TIPMAX=400, then no data tips appear. The default maximum
value is 500.
Note: Prior to SAS 9.4M3, the TIPMAX= option specifies the maximum number
of observations in the graph data to be allowed before data tips are disabled.
The default is 500. When the graph data contains more than 500 observations,
data tips are disabled for the entire graph. Starting with SAS 9.4M3, the
TIPMAX= option specifies the maximum number of data-tip areas allowed
before data tips are disabled. This threshold is applied separately for each plot.
The default remains at 500. If any plot in a graph contains more than 500 data-
tip areas, data tips are disabled for that plot. Data tips are enabled for the
remaining plots in the graph.
n
specifies a positive integer.
ODS GRAPHICS Statement 1583
Default 500
TOTALCELLMAX=n
specifies the maximum number of total cells in a graph where the number of
cells is determined dynamically by classification variables.
If the number of cells exceeds the specified limit, the graph is not drawn. This
option is useful when multiple classification variables or large amounts of data
result in a large number of cells.
n
specifies a positive integer.
Default 2000
Tip You can use the PANELCELLMAX= option to control the maximum
number of cells in a graph panel.
WIDTH=dimension
specifies the width of any graph.
dimension
is a nonnegative number followed by one of these units of measure:
Table A12.3 Units of Measure for Dimension
cm Centimeters
in Inches
mm Millimeters
pct or % Percentage
px Pixels
1584 Chapter 24 / ODS GRAPHICS Statement
Defaults The value of the SAS registry entry "ODS > ODS GRAPHICS >
Design Width" or the value of the DesignWidth= option in a
STATGRAPH template. Typically, this value is 640px.
Tips If only the WIDTH= option is specified, then the default aspect of the
graph is maintained.
When you change the size of a graph, by default graph elements such as
markers, lines, text, and titles are scaled proportionally. This scaling takes
effect even when you specify dimensions for the graph elements. To
disable the scaling, specify the NOSCALE option.
Details
When you specify one of these statements before your procedure invocation, Base,
SAS/STAT, SAS/ETS, and SAS/QC procedures support ODS Graphics, either by
default, or when you specify procedure options for requesting particular graphs.
The ip_address is the TCP/IP address, or the name of a UNIX terminal. Usually, the
IP address of the UNIX system where SAS is running would be used. If you do not
set the DISPLAY variable, then you get an error message in the SAS log.
ODS GRAPHICS Statement 1585
The assigned name REGPLOT is treated as a "root" name and the first output
created is named REGPLOT. Subsequent graphs are named REGPLOT1, REGPLOT2,
and so on, with an increasing index counter. This numbering can be reset with the
RESET=INDEX option.
For a usage example, suppose that you are developing a paper or a presentation
and it takes several submissions to get the desired output. You can use the RESET
or RESET=INDEX option to force each output to replace itself:
ods graphics / reset=index ... ;
This specification causes all subsequent images to be created with the default or
current image name.
When specifying this option, you can also specify the value for the index counter.
The value that you specify determines the suffix for the next subsequent image.
For example:
ods graphics / reset=index(100) imagename="MyName";
This feature is useful for creating animated graphics. For example, for a sequence of
100 images, you might begin with the following statement:
ods graphics / reset=index(1) imagename="MyName";
If a BY statement is in effect for the data, then you can uniquely name image files
based on BY groups. You do this by inserting any of the #BY* substitution items
into the image file name. You can specify BY variable values or BY variable names
1586 Chapter 24 / ODS GRAPHICS Statement
for IMAGENAME=. You can combine the #BY* substitution item with other text. To
do this, insert the #BY* item in the specified text string at the position where you
want the substitution text to appear.
#BYVALn | #BYVAL(BY-variable-name)
substitutes the current value of the specified BY variable for #BYVAL in the file
name string. Specify the variable with one of these:
n
specifies a variable by its position in the BY statement. You must provide the
position even if your BY statement contains only one variable. Otherwise, no
substitution occurs.
BY-variable-name
specifies a variable from the BY statement by its name. BY-variable-name is
not case sensitive.
#BYVARn | #BYVAR(BY-variable-name)
substitutes the name of the BY variable or the label associated with the variable
(whatever the BY line would normally display) for #BYVAR in the file name
string. Specify the variable with one of these:
n
specifies a variable by its position in the BY statement. You must provide the
position even if your BY statement contains only one variable. Otherwise, no
substitution occurs.
BY-variable-name
specifies a variable from the BY statement by its name. BY-variable-name is
not case sensitive.
Note: When using this feature, consider any file name length restrictions that
might apply to your platform host. The file name length can vary greatly depending
on the input data.
Note: Unless you have a special requirement for changing the image format, we
recommend that you not change it. The default PNG or vector graphic format is far
superior to other formats, such as GIF, in support for transparency and a large
number of colors. Also, PNG and vector graphics images require much less disk
storage space than JPEG or TIFF formats.
If you want to generate vector graphics images, you can use the following
OUTPUTFMT= values for each destination:
OUTPUTFMT=PCL
Note: For information about SVG and SAS Universal Printing, see “Creating SVG
Documents Using Universal Printing” in SAS 9.4 Universal Printing.
When a vector graphics image cannot be generated for the format that you specify,
a PNG image is generated instead and is embedded in the specified output file. The
output file format and extension are not changed in that case. In the following
cases, a vector graphics image cannot be generated:
n surface plots
n bivariate histograms
Starting with SAS 9.4M2, additional cases for which vector graphics output cannot
be generated for graphs are as follows:
n graphs that use gradient fill for bars in a bar chart, histogram, or waterfall chart
n graphs that include a text plot that displays text with an outlined bounding box
or text with a filled bounding-box background
n graphs that include images (PostScript output only)
Starting with SAS 9.4M3, vector graphics output can be generated in the EMF, PDF,
and SVG output formats for the following cases:
n graphs that use data skins
Note: For the EMF, PDF, and SVG formats, vector graphics output is not
supported for graphs that use transparency and data skins. An image is
generated in that case.
Note: For the PDF output format, vector graphics output is not supported for
graphs that use a continuous legend and data transparency. An image is
generated in that case.
Starting with SAS 9.4M5, vector graphics output can or cannot be generated in the
output formats as indicated in the following table:
Surface plots No No No No No
Text plots with fill and outline Yes No Yes Yes Yes
1 Starting with SAS 9.4M7, vector graphics are supported for transparent images in EMF, PDF, and SVG output. The image
itself must be transparent. If you make an image transparent by specifying transparency in your program, a vector graphic
is not created.
Note: The SGMAP procedure, which is new in SAS 9.4M5, does not support vector-
based output.
LISTING PNG (default), BMP, EMF, EPSI, GIF, JFIF, JPEG, JPG,
PDF, PS, SASEMF, STATIC, TIFF, WMF, PSL, SVG
ODS destination for PNG (default), JPEG, JPG, GIF, EMF, TIFF, BMP
PowerPoint
RTF and Measured RTF EMF (default), PNG, JPEG, JPG, JFIF
EMF Dual (Enhanced Metafile Format Produces both EMF and EMF Plus
and Enhanced Metafile Format Plus formats simultaneously in the same
Extensions) output.
JFIF (JPEG File Interchange Format) Supports JPEG image compression. JFIF
software is developed by the
Independent JPEG Group.
JPEG or JPG (Joint Photographic Experts A file format that is used for storing
Group) noninteractive images.
PNG (Portable Network Graphic) Supports true color, gray-scale, and 8-bit
images.
PS (PostScript Image File Format) The Image classes use only PostScript
image operators. A level II PS printer is
required for color images. PostScript was
developed by Adobe Systems, Inc.
Although you can use the RESET option to restore the default ODS GRAPHICS
settings, there might be times when you want to save your current custom settings
and later restore them. ODS enables you to temporarily store your custom settings
in a stack created for this purpose, perform some other task with different settings,
and then restore the previous settings.
The PUSH option saves the current ODS GRAPHICS settings to the stack and
increments the stack depth. The POP option restores the most recently stored
settings from the stack and decrements the stack depth.
This feature is useful when you write macros. Within a macro you can PUSH at the
start of the macro and POP at the end. This enables your macro to have custom
ODS GRAPHICS behaviors without affecting the calling environment.
You can specify PUSH as many times as you like up to the limit that is defined by
the STACKDEPTHMAX= option. The pushed settings remain in the stack in the
current SAS session until they are popped or the stack is emptied. For more
information, see “Managing the Stack Depth” on page 1594. For each PUSH option,
you can specify a POP option. ODS issues a warning if you specify POP without a
corresponding PUSH. In that case, nothing is popped because nothing has been
pushed to the stack.
Order of specification is important when using the PUSH option. For example, the
following statement pushes the NOBORDER option to the stack along with any
other custom settings that are in effect.
ods graphics / noborder push;
However, the following statement pushes the current custom settings and then
sets the NOBORDER option.
ods graphics / push noborder;
Here, the subsequent POP option restores whatever border setting was in effect
when the PUSH option was specified.
1594 Chapter 24 / ODS GRAPHICS Statement
TIP Use the SHOW option to show the ODS GRAPHICS settings that are
currently in effect.
A syntax error (BOGUS) in ANTIALIAS causes the parser to ignore the remaining
options. However, a simple semantics error does not prevent the remaining options
from being handled. In the following statement, the PUSH option is honored.
ods graphics / antialiasmax=-1 push;
Note: Syntax errors in your code can have other unexpected results that are not
described here.
If the specified STACKDEPTHMAX= value is less than the current stack depth, then
the stack is popped until its depth equals the specified value. Popping the stack
does not affect other option settings.
This statement first empties the stack of all PUSH requests and then restores the
stack size to 1024.
1595
Appendix 2
Reserved Keywords and Unicode
Values
Overview
The tables in this section show some of the reserved keywords and Unicode values
that can be used with the UNICODE text command. For information about
rendering Unicode characters, see “Managing the String on Text Statements” in SAS
Graph Template Language: User’s Guide.
mu μ 03BC lowercase mu
nu ν 03BD lowercase nu
xi ξ 03BE lowercase xi
pi π 03C0 lowercase pi
Special Characters
Keyword Glyph Unicode Description
Appendix 3
Display Attributes
style-element
specifies the name of a style element. Only style attributes that are relevant for
rendering the fill, line, data marker, or text are used.
style-element (options)
specifies the name of a style element, plus individual options to be used as style
overrides. Options is a space-delimited list of option = value pairs. Any options
that are not specified are derived from the specified style element.
(options)
specifies individual options as a space-delimited list of option = value pairs. Any
options that are not specified are derived from the default style element.
Depending on the attribute option used, the options might be fill options , line
options , marker options , or text options .
In general, any relevant attribute that is not specified defaults to an internal value,
which is typically derived from the style element that you specify for the attributes.
When choosing a style element, you should use an element of the correct type. See
“Graph Style Elements Used by ODS Graphics” in SAS Graph Template Language:
User’s Guide for a list of style elements and their types.
COLOR=style-reference | color
specifies the fill color. Style-reference must specify a valid style attribute such
as Color, ContrastColor, StartColor, NeutralColor, or EndColor in the form
Attributes Available for the Attribute Options 1601
Color must be a valid color name, such as RED, or a color code, such as
CXFF0000 or #FF0000. The color name must not exceed 64 characters. A
color code must be a valid code for a SAS color-naming scheme, such as RGB,
CMYK, HLS, or HSV (HSB). See “Color-Naming Schemes” on page 1609.
TRANSPARENCY=number
specifies the degree of the transparency of the filled area. This setting enables
you to set the transparency for the filled elements of some graph types. You can
set just this fill transparency, or set the fill independently of the other
transparent elements in the graph. For example, you can use this setting to set
the transparency level for the filled bars of a bar chart, and use the bar chart’s
DATATRANSPARENCY= option to set a different transparency level for the bar
outlines.
COLOR=style-reference | color
specifies the fill color.Style-reference must specify a valid style attribute such
as Color, ContrastColor, StartColor, NeutralColor, or EndColor in the form
style-element-name:attribute-name. If style-reference is not defined in the
active ODS style, the COLOR= option is ignored and the default color is used.
Color must be a valid color name, such as RED, or a color code, such as
CXFF0000 or #FF0000. The color name must not exceed 64 characters. A
color code must be a valid code for a SAS color-naming scheme, such as RGB,
CMYK, HLS, or HSV (HSB). See “Color-Naming Schemes” on page 1609.
PATTERN=style-reference | fill-pattern
specifies the fill pattern. Style-reference is valid starting with SAS 9.4M5. It
must specify a FILLPATTERN attribute in the form style-element-
name:FILLPATTERN. If style-reference is not defined in the active ODS style, the
PATTERN= option is ignored and the default fill pattern is used, if one is
specified by the active ODS style.
1602 Appendix 3 / Display Attributes
L1 R1 X1
L2 R2 X2
L3 R3 X3
L4 R4 X4
L5 R5 X5
Line Options
Use one or more of the following options to specify line attributes. The options
must be enclosed in parentheses and specified as a space-delimited list of name =
value pairs.
COLOR=style-reference | color
specifies the line color. Style-reference must specify a valid style attribute such
as Color, ContrastColor, StartColor, NeutralColor, or EndColor in the form
style-element-name:attribute-name. If style-reference is not defined in the
active ODS style, the COLOR= option is ignored and the default color is used.
Color must be a valid color name, such as RED, or a color code, such as
CXFF0000 or #FF0000. The color name must not exceed 64 characters. A
color code must be a valid code for a SAS color-naming scheme, such as RGB,
CMYK, HLS, or HSV (HSB). See “Color-Naming Schemes” on page 1609.
Pattern
Number Pattern Name Example
1 Solid
2 ShortDash
4 MediumDash
5 LongDash
8 MediumDashShortDash
14 DashDashDot
15 DashDotDot
20 Dash
26 LongDashShortDash
34 Dot
35 ThinDot
41 ShortDashDot
42 MediumDashDotDot
Valid line-pattern numbers range from 1 to 46. Not all line-pattern numbers
have names. See “Available Line Patterns” on page 1607 for a list of all possible
line patterns. We recommend that you use the named patterns because they
have been optimized to provide good discriminability when used in the same
plot.
Note Anti-aliasing might alter the appearance of some line patterns that have
fine detail such as line patterns 33 through 46. For example, if you specify
the color black and the pattern 33 for a line, and anti-aliasing is enabled,
then the line might appear gray. In that case, you can use the ODS
GRAPHICS statement to disable anti-aliasing as shown in the following
example:
ods graphics / antialias = off;
THICKNESS=style-reference | dimension
specifies the line thickness. Style-reference must specify a LINETHICKNESS
attribute in the form style-element-name:LINETHICKNESS.
1604 Appendix 3 / Display Attributes
Marker Options
Use one or more of the following options to specify data-marker attributes. You
must enclose the options in parentheses and specify the options as a space-
delimited list of name = value pairs.
COLOR=style-reference | color
specifies the line color. Style-reference must specify a valid style attribute such
as Color, ContrastColor, StartColor, NeutralColor, or EndColor in the form
style-element-name:attribute-name. If style-reference is not defined in the
active ODS style, the COLOR= option is ignored and the default color is used.
Color must be a valid color name, such as RED, or a color code, such as
CXFF0000 or #FF0000. The color name must not exceed 64 characters. A
color code must be a valid code for a SAS color-naming scheme, such as RGB,
CMYK, HLS, or HSV (HSB). See “Color-Naming Schemes” on page 1609.
Restriction This option has no effect on marker symbols that are created with
the SYMBOLIMAGE statement.
SIZE=style-reference | dimension
specifies the marker size (both width and height). Style-reference must specify a
MARKERSIZE attribute in the form style-element-name:MARKERSIZE.
SYMBOL=style-reference | marker-name
specifies the name of the marker. Style-reference must specify a
MARKERSYMBOL attribute in the form style-element-
name:MARKERSYMBOL.The following table lists the SAS symbols that are
supported.
Table A14.3 Supported Marker Symbols
ArrowDown StarFilled
Asterisk Tack
Circle Tilde
CircleFilled Triangle
Attributes Available for the Attribute Options 1605
Diamond TriangleFilled
DiamondFilled TriangleDown
GreaterThan TriangleDownFille
d
Hash TriangleLeft
HomeDown TriangleLeftFilled
HomeDownFilled TriangleRight
IBeam TriangleRightFille
d
LessThan Union
Plus X
Square Y
SquareFilled Z
Star
You can also specify the names of symbols that are created by the
SYMBOLCHAR and SYMBOLIMAGE statements.
TRANSPARENCY=number
specifies the degree of transparency for the plot markers.
WEIGHT=NORMAL | BOLD
specifies the marker weight.
Restriction This option has no effect on marker symbols that are created with
the SYMBOLCHAR and SYMBOLIMAGE statements.
Text Options
Use one or more of the following options to specify text attributes. The options
must be enclosed in parentheses and specified as a space-delimited list of name =
value pairs.
COLOR=style-reference | color
specifies the line color. Style-reference must specify a valid style attribute such
as Color, ContrastColor, StartColor, NeutralColor, or EndColor in the form
style-element-name:attribute-name. If style-reference is not defined in the
active ODS style, the COLOR= option is ignored and the default color is used.
Color must be a valid color name, such as RED, or a color code, such as
CXFF0000 or #FF0000. The color name must not exceed 64 characters. A
color code must be a valid code for a SAS color-naming scheme, such as RGB,
CMYK, HLS, or HSV (HSB). See “Color-Naming Schemes” on page 1609.
FAMILY=style-reference | "string"
specifies the font family of the text. Style-reference must specify a
FONTFAMILY attribute in the form style-element-name:FONTFAMILY.
SIZE=style-reference | dimension
specifies the font size of the text. Style-reference must specify a FONTSIZE
attribute in the form style-element-name:FONTSIZE.
Restriction The font size cannot be less than the minimum font size in SAS,
which is determined by the SAS system. If you specify a font size
that is less than the minimum font size, the minimum size is used.
Pattern
Number Pattern Name Example
1 Solid
2 ShortDash
4 MediumDash
5 LongDash
8 MediumDashShortDash
10
11
12
13
14 DashDashDot
15 DashDotDot
16
1608 Appendix 3 / Display Attributes
Pattern
Number Pattern Name Example
17
18
19
20 Dash
21
22
23
24
25
26 LongDashShortDash
27
28
29
30
31
32
33
34 Dot
35 ThinDot
36
37
38
39
Color-Naming Schemes 1609
Pattern
Number Pattern Name Example
40
41 ShortDashDot
42 MediumDashDotDot
43
44
45
46
Color-Naming Schemes
n Gray scale
Color-Naming
Scheme Example
RGB COLOR=(CX98FB98)
1610 Appendix 3 / Display Attributes
Color-Naming
Scheme Example
CMYK COLOR=(FF00FF00)
COLOR=(CMYK00FFFF00)
HLS COLOR=(H14055FF)
HSV COLOR=(V0F055FF)
You can also mix color-naming schemes in the same statement. For example:
DATACOLORS=(CXEE0044 vivid_blue darkgreen);
Each of the color-naming schemes has its advantages and disadvantages based on
how the output is used. For example, if you are creating a report that will be viewed
only online, then specifying colors using the RGB naming scheme or the SAS color
names defined in the registry might produce better results. If you are creating a
report for publishing in printed form, you might want to use the CMYK color-naming
scheme.
Note: If you specify an invalid color name, the default color is used instead.
Color names are in the form CXrrggbb, where the following is true:
n CX indicates to SAS that this is an RGB color specification.
The components are hexadecimal numbers in the range 00–FF (0% to 100%). Each
hexadecimal number indicates how much of the red, green, or blue is included in the
color. Lower percentage values are darker and higher values are lighter. This
scheme allows for up to 256 levels of each color component (more than 16 million
different colors).
Red CXFF0000
Green CX00FF00
Blue CX0000FF
White CXFFFFFF
Black CX000000
Any combination of the color components is valid. Some combinations match the
colors produced by predefined SAS color names. See “Predefined Colors” in SAS
Graph Template Language: User’s Guide.
To specify the colors from a printer's Pantone Color Lookup Table, you can use the
CMYK color-naming scheme. Specify colors in terms of their cyan, magenta, yellow,
and black components. Color names are in the form CMYKccmmyykk or
Kccmmyykk, where the following is true:
n CMYK or K is an optional prefix that indicates to SAS that this is a CMYK color
specification.
n cc is the cyan component.
The color-value components are hexadecimal numbers in the range 00–FF, where
higher values are darker and lower values are brighter. This scheme allows for up to
1612 Appendix 3 / Display Attributes
256 levels of each color component. When the color value begins with a letter (A–
F), you can omit the CMYK or K prefix. When the color value begins with a number
(0–9), you must use the CMYK or K prefix.
Red CMYK00FFFF00
Green FF00FF00
Blue CMYKFFFF0000
White K00000000
Note: You can specify a CMY value by specifying zero (00) for kk, the color's black
component.
CMYK color specifications are for output devices that support four colors. If you
specify CMYK colors on an output device that supports three colors such as RGB,
the CMYK colors are converted to colors in the three-color space. Because the
four-color space supports many more colors than a three-color space, the CMYK
colors might map to different colors in the three-color space. To preserve your
CMYK colors in that case, specify a device that supports the CMYK color space.
See “Color Support for Universal Printers” in SAS 9.4 Universal Printing.
The components are hexadecimal numbers. The hue component is in the range
000–168 hexadecimal, which represents an angular value in the range 0–360
decimal. Hue starts with the primary color blue at 0 degrees, and then progresses
Color-Naming Schemes 1613
to red at 120 degrees, to green at 240 degrees, and back to blue at 360 degrees.
Both the lightness and saturation components are in the range 00–FF hexadecimal
(0–255 decimal), which provides 256 levels that represent 0% to 100% for each
component.
Red H07880FF
Green H0F080FF
Blue H00080FF
1 When the saturation is set to 00, the color is a shade of gray that is determined by the lightness
value. Therefore, white is defined as HxxxFF00 and black as Hxxx0000, where xxx can be any hue.
The components are hexadecimal numbers. The hue component is in the range
000–168 hexadecimal, which represents an angular value in the range 0–360
decimal. Hue starts with the primary color red at 0 degrees, and then progresses to
green at 120 degrees, to blue at 240 degrees, and back to red at 360 degrees. Both
the saturation and value (brightness) components are in the range 00–FF
hexadecimal (0–255 decimal), which provides 256 levels for each component.
Red V000FFFF
1614 Appendix 3 / Display Attributes
Green V078FFFF
Blue V0F0FFFF
1 When the saturation is set to 00, the color is a shade of gray. The value component determines the
intensity of gray level. The xxx value can be any hue.
Note: GRAY, without a lightness value, is a SAS color name defined in the SAS
registry. (See “SAS Color Names and RGB Values in the SAS Registry” on page
1616.) Its value is CX808080. Invalid color specifications are mapped to GRAY.
The following figure shows the gray-scale color for each hexadecimal value.
Color-Naming Schemes 1615
White
Follow these rules when you are determining the CNS color name:
n You should not use the lightness values Black and White with saturation or hue
values.
n If you do not specify default values, medium is the default lightness value and
vivid is the default saturation value.
n Gray is the only saturation value that can be used without a hue.
n Unless the color that you want is black, white, or some form of gray, you must
specify at least one hue.
You can use one or two hue values in the CNS color name. When you use two hue
values, the hues must be adjacent to each other in the following list: blue, purple,
red, orange/brown, yellow, green, and then returning to blue. Two hue values result
in a color that is a combination of both colors. Use the suffix “ish” to reduce the
effect of a hue when two hues are combined. Reddish purple is less red than red
purple. The color specified with the “ish” suffix must precede the color without the
“ish” suffix.
Do not enclose color names in quotation marks in GTL. For example, the following
color specifications are valid:
n verylightmoderatepurplishblue
n very_light_moderate_purplish_blue
Note: If a CNS color name is also a color name in the SAS Registry, the SAS
Registry color value takes precedence. Some CNS color names and color names in
the SAS Registry have different color values. Dark blue is an example. To use a CNS
color value when the color name is also in the SAS Registry, include an underscore
to separate the words. Here is an example.
color=dark_blue
SAS prints the output in the SAS log. Here is a partial listing.
NOTE: Contents of SASHELP REGISTRY starting at subkey [COLORNAMES]
[ COLORNAMES]
Active="HTML"
[ HTML]
AliceBlue=hex: F0,F8,FF
AntiqueWhite=hex: FA,EB,D7
Aqua=hex: 00,FF,FF
Aquamarine=hex: 7F,FD,D4
Azure=hex: F0,FF,FF
Beige=hex: F5,F5,DC
...
For a list of the color names that are defined in the SAS Registry, see “Predefined
Colors” in SAS Graph Template Language: User’s Guide.
You can also create your own color values by adding them to the SAS registry. For
information about viewing and modifying the list of color names, see “The SAS
Registry” in SAS Programmer’s Guide: Essentials.
Color-Naming Schemes 1617
Figure A3.1 on page 1618 shows the HSB and RGB numeric color component values
for the currently selected color. It also shows the RGB values in hexadecimal. To
use the RGB specification for this color in a SAS program, add the CX prefix to the
Hex value E7B3B4. If the application provides only the numeric component values,
you must convert the decimal component values to hexadecimal. In Figure A3.1 on
page 1618, the H value is in the range 0–360 degrees, and the S and B values are
each in the range 0–100 percent. The R, G, and B values are in the range 0–255
each. You can convert the component values manually. (See “Understanding
Hexadecimal Values” in SAS Graph Template Language: User’s Guide.) Be aware that
you must first convert the S and B values from percentages to 255-based values by
rounding the result of the following computation to the nearest integer:
Value
100
× 255
If the SAS/GRAPH software is included in your SAS installation, you can also use
the SAS/GRAPH color utility macros to convert the values. The %HSV color utility
macro converts HSV (HSB) numeric color component values to an HSV color name.
Likewise, the %RGB macro converts RGB numeric color component values to an
RGB color name. The following example shows how to use the %HSV color utility
macro to convert the H, S, and B color component values in Figure A3.1 on page 1618
to an HSV color name.
Color-Naming Schemes 1619
%COLORMAC;
data _null_;
put "%HSV(357,22,90)";
run;
Note: The %COLORMAC macro compiles all of the SAS/GRAPH color utility
macros. You need to run it only once during a SAS session.
Because the %HSV macro accepts values in the range 0–100 as a percentage of 255
for saturation and value, use the S and B values as shown. The result is V16538E6.
The following example shows how to use the %RGB color utility macro to convert
the R, G, and B numeric color component values in Figure A3.1 on page 1618 to an
RGB color name.
/* Compute the RGB percentages */
data _null_;
r = 231;
g = 179;
b = 180;
call symputx("r", round((r/255)*100));
call symputx("g", round((g/255)*100));
call symputx("b", round((b/255)*100));
run;
Because the %RGB color utility macro accepts integer values in the range 0–100 as
a percentage of 255, you must convert the 255-based values to integer percentages
in order to use them in the %RGB macro call. The result is CXE8B3B5. The result
from the %RGB macro is not exact due to rounding. If you want more exact results,
use the following program.
data _null_;
r = 231;
g = 179;
b = 180;
rgb="CX" || put(r,hex2.) || put(g,hex2.) || put(b,hex2.);
put rgb;
run;
To convert the RGB color name to an HLS color name, use the %RGB2HLS macro as
shown in the following program.
%COLORMAC;
data _null_;
put "%RGB2HLS(CXE7B3B4)";
run;
For more information about the SAS/GRAPH color utility macros, see SAS/GRAPH:
Reference.
1621
Appendix 4
Format Support in ODS Graphics
Assigning Formats
SAS formats and user-defined formats can be assigned to input data columns with
the FORMAT statement of the SGRENDER procedure. Also, several GTL statement
options accept a format as an option value. Examples include the
TICKVALUEFORMAT= option for formatting axis tick values, and the TIPFORMAT=
option for formatting data tips. For information about SAS formats, see SAS
Formats and Informats: Reference. For information about user-defined formats, see
“FORMAT Procedure” in Base SAS Procedures Guide.
Not all SAS formats and user-defined formats are supported in GTL or with the
SGPLOT, SGSCATTER, SGPANEL, and SGRENDER procedures. See “SAS Formats
That Are Not Supported” on page 1622. When an unsupported format is
encountered, a note similar to the following is written to the SAS log:
Z ZD
The NewDate column can be used in ODS Graphics plot statements instead of the
Date column.
For information about the PICTURE statement in the FORMAT procedure, see Base
SAS Procedures Guide.
User-Defined Formats That Are Not Supported 1625
ODS Graphics does not support the use of a user-defined ODS escape character to
escape Unicode values in user-defined formats.
For an example of how to use Unicode values in user-defined formats with ODS
Graphics, see “Formatting the Tick Values on a Discrete Axis” in SAS Graph
Template Language: User’s Guide.
1626 Appendix 4 / Format Support in ODS Graphics
1627
Appendix 5
Generalized Macro for
BOXPLOTPARM Data
%local varnum;
%if %length(&varname)=0 %then %do;
%let &rc=0; %return;
%end;
%let varnum=%sysfunc(varnum(&dsid,&varname));
%if &varnum > 0 %then %do;
%let &role.label=%sysfunc(varlabel(&dsid,&varnum));
%if %length(&&&role.label)=0 %then
%let &role.label=%sysfunc(varname(&dsid,&varnum));
%let &role.fmt=%sysfunc(varfmt(&dsid,&varnum));
%let &rc=0;
%end;
%else %do;
%put ERROR: %upcase(&role) variable &varname not found.;
%let &rc=1;
%end;
%mend varinfo;
output;
end;
run;
/* interleave the obs by the X variable */
data &outdsn;
set transpose outliers; by X;
run;
/* merge the output stats for building a stat table */
%if %upcase(&table)=YES %then %do;
data &outdsn;
merge &outdsn summary; by X;
run;
%end;
%mend boxcompute;
Here is the macro invocation to produce the data for the graph shown in the section
“Example: BOXPLOTPARM Statement” on page 440 .
%boxcompute(indsn=sashelp.cars,x=type,y=mpg_city,
datalabel=make);
proc template;
define statgraph boxplotparm1;
begingraph;
entrytitle "City Mileage for Vehicle Types";
layout overlay;
boxplotparm y=value x=x stat=stat /
datalabel=datalabel spread=true ;
endlayout;
endgraph;
end;
run;
The following figure and code show an example of a “table” of statistics with
BLOCKPLOT statements.
Generalized Macro for BOXPLOTPARM Data 1631
%boxcompute(indsn=sashelp.cars,x=type,y=mpg_highway,
outdsn=boxdata2,table=yes);
proc template;
define statgraph boxplotparm2;
begingraph;
entrytitle "Highway Mileage for Vehicle Types";
layout overlay / xaxisOpts=(offsetMin=0.08 offsetMax=0.08);
innerMargin / align=top;
blockplot x=x block=n /
display=(values label outline) valuehalign=center
labelattrs=graphdatatext valueattrs=graphdatatext;
blockplot x=x block=std /
display=(values label outline) valuehalign=center
labelattrs=graphdatatext valueattrs=graphdatatext;
blockplot x=x block=mean /
display=(values label outline) valuehalign=center
labelattrs=graphdatatext valueattrs=graphdatatext;
blockplot x=x block=median /
display=(values label outline) valuehalign=center
labelattrs=graphdatatext valueattrs=graphdatatext;
endInnerMargin;
boxplotparm y=value x=x stat=stat /
datalabel=datalabel spread=true;
endlayout;
endgraph;
end;
run;
Appendix 6
Memory Management for ODS
Graphics
Normally, the memory limit for Java is sufficient for most ODS Graphics
applications. However, some tasks are very memory intensive and might exhaust all
available Java memory, resulting in an OutOfMemoryError condition. You might
encounter Java memory limitations in the following cases:
n the product of the output size and the DPI setting results in very large output
n creating 3-D plots and 2-D contours, which are memory intensive to generate
n a plot uses many character variables or has a large number of GROUP values
To determine what the current Java memory settings are, you can submit a PROC
OPTIONS statement that shows the value of the JREOPTIONS option:
After you submit this procedure code, a list of JREOPTIONS settings is written to
the SAS log. The JREOPTIONS option has many suboptions that configure the SAS
Java environment. Many of the suboptions are installation and host specific and
should not be modified, especially the ones that provide installed file locations. For
managing memory, look for the -Xmx and -Xms suboptions:
-Xms
Use this option to set the minimum Java memory (heap) size, in bytes. Set this
value to a multiple of 1024 greater than 1MB. Append the letter k or K to
indicate kilobytes, or m or M to indicate megabytes. The default is 2MB.
Examples:
-Xms6291456
-Xms6144k
-Xms6m
-Xmx
Use this option to set the maximum size, in bytes, of the memory allocation
pool. Set this value to a multiple of 1024 greater than 2MB. Append the letter k
or K to indicate kilobytes, or m or M to indicate megabytes. The default is 64MB.
Examples:
-Xmx83886080
-Xmx81920k
-Xmx80m
As a general rule, you should set the minimum heap size (-Xms) equal to the
maximum heap size (-Xmx) to minimize garbage collections.
Typically, SAS sets both -Xms and -Xmx to be about 1/4 of the total available
memory or a maximum of 128M. However, you can set a more aggressive maximum
memory (heap) size, but it should never be more than 1/2 of physical memory.
Managing a Java Out of Memory Error 1635
You should be aware of the maximum amount of physical memory your computer
has available. Let us assume that doubling the Java memory allocation is feasible.
So when you start SAS from a system prompt, you can add the following option:
The exact syntax varies for specifying Java options, depending on your operating
system, and the amount of memory that you can allocate varies from system to
system. The set of JRE options must be enclosed in parentheses. If you specify
multiple JREOPTIONS system options, then SAS appends JRE options to JRE
options that are currently defined. Incorrect JRE options are ignored.
If you choose to create a custom configuration file, then you would simply replace
the existing -Xms and -Xmx suboption values in the JREOPTIONS=(all Java
options) portion of the configuration file.
For more information, see the SAS Companion for your operating system.
1636 Appendix 6 / Memory Management for ODS Graphics