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;

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 the width of the group clusters as a fraction of the midpoint spacing.
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 location of the data labels relative to the vertices of the series and the markers, when displayed.
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 how marker groups are positioned for the coordinate pairs.
Specifies the relative position of the series lines and markers for a clustered group display.
Specifies whether missing values of the group variable are included in the plot.
Specifies indices for mapping series-line attributes (color, marker symbol, and line pattern) to one of the GraphData1–GraphDataN style elements.
Specifies a label for 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 user-defined roles that can be used to display information in the tooltips.
Specifies that a smoothed line passes through all vertices.
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.
CLUSTERWIDTH= number
specifies the width of the group clusters as a fraction of the midpoint spacing on a discrete axis or a fraction of the minimum interval between adjacent data values on an interval axis.
Default: 0.85
Range: 0.1 (narrowest) to 1 (widest)
Interaction: For this option to take effect, the GROUP= option must also be specified, and GROUPDISPLAY=CLUSTER must be set..
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 curve label is displayed
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= 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 ignored if CURVELABELLOCATION=INSIDE is specified. The START and END settings are ignored 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 data labels are displayed
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.
DATALABELPOSITION = AUTO | TOPRIGHT | TOP | TOPLEFT | LEFT | CENTER | RIGHT | BOTTOMLEFT | BOTTOM | BOTTOMRIGHT
specifies the location of the data labels relative to the vertices of the series and the markers, when displayed.
Default: AUTO
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 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)
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 | discrete-attr-var | expression
creates a separate series plot for each unique group value of the specified column.
discrete-attr-var
specifies a discrete attribute variable that is defined in a DISCRETEATTRVAR statement.
Restriction: A discrete attribute variable specification must be a direct reference to the attribute variable. It cannot be set by a dynamic variable.
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.
Interaction: The INCLUDEMISSINGGROUP= option controls whether missing group values are considered a distinct group value.
Tip: 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 how marker groups are positioned for the coordinate pairs.
Default: OVERLAY
OVERLAY
draws markers for a given group value at the exact coordinate. Depending on the data, markers at a given coordinate might overlap.
CLUSTER
draws markers for a given group value adjacent to each other.
Interaction: For this option to take effect, the GROUP= option must also be specified.
Tip: Use the CLUSTERWIDTH= option to control the width of the clusters when CLUSTER is in effect.
GROUPORDER=DATA | ASCENDING | DESCENDING
specifies the relative position of the series lines and markers for clustered group display. It also sets the default order of the groups in the legend.
Default: DATA
DATA
shows each group within a category in data order of the group column.
ASCENDING
shows each group within a category in ascending order of the group column. See the Details for more information.
DESCENDING
shows each group within a category in descending order of the group column. See the Details for more information.
Interaction: For this option to take effect, the GROUP= must also be specified.
Interaction: The SORTORDER= setting in a DISCRETELEGEND statement overrides the legend item order.
Note: Attributes such as color, symbol, and pattern are assigned to each group in the DATA order by default regardless of the GROUPORDER= option setting.
Note: The ASCENDING and DESCENDING settings linguistically sort the group values within each category (or X value) for display position purposes only. The data order of the observations and the visual attributes that are assigned to the group values remain unchanged.
Tip: The CLUSTERWIDTH option can be used to control the distance between the group markers in a cluster.
Tip: The INDEX= option can be used to alter the default sequence of visual attributes that is assigned to the group values.
Details: By default, the value that is set for this option determines the order in which attributes are assigned to each group. It also determines the order in which the groups are displayed in the legend.
For ASCENDING and DESCENDING sort orders, the order is based on the data type:
  • For Numeric data, the order is based on unformatted values.
  • For Character data the order is based on formatted values.
The ASCENDING and DESCENDING settings perform a linguistic sort on the group items and have the same effect as sorting the input data. However, the data is not changed.
INCLUDEMISSINGGROUP=boolean
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: Unless a discrete attribute map is in effect or the INDEX= option is used, the attributes of the missing group value are determined by the GraphMissing style element except when the MISSING= system option is used to specify a non-default missing character or when a user-defined format is applied to the missing group value. In those cases, the attributes of the missing group value are determined by a GraphData1–GraphDataN style element.
INDEX=numeric-column | expression
specifies indices for mapping series-line attributes (color, marker symbol, and line pattern) to one of the GraphData1–GraphDataN style elements.
Default: no default
Restriction: If the value of the numeric-column is missing or is less than 1, the observation is not used in the analysis. If the value is not an integer, only the integer portion is used.
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 for the legend item that is associated with this plot.
Default: The Y-variable label. If a label is not defined, the Y-variable name.
Restriction: This option applies only to an associated DISCRETELEGEND statement.
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 that can be used to display information in the tooltips.
Default: no user-defined roles
(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.
SMOOTHCONNECT=boolean
specifies that a smoothed line passes through all vertices.
Default: FALSE
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 is a valid reference.
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.