Example Program and Statement Details

Example Graph

The following graph was generated by the Example Program:
Example Bar Chart

Example Program

data transactions;
input ID $ Amount type $;
datalines;
Alpha 2000 credit
Beta -2500 debit
Gamma -2000 debit
Delta -500 debit
Epsilon 2250 credit
;
proc template;
  define statgraph waterfallchart;
    begingraph;
      layout overlay;
        waterfallchart category=id response=amount /
          colorgroup=type
          initialbarvalue=1000
          name="waterfall";
        discretelegend "waterfall";
      endlayout;
    endgraph;
  end;
run;

proc sgrender data=transactions template=waterfallchart;
run;

Statement Summary

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 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, 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.

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.

Options

Statement Option
Description
Specifies whether the bar statistic value is displayed at the end of the bar.
Specifies the text properties of the bar label text.
Specifies the text format used to display the bar label.
Specifies the width of the bars as a ratio of the maximum possible width.
Specifies the response-axis intercept for the baseline.
Specifies a column that is used to discretely color the transaction bars.
Specifies a style element to use to determine the colors of the transaction bars.
Specifies the values to use to map the transaction-bar colors to a continuous color gradient.
Determines whether trend lines connect to the adjacent bar’s starting or ending value.
Specifies the appearance of the trend lines that connect the bars.
Specifies the appearance of trend lines that denote a decreasing value between bars.
Specifies the appearance of trend lines that denote an increasing value between bars.
Enhances the visual appearance of the filled bars.
Specifies the degree of the transparency of the bar fill, bar outline, and trend lines, if displayed.
Specifies which bar features are displayed.
Specifies the appearance of the filled bar area.
Determines whether a solid or gradient fill is used in the bars.
Specifies the appearance of the “final” bar, if displayed.
Specifies a tick value to use on the category axis when the “final” bar is displayed
Specifies the appearance of the “initial” bar, if displayed.
Specifies a tick value to use on the category axis when the “initial” bar is displayed.
specifies a value for the “initial” bar.
Specifies the label for a legends.
Assigns a name to a plot statement for reference in other template statements.
Specifies the properties of the bar outlines.
Specifies user-defined roles that can be used to display information in the tooltips.
Specifies the statistic to be computed for the RESPONSE axis.
Specifies the information to display when the cursor is positioned over a bar.
Specifies display formats for the information defined by the tooltip roles.
Specifies display labels for the information defined by the tooltip roles.
Specifies an HTML page to display when a bar 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.
BARLABEL=boolean
specifies whether the bar statistic value is displayed at the end of the bar.
Default: FALSE
TIP: The font and color attributes for the label are specified by the BARLABELATTRS= option. The text format is specified by the BARLABELFORMAT= option.
BARLABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the text properties of the bar label text. See General Syntax for Attribute Options for the syntax on using a style-element and Text Options for available text-options.
Default: The GraphDataText style element.
Interaction: For this option to take effect, BARLABEL=TRUE must be specified.
BARLABELFORMAT=format
specifies the text format used to display the bar label.
Default: The column format assigned to the RESPONSE= variable or BEST6. if no format is assigned.
Interaction: For this option to take effect, BARLABEL=TRUE must be specified.
BARWIDTH=number
specifies the width of the bars as a ratio of the maximum possible width.
Default: .85. By default, the bar width automatically adjusts based on the number of bars to be displayed and the wall width.
Range: 0.1 (narrowest) to 1 (widest)
This option is needed only to change the default behavior. For example, to remove any inter-bar gap, set BARWIDTH=1.
BASELINEINTERCEPT=number
specifies the response-axis intercept for the baseline.
Default: 0
Interaction: The value set by this option is included in the calculation of the axis range.
Interaction: This setting 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.
Tip: The baseline is always displayed in the chart, whether for a specified value or the default value. Visual attributes for the line are derived from the GraphAxisLines style-element.
Tip: Label positions are automatically adjusted to prevent the labels from overlapping.
Comparison between default baseline value and BASLINEINTERCEPT=2000
COLORGROUP=column | discrete-attr-var | expression
specifies a column that is used to discretely color the transaction bars.
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: no default. 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.
Interaction: This option is ignored if the COLORRESPONSE= option is also specified.
Interaction: If a column or expression is specified, the unique column values are found and the transaction bar colors are derived from the GraphData1 - GraphDataN style elements. The COLOR attribute is used for the bar fill colors and the CONTRASTCOLOR attribute is used for the bar outline colors.
Interaction: If a variable that is associated with an attribute map is specified, then the color mapping defined by the associated DISCRETEATTRMAP statement is used for the transaction bars.
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=style-element
specifies a style element to use to determine the colors of the transaction bars.
Default: The ThreeColorRamp style element.
style-element
name of a style element. The style element should contain these style attributes:
STARTCOLOR color for the smallest data value of the column that is specified on the COLORRESPONSE= option
NEUTRALCOLOR color for the midpoint of the range of the column that is specified on the COLORRESPONSE= option
ENDCOLOR color for the highest data value of the column that is specified on the COLORRESPONSE= option
Interaction: 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.
COLORRESPONSE=numeric-column | range-attr-var | expression
specifies the values to use to map the transaction-bar colors to a continuous color gradient.
range-attr-var
specifies a range attribute variable that is defined in a RANGEATTRVAR statement.
Restriction: A range attribute variable specification must be a direct reference to the attribute variable. It cannot be set by a dynamic variable.
Default: no default.
Interaction: This option overrides the COLORGROUP= option, if it is also specified.
Interaction: The color ramp that is used is determined as follows:
  • If a numeric-column or an expression is specified, then the value of the COLORMODEL= option determines the color ramp.
  • If a range-attr-var that is associated with an attribute map is specified, then the color mapping defined by the associated RANGEATTRMAP statement determines the color ramp.
Tip: To produce “discrete” color mapping, the RANGEATTRMAP statement can define an attribute map that maps a single color to all values greater than 0, and another color to all values less than 0.
Tip: The FILLTYPE= option can be used to indicate whether the color mapping is used to produce solid or gradient fills.
CONNECT=START | END
determines whether trend lines connect to the adjacent bar’s starting or ending value.
Default: START
START
trend lines are horizontal and connect 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
trend lines are diagonal and connect 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.
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.
CONNECTATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of the trend lines that connect the bars. See General Syntax for Attribute Options for the syntax on using a style-element and Line Options for available line-options.
Default: The GraphConnectLine style element.
CONNECTDECREASINGATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of trend lines that denote a decreasing value between bars. See General Syntax for Attribute Options for the syntax on using a style-element and Line Options for available line-options.
Default: The appearance specified by the CONNECTATTRS= option.
CONNECTINCREASINGATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of trend lines that denote an increasing value between bars. See General Syntax for Attribute Options for the syntax on using a style-element and Line Options for available line-options.
Default: The appearance specified by the CONNECTATTRS= option.
DATASKIN=NONE | PRESSED | SHEEN | CRISP | GLOSS | MATTE
enhances the visual appearance of the filled bars.
Waterfall Charts with Data Skins
Default: NONE
Requirement: For this option to have any effect, the fill must be enabled by the ODS style or the DISPLAY= option.
Interaction: The skin appearance is based on the FILLATTRS= color.
Interaction: 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, and trend lines, if displayed.
Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
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)
DISPLAY=STANDARD | ALL | (display-options)
specifies which bar features to display.
Default: STANDARD
STANDARD
displays outlined, filled bars; connect lines; and the “final” bar.
ALL
same as STANDARD
(display-options)
a list of options, enclosed in parentheses, that must include one or more of the following:
FILL—displays filled bars
FINALBAR—displays the “final” bar
OUTLINE—displays outlined bars
CONNECT—Displays line segments (trend lines) connecting adjacent bar. The connection point is determined by the CONNECT= option.
Tip: To control the appearance of the bars, use the COLORMODEL=, FILLATTRS=, and OUTLINEATTRS= options.
Tip: To control the appearance of the trend lines, use the CONNECTATTRS=, CONNECTDECREASINGATTRS=, and CONNECTINCREASINGATTRS= options.
FILLATTRS=style-element | style-element (fill-options) | (fill-options)
specifies the appearance of the filled transaction bars. See General Syntax for Attribute Options for the syntax on using a style-element and Fill Options for available fill-options.
Default:
  • If the COLORGROUP= option is not specified, the GraphDataDefault:Color style reference.
  • If the COLORGROUP= option is specified, the GraphData1:Color - GraphDataN:Color style references.
Interaction: This option is ignored if either the COLORMODEL= or COLORRESPONSE= option is specified.
Tip: The DATATRANSPARENCY= option sets the transparency for the bar fill, bar outline, and trend lines. You can combine this option with DATATRANSPARENCY= 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)
FILLTYPE=SOLID | GRADIENT
determines whether a solid or gradient fill is used in the bars.
Default: SOLID
Tip: The colors that are used depend on whether the COLORGROUP= option or the COLORRESPONSE= option is also specified.
FINALBARATTRS=style-element | style-element (fill-options) | (fill-options)
specifies the appearance of the “final” bar, if displayed. See General Syntax for Attribute Options for the syntax on using a style-element and Fill Options for available fill-options.
Default: the GraphFinal style element
Interaction: This option is ignored if the DISPLAY= option does not display the “final” bar.
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.
INITIALBARATTRS=style-element | style-element (fill-options) | (fill-options)
specifies the appearance of the “initial” bar, if displayed. See General Syntax for Attribute Options for the syntax on using a style-element and Fill Options for available fill-options.
Default: the GraphInitial style element
Interaction: For this option to take effect, the INITIALBARVALUE= option must also be specified.
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.
Default: no default. The first transaction bar starts at response value 0.
Interaction: If this option is not specified, 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.
Comparison between default baseline value and BASLINEINTERCEPT=2000
LEGENDLABEL= "string"
specifies a label for the legend item that is associated with this plot.
Default: The string specified on the NAME= option.
Restriction: This option applies only to an associated DISCRETELEGEND statement.
Interaction: If the COLORGROUP= option is specified, this option is ignored.
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 and line patterns between the graph and the legend.
OUTLINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of the bar outlines. See General Syntax for Attribute Options for the syntax on using a style-element and Line Options for available line-options.
Default: The ContrastColor and LineThickness attributes of the GraphOutlines style element.
Interaction: For this option to have any effect, outlines must be enabled by the ODS style or the DISPLAY= option.
Interaction: If the DATASKIN= option applies a data skin, this option is ignored.
ROLENAME=(role-name-list)
specifies user-defined roles that can be used to display information in the tooltips. Columns for the tooltip display are specified in the TIP= option.
Default: no user-defined roles
(rolename-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 CATEGORY, RESPONSE, COLORGROUP, and COLORRESPONSE.
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.
STAT= SUM | MEAN
specifies the statistic to be computed for the RESPONSE axis.
Default:SUM
TIP=(role-list)
specifies the information to display when the cursor is positioned over a bar. If this option is used, it replaces all the information displayed by default. Roles for columns that do not contribute to the waterfall chart can be specified along with roles that do.
Default: The columns assigned to these roles are automatically included in the tooltip information: CATEGORY and RESPONSE.
(role-list)
an ordered, blank-separated list of unique WATERFALLCHART and user-defined roles. WATERFALLCHART roles include CATEGORY, RESPONSE, COLORGROUP, and COLORRESPONSE.
The following example displays tooltips only for the column that is assigned to the RESPONSE role:
  TIP= (RESPONSE)
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 the information that is defined by the tooltip roles.
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 role-name = format pairs separated by blanks.
  TIP=(RESPONSE)
  TIPFORMAT=(RESPONSE=DOLLAR12.)
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.
TIPLABEL=(role-label-list)
specifies display labels for the information that is defined by the tooltip roles.
Default: The column label or column name of the variable assigned to the role.
(role-label-list)
a list of role-name = "string" pairs separated by blanks.
   TIP=(RESPONSE)
   TIPLABEL=(RESPONSE="Average Amount")
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.
URL=character-column
specifies an HTML page to display when a bar is selected.
Default: no default
character-column
each value of the column should be a valid HTML page reference (HREF). 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.
For non-grouped data, the values of the column are expected to be same for each unique RESPONSE value. If they are not, the results might be unpredictable. 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.
For grouped data, the values of the column are expected to be the same for each unique RESPONSE and group combination.
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.
YAXIS=Y | Y2
specifies whether data are mapped to the primary Y (left) axis or to the secondary Y2 (right) axis.
Default: Y
Interaction: This option is ignored if the RESPONSE= argument is not specified.
Interaction: The overall plot specification and the layout type determine the axis display. For more information, see How Axis Features Are Determined.