Example Program and Statement Details

Example Graph

The following graph was generated by the Example Program:
Example Series Plot

Example Program

proc template;
 define statgraph seriesplot;
  begingraph; 
   entrytitle "Tech Stock Trends"; 
   layout overlay; 	 
     seriesplot x=date y=close / group=stock name="stocks";
     discretelegend "stocks";
   endlayout;	
  endgraph;
 end;
run;

proc sgrender data=sashelp.stocks template=seriesplot;
  where date > "31dec1999"d;
run;

Statement Summary

The SERIESPLOT statement is typically used to show time-dependent data.

Required Arguments

X=column | expression
specifies the column for the X values.
Y=column | expression
specifies the column for the Y values.

Options

Statement Option
Description
Breaks the plot line at the occurrences of the missing values of the X or Y variable.
Specifies how to connect the data points to form the series line.
Specifies a label for the series line.
Specifies the color and font attributes of the series line label.
Specifies the location of the series line label relative to the plot area.
Specifies the position of the series label relative to the series line.
Specifies a column that supplies values for the data point labels.
Specifies the color and font attributes of the data labels.
Specifies the degree of the transparency of the line and markers, when displayed.
Specifies an amount to offset all series lines and markers from discrete X values, or discrete Y values, or both.
Specifies additional feature to display with the series line.
Creates a separate series plot for each unique group value of the specified column.
Specifies indices for mapping series-line attributes (color, marker symbol, and line pattern) to one of the GraphData1 - GranphDataN style elements.
Specifies a label to be used in a legend.
Specifies the line attributes of the series line.
Specifies the attributes of the data markers.
Assigns a name to a plot statement for reference in other template statements.
Specifies that the data columns for this plot be used for determining default axis features.
Specifies roles for information defined by data columns.
Specifies the information to display when the cursor is positioned over the series line.
Specifies display formats for information defined by roles.
Specifies display labels for information defined by roles.
Specifies an HTML page to display when a series line segment is selected.
Specifies whether data are mapped to the primary X (bottom) axis or the secondary X2 (top) axis.
Specifies whether data are mapped to the primary Y (left) axis or the secondary Y2 (right) axis.
BREAK=boolean
breaks the plot line at missing values of the X or Y variable.
Default: FALSE
When this option is set to FALSE, missing values are skipped and a continuous line is drawn.
CONNECTORDER=XVALUES | XAXIS
specifies how to connect the data points to form the series line.
Default: XVALUES
XVALUES
Connects data points in the order read from the X variable.
XAXIS
Connects data points as they occur min-to-max along the X axis.
For certain types of series lines (for example, time series) when the input data might not be sorted by the X variable, set this option to XAXIS to assure the expected connect order.
CURVELABEL="string" | column | expression
specifies a label for the series line.
Default: no default
Interaction:
  • For non-grouped data, use "string".
  • For grouped data, use a column to define the labels for each group value.
The font and color attributes for the label are specified by the CURVELABELATTRS= option.
CURVELABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the series line labels. See General Syntax for Attribute Options for the syntax on using a style-element and Text Options for available text-options.
Default:
  • For non-grouped data, the GraphValueText style element.
  • For grouped data, text color is derived from the GraphData1:ContrastColor - GraphDataN:ContrastColor style references. The font is derived from the GraphValueText style element.
Interaction: For this option to take effect, the CURVELABEL=curvelabel option must also be used.
Interaction: This option’s COLOR= setting overrides the colors indicated by the GROUP= option.
When the GROUP= option is used, each distinct group value might be represented by a different color. The series label that is associated with the group is assigned the group color. This option can be used to specify a single color for all series labels in a graph, without affecting items that have the group color, such as lines and marker symbols.
CURVELABELLOCATION=INSIDE | OUTSIDE
specifies the location of the series line label relative to the plot area.
Default: INSIDE
INSIDE
inside the plot area
OUTSIDE
outside the plot area
Restriction: OUTSIDE cannot be used when the SERIESPLOT is used in multicell layouts such as LATTICE, DATAPANEL, or DATALATTICE, where axes might be external to the grid.
Interaction: For this option to take effect, the CURVELABEL= option must also be specified.
Interaction: This option is used in conjunction with the CURVELABELPOSITION= option to determine where the curve labels appear. For more information, see Location and Position of Curve Labels.
CURVELABELPOSITION=AUTO | MAX | MIN | START | END
specifies the position of the series label relative to the series line.
Default: AUTO when CURVELABELLOCATION=OUTSIDE END when CURVELABELLOCATION=INSIDE
AUTO
Only used when CURVELABELLOCATION=OUTSIDE. The series label is positioned automatically near the end series line along unused axes whenever possible (typically Y2 or X2) to avoid collision with tick values.
MAX
Forces the series label to appear near maximum series values (typically, to the right)
MIN
Forces the series label to appear near minimum series values (typically, to the left)
START
Only used when CURVELABELLOCATION=INSIDE. Forces the series label to appear near the beginning of the curve. Particularly useful when the curve line has a spiral shape.
END
Only used when CURVELABELLOCATION=INSIDE. Forces the series label to appear near the end of the curve. Particularly useful when the curve line has a spiral shape.
Restriction: The AUTO setting is not supported if CURVELABELLOCATION=INSIDE is specified. The START and END settings are not supported if CURVELABELLOCATION=OUTSIDE is specified.
Interaction: For this option to take effect, the CURVELABEL= option must also be specified.
Interaction: This option is used in conjunction with the CURVELABELLOCATION= option to determine where the series label appears. For more information, see Location and Position of Curve Labels.
DATALABEL=column | expression
specifies a column that supplies values for the data point labels.
Default: no default
The label positions are adjusted to prevent the labels from overlapping.
DATALABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the data labels. See General Syntax for Attribute Options for the syntax on using a style-element and Text Options for available text-options.
Default:
  • For non-grouped data, the GraphDataText style element.
  • For grouped data, the GraphData1:ContrastColor - GraphDataN:ContrastColor style references.
Interaction: For this option to take effect, the DATALABEL= option must also be specified.
Interaction: This option’s COLOR= setting overrides the colors indicated by the GROUP= option.
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 graph, without affecting items that have the group color, such as error bars and marker symbols.
DATATRANSPARENCY=number
specifies the degree of the transparency of the line and markers, when displayed.
Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
DISCRETEOFFSET=number
specifies an amount to offset all series lines and markers from X values for a discrete X axis, or from Y values for a discrete Y axis. If both axes are discrete, the offset applies to both axes.
Note: This feature is for the third maintenance release of SAS 9.2 and later.
Default: 0 (no offset, all series lines and markers are centered on the X values for a discrete X axis, or on the Y values for a discrete Y axis)
Range: -0.5 to +0.5, where .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.
DISPLAY=STANDARD | ALL | display-options
specifies additional feature to display with the series line.
Default: STANDARD
STANDARD
displays a series line without markers.
ALL
displays a series line with markers.
(display-options)
a list of options enclosed in parentheses. Currently, only the following option is available for the list:
MARKERS—displays a series line with markers
Use the MARKERATTRS= and LINEATTRS= options to control the appearance of the line and markers.
GROUP=column | expression
creates a separate series plot for each unique group value of the specified column.
Default: Each distinct group value might be represented in the graph by a different combination of color, line pattern, and marker symbol. Lines and markers vary according to the ContrastColor, LineStyle, and MarkerSymbol attributes of the GraphData1 - GraphDataN style elements. Line thickness (for grouped and ungrouped data) is controlled by the LINEATTRS= option.
Interaction: 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.
Interaction: The marker size is set by the MARKERATTRS= option.
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.
INDEX=positive-integer-column | expression
specifies indices for mapping series-line attributes (color, marker symbol, and line pattern) to one of the GraphData1 - GranphDataN style elements.
Default: no default
Interaction: For this option to take effect, the GROUP= option must also be specified.
Interaction: All of the indexes for a specific group value must be the same. Otherwise, the results are unpredictable.
Interaction: If this option is not used, then the group values are mapped in the order of the data.
Interaction: The index values are 1-based indices. For the style elements 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.
Discussion: Indexing can be used to collapse the number of groups that are represented in a graph. For more information, see Remapping Groups for Grouped Data.
LEGENDLABEL= "string"
specifies a label to be used in a legend.
Default: The Y-variable label. If a label is not defined, the Y-variable name.
Interaction: If the GROUP= option is specified, this option is ignored.
LINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the attributes of the series line. See General Syntax for Attribute Options for the syntax on using a style-element and Line Options for available line-options.
Default:
  • For non-grouped data, the GraphDataDefault style element.
  • For grouped data, the ContrastColor and LineStyle attributes of the GraphData1 - GraphDataN style elements, and the GraphDataDefault:LineThickness style reference.
MARKERATTRS=style-element | style-element (marker-options) | (marker-options)
specifies the attributes of the data markers. See General Syntax for Attribute Options for the syntax on using a style-element and Marker Options for available marker-options.
Default:
  • For non-grouped data, GraphDataDefault style element.
  • For grouped data, the MarkerSymbol and ContrastColor attributes of the GraphData1 - GraphDataN style elements, and the GraphDataDefault:MarkerSize style reference.
Interaction: DISPLAY=ALL or DISPLAY=(MARKERS) must be set for this option to have any effect.
Interaction: This option’s COLOR= suboption overrides the default behavior for grouped data: all markers the same color and the marker symbol alone distinguishes the markers.
Interaction: This option’s SYMBOL= suboption overrides the default behavior for grouped data: it holds the marker constant across group values and marker color alone distinguishes the markers.
NAME="string"
assigns a name to a plot statement for reference in other template statements.
Default: no default
Restriction: The string is case sensitive, cannot contain spaces, and must define a unique name within the template.
The specified name is used primarily in legend statements to coordinate the use of colors, marker symbols, and line patterns between the graph and the legend.
PRIMARY=boolean
specifies that the data columns for this plot and the plot type be used for determining default axis features.
Default: FALSE
Restriction: This option is ignored if the plot is placed under a GRIDDED or LATTICE layout block.
Details: This option is needed only when two or more plots within an overlay-type layout contribute to a common axis. For more information, see When Plots Share Data and a Common Axis
ROLENAME=( role-name-list )
specifies user-defined roles for information contained in data columns.
Default: no default
(role-name-list)
a blank-separated list of rolename = column pairs.
For example, ROLENAME= ( TIP1=OBS ) assigns the column OBS to the user-defined role TIP1.
Requirement: The role names that you choose must be unique and different from the pre-defined roles X, Y, CURVELABEL, DATALABEL, GROUP, and INDEX.
Interaction: For this option to take effect, the TIP= option must also be used.
This option provides a way to add to the data columns that appear in tooltips specified by the TIP= option.
TIP=(role-list)
specifies the information to display when the cursor is positioned over the series line. If this option is used, it replaces all the information displayed by default. Roles for columns that do not contribute to the series plot can be specified along with roles that do.
Default: The columns assigned to these roles are automatically included in the tooltip information: X, Y, DATALABEL, and GROUP.
(role-list)
an ordered, blank-separated list of unique SERIESPLOT and user-defined roles. SERIESPLOT roles include X, Y, CURVELABEL, DATALABEL, and GROUP.
Note: CURVELABEL is considered a role only when it is assigned a column of values. It is not considered a role and does not display tooltips when assigned a string.
User-defined roles are defined with the ROLENAME= option.
The following example displays tooltips 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)
Requirement: To generate tooltips, you must include an ODS GRAPHICS ON statement that has the IMAGEMAP option specified, and write the graphs to the ODS HTML destination.
Interaction: 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.
Default: The column format of the variable assigned to the role or BEST6. if no format is assigned to a numeric column.
(role-format-list)
a list of rolename = format pairs separated by blanks.
  ROLENAME=(TIP1=OBS)
  TIP=(TIP1 X Y)
  TIPFORMAT=(TIP1=4.) 
Requirement: This option provides a way to control the formats of columns that appear in tooltips. Only the roles that appear in the TIP= option are used. Columns must be assigned to the roles for this option to have any effect. See the ROLENAME= option.
TIPLABEL=(role-label-list)
specifies display labels for tip columns.
Default: The column label or column name of the variable assigned to the role.
(role-label-list)
a list of rolename = "string" pairs separated by blanks.
   ROLENAME=(TIP1=OBS) 
   TIP=(TIP1 X Y)
   TIPLABEL=(TIP1="Observation #")
Requirement: This option provides a way to control the labels of columns that appear in tooltips. Only the roles that appear in the TIP= option are used. Columns must be assigned to the roles for this option to have any effect. See the ROLENAME= option.
URL=character-column
specifies an HTML page to display when a point or a segment of the curve is selected.
Default: no default
character-column
each value of the column must be a valid HTML page reference (HREF). For example, http://www.sas.com/technologies/analytics/index.html.
Requirement: To generate selectable bars, you must include an ODS GRAPHICS ON statement that has the IMAGEMAP option specified, and write the graphs to the ODS HTML destination.
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 the specified axis. For more information, see How Axis Features are Determined.
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 the specified axis. For more information, see How Axis Features are Determined.