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
;
proc sort data=sashelp.stocks(keep=date stock close)
  out=MSstock;
  where stock="Microsoft"; 
  by date;

data events;
  merge MSstock MSevents;
  by date;
run;
In the combined input data set, notice that the RELEASE value is missing for each observation until the first defined “event” occurs on 01JUN90. The RELEASE value is missing again for subsequent observations and will not have another value until the next event occurs on 01SEP95, when the MSEVENTS data supplies the value 95.
Obs    Date      Close   Release
... 
45    02APR90   $58.00
46    01MAY90   $73.00
47    01JUN90   $76.00     3.0
48    02JUL90   $66.50     
49    01AUG90   $61.50     
50    04SEP90   $63.00     
...
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. The BLOCKPLOT statement sets EXTENDBLOCKONMISSING=TRUE so that missing values in the data revert to the previous nonmissing value in the block plot. Thus, in the block plot, values are missing until 01JUN90, when the value changes from missing to 3.0. The block plot retains that 3.0 value for subsequent observations until the next nonmissing value replaces it (in this case, the value95 on 01SEP95).
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)
           extendblockonmissing=true ;
        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)
          extendblockonmissing=true;
        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 whether a missing value in the BLOCK column starts a new block or reverts to the previous nonmissing value.
Specifies the appearance of the block fills.
Specifies how the blocks are filled.
Specifies whether missing values of the class variable are included in the plot.
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 the value text within the blocks.
Specifies the vertical alignment of the value text within the 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.
Tip: The DATATRANSPARENCY= option sets the transparency for the block fills and the outlines. You can combine this option with DATATRANSPARENCY= to set one transparency for the outlines but a different transparency for the alternate block fills. Example:
datatransparency=0.2 altfillattrs=(transparency=0.6)
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)
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=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 the external block label or labels
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.
EXTENDBLOCKONMISSING=boolean
specifies whether a missing value in the BLOCK column starts a new block or reverts to the previous nonmissing value.
Default: FALSE
Tip: When EXTENDBLOCKONMISSING = TRUE, you can set up the input data for the BLOCK= column with nonmissing values where you expect the blocks to change and leave the remaining block values missing. For an example, see BlockPlot Overlaid with SeriesPlot.
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.
Tip: The DATATRANSPARENCY= option sets the transparency for the block fills and the outlines. You can combine this option with DATATRANSPARENCY= to set one transparency for the outlines but a different transparency for the block fills. Example:
datatransparency=0.2 fillattrs=(transparency=0.6)
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.
INCLUDEMISSINGCLASS=boolean
specifies whether missing values of the class variable are included in the plot.
Default: TRUE
Interaction: The CLASS=class option must be specified for this option to have any effect.
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 value 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. In addition, 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 value text within the blocks.
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