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;