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 value
95 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;