Example Program and Statement 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.

BlockPlot Overlaid with SeriesPlot

BlockPlot Overlaid with SeriesPlot
When overlaid with plots that have a Y axis—a series plot for example—a block plot expands vertically to fill the Y axis range. In the BLOCKPLOT statement, the BLOCK= argument can be used to reference text values from a column. The resulting graph displays those values within the plot wall.
The following example shows how a block plot can be specified with a series plot within an Overlay layout. To prepare data for the graph, “event” information is added to existing data for stock prices. 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
run;

proc sort data=sashelp.stocks(keep=date stock close)
  out=MSstock;
  where stock="Microsoft"; 
  by date;
run;

data events(drop=temp); 
  retain temp; 
  merge MSstock MSevents(in=r);
  by date; 
  if first.date and r then temp=release;
  release=temp; 
run;
In the combined input data set, notice that the RELEASE value is repeated for each observation within the duration of a defined “event”:
Obs    Date      Close   Release
... 
45    02APR90   $58.00
46    01MAY90   $73.00
47    01JUN90   $76.00     3.0
48    02JUL90   $66.50     3.0
49    01AUG90   $61.50     3.0
50    04SEP90   $63.00     3.0
...
In the following GTL template code, BLOCK=RELEASE is specified in the BLOCKPLOT statement so that the RELEASE values are displayed on the wall of the resulting block plot.
proc template;
  define statgraph blockplot1;
    begingraph;
      entrytitle "Microsoft Share Prices";
      entrytitle "and Significant OS Releases";
       layout overlay; 
         blockplot x=date block=release /
           datatransparency=.3 valuevalign=top
           labelposition=top display=(fill values label);
        seriesplot x=date y=close;
      endlayout;
    endgraph;
  end;
run;

proc sgrender data=events template=blockplot1;
run;

Stand-alone BlockPlot in Lattice Layout

When used as a stand-alone plot in a lattice layout, the block plot’s height can be controlled. Here the lattice ROWWEIGHTS=(.04 .96) option apportions 4% of the vertical space to the block plot. Using this technique, it is possible to include two or more “event” strips in a plot.
Stand-alone BlockPlot in Lattice Layout
proc template;
  define statgraph blockplot2;
    begingraph;
      entrytitle "Microsoft Share Prices"; 
      entrytitle "and Significant OS Releases"; 
      layout lattice / rowweights=(.04 .96); 
        blockplot x=date block=release / datatransparency=.3
          valuefitpolicy=shrink  labelposition=left 
          display=(fill label outline values);
        seriesplot x=date y=close;
      endlayout;
    endgraph;
  end;
run; 

proc sgrender data=events template=blockplot2;
run;

Arguments

X=column | expression
specifies numeric X axis positions. When the X-axis is numeric and the specified column is numeric, values are expected to be in sorted, ascending order. If the X-axis is discrete and the specified column is numeric, values are treated as numeric-discrete.
BLOCK=column | expression
specifies a value for each X position. Numeric values are converted to text strings according to an assigned format or BEST6.

Options

Statement Option
Description
Specifies the appearance of alternate block fills.
Specifies indices for remapping the assignment of color to block values.
Creates a separate block plot for each unique value of the specified column or expression.
Specifies the degree of the transparency of the block fill and outline.
Specifies whether to display an outlined, a filled, or an outlined and filled block area.
Specifies the appearance of the block fills.
Specifies how the blocks are filled.
Specifies an external label for a single block plot.
Specifies the appearance of the external BLOCK label(s).
Specifies the alignment of BLOCK label.
Assigns a name to a plot statement for reference in other template statements.
Specifies the properties of the block outlines.
Specifies whether contiguous block values that are identical create separate blocks.
Specifies the appearance of the text values.
Specifies how text values are adjusted to fit within the containing block.
Specifies the horizontal alignment of text with blocks.
Specifies the vertical alignment of text with blocks.
Specifies whether data are mapped to the primary X (bottom) axis or the secondary X2 (top) axis.
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. See General Syntax for Attribute Options for the syntax on using a style-element and Fill Options for available fill-options.
Default: The GraphWalls style element.
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.
Interaction: The FILLATTRS= option controls the fill color.
To make all block fill areas the same color, set the FILLATTRS= and ALTFILLATTRS= options to the same value.
BLOCKINDEX=positive-integer-column | expression
specifies indices for remapping the assignment of the color of the block fills.
Default: no default
Requirement: FILLTYPE=MULTICOLOR must set for this option to have any effect.
Interaction: All of the indexes for a specific block value must be the same. Otherwise, the results are unpredictable.
Interaction: The index values are 1-based indices. For the style definitions 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.
Interaction: If this option is not used, then the color values are mapped in the order of GraphData1 - GraphDataN.
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.
Default: no default
Interaction: The DISPLAY= option must include LABEL for any external labels to appear.
Interaction: This option overrides the LABEL= option.
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. It does not affect block values or label.
Default: 0
Range: 0 (opaque) to 1 (entirely transparent)
DISPLAY=STANDARD | ALL | ( display-options )
specifies whether to display an outlined, a filled, or an outlined and filled block area. Values and a label can also be added or suppressed.
Default: STANDARD
STANDARD
1) displays an outlined, filled block without text values or a label when used inside an overlay-type layout (OUTLINE FILL).
2) displays an outlined, filled block with text values and a label when used as a stand-alone plot inside a LATTICE or GRIDDED layout (OUTLINE FILL VALUES LABEL).
ALL
displays all possible features.
(display-options)
a list of options, enclosed in parentheses, that must include at least one of the following:
OUTLINE—displays an outlined, non-filled block
FILL—displays a filled, non-outlined block
VALUES—displays internal block values
LABEL—displays external block label(s)
Use the OUTLINEATTRS=, FILLATTRS=, ALTFILLATTRS=, and BLOCKINDEX= options to control the appearance of the blocks.
Use the VALUEATTRS= and LABELATTRS= options to control the text appearance.
FILLATTRS=style-element | style-element (fill-options) | (fill-options)
specifies the appearance of the block fills. This option in conjunction with the ALTFILLATTRS= option controls fill appearance when FILLTYPE=ALTERNATE. See General Syntax for Attribute Options for the syntax on using a style-element and Fill Options for available fill-options.
Default: The GraphData1 style element.
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.
Interaction: The ALTFILLATTRS= option controls the alternating fill color.
To make all block fill areas the same color, set the FILLATTRS= and ALTFILLATTRS= options to the same value.
FILLTYPE=MULTICOLOR | ALTERNATE
specifies how the blocks are filled.
Default: MULTICOLOR
MULTICOLOR
Blocks are filled with the COLOR attribute of the style elements GraphData1 - GraphDataN or the style elements indicated by the BLOCKINDEX= column.
ALTERNATE
Blocks are filled alternating between the colors specified by the FILLATTRS= and ALTFILLATTRS= options.
Interaction: For this option to have any effect, the fill must be enabled by the ODS style or the DISPLAY= option.
Interaction: When this option is set to ALTERNATE, the block plot does not support a DISCRETELEGEND entry.
LABEL= "string"
specifies an external label for a single block plot.
Default:
  • The variable label of the BLOCK= column.
  • The variable name of the BLOCK= column, if there is no variable label.
Interaction: If the CLASS= option is specified, this option is ignored.
Interaction: The DISPLAY= option must include LABEL for any external label(s) to appear.
The font and color attributes for the external label are specified by the LABELATTRS= option.
LABELATTRS=style-element | style-element (text-options) | (text-options)
specifies the color and font attributes of the external block label(s). See General Syntax for Attribute Options for the syntax on using a style-element and Text Options for available text-options.
Default: The GraphLabelText style element.
LABELPOSITION=LEFT | RIGHT | TOP | BOTTOM
specifies the alignment of BLOCK label.
Default: LEFT
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.
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.
OUTLINEATTRS=style-element | style-element (line-options) | (line-options)
specifies the appearance of the block outlines. See General Syntax for Attribute Options for the syntax on using a style-element and Line Options for available line-options.
Default: The GraphOutlines style element.
Interaction: For this option to have any effect, the outlines must be enabled by the ODS style or the DISPLAY= option.
Interaction: If labels are displayed in the TOP or BOTTOM position, they are also outlined.
REPEATEDVALUES=boolean
specifies whether contiguous block values that are identical create separate blocks.
Default: FALSE
FALSE
If two or more identical block values appear consecutively, only one block is created for them.
TRUE
If two or more identical block values appear consecutively, a separate block is created for each of them.
VALUEATTRS=style-element | style-element (text-options) | (text-options)
specifies the appearance of the text values. See General Syntax for Attribute Options for the syntax on using a style-element and Text Options for available text-options.
Default: The GraphValueText style element.
VALUEFITPOLICY=TRUNCATE | SHRINK
specifies how text values are adjusted to fit within the containing block.
Default: TRUNCATE
TRUNCATE
Any value that does not fit is truncated. 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 (...).
SHRINK
All values are reduced in font size until they all fit.
VALUEHALIGN=LEFT | CENTER | RIGHT | START
specifies the horizontal alignment of the text within the blocks.
Default: LEFT
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
Interaction: For this option to have any effect, the DISPLAY= option must include VALUE.
Interaction: When REPEATEDVALUES=TRUE and X values are numeric, only CENTER and START can be used for a discrete axis, and only LEFT and START can be used for a linear or log axis. For example, if REPEATEDVALUES=TRUE and the axis is discrete, a setting of RIGHT for this option is ignored and LEFT is used instead.
VALUEVALIGN=TOP | CENTER | BOTTOM
specifies the vertical alignment of the text within the blocks.
Default: CENTER
Interaction: For this option to have any effect, the DISPLAY= option must include VALUE.
If the DISPLAY= option also includes LABEL, the label has the same vertical alignment.
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.