Chapter Contents


SAS/GRAPH Software: Reference

Example 3: Using a Web Driver to Generate a Drill-down Graph

This example shows how to use a SAS/GRAPH Web driver to generate a drill-down graph (see About Drill-down Graphs). The example uses the HTML driver, but the principles would be the same for using the WEBFRAME driver.

Note:   The SAS/GRAPH Web drivers do not assign anchor names to the output that they generate. Thus, the Web drivers are best used to generate drill-down graphs that link to GIF files that are stored or referenced in separate files. To link to HTML files that store multiple pieces of output, or to link to both graphics and non-graphics output, it is easier to use ODS to generate drill-down graphs.  [cautionend]

To generate a drill-down graph with the HTML or WEBFRAME device driver, all you have to do is specify the IMAGEMAP= option on the graphics procedure that generates the graph and supply the linking information that identifies the location of the target output. SAS/GRAPH produces the GIF files and the image map needed for the drill-down graph and creates the HTML files needed to display the output and implement the drill-down capability.

Planning the Web Page

To plan the Web page, you must determine what output you need, which Web driver you will use, and what links you need to implement the drill-down capability. This example generates a simple drill-down bar chart showing the regional sales figures for three sales regions.


When the bar chart is displayed in a browser, you can select any one of the bars to drill down to a pie chart that shows the sales figures for the corresponding region. For example, you can click on the bar that represents sales for the Western region to drill down to a pie chart that shows the Western region's sales figures.


To create this drill-down graph, you need the following:
output The output requires a 3-D vertical bar chart to show the drill-down chart. The output also requires three pie charts to show the state sales figures for each region.
drivers The drill-down chart is a single bar chart, so the HTML driver is preferable to the WEBFRAME driver, which is designed for linking to multiple graphs. For the pie charts, the GIF driver can generate the required GIF files.

For naming the GIF files, you can let SAS/GRAPH assign default names, or you can use the NAME= option to control the names. This example will use the NAME= option to ensure that the GIF files are named salereg1.gif, salereg2.gif, and salereg3.gif.

links Each bar in the bar chart requires a link to the corresponding region's pie chart. Because the example will direct each pie chart to its own GIF file, the links do not need anchor names.

The drill-down capability for this design requires only one drill-down level: from the bar chart to the pie charts. There is no legend and, therefore, there are no links from the legend. Thus, only one HTML variable is required to store link information for the chart. This example will create a variable named LINKS.

Each pie chart will be directed to its own GIF file. Thus, the links do not need anchor names. The example assumes that users will access all output through a file system, so a file specification will suffice for the linking information.

Output Needed for the Drill-down Graph

To generate this example drill-down bar chart, you must run the GCHART procedure with the VBAR3D statement. The PROC GCHART statement must use the IMAGEMAP= option to create an Imagemap data set, and the VBAR3D statement must use the HTML= option to specify the HTML variable that contains the linking information--in this case, the variable LINKS. To generate the pie charts, you can use PROC GCHART to generate all three pie charts in a single procedure run by using BY-group processing (see BY Statement) .

In this example code, note the following:

Code for the Example

/* This is the only line you have to change to run the */
/* program. Specify a location in your file system. */
filename webout 'path-to-Web-server';

/* set general graphic options */
goptions reset=global gunit=pct
         htitle=6 htext=4
         ftitle=zapfb ftext=swiss border;

/* assign graphics options for ODS output */
goptions transparency noborder
  xpixels=450 ypixels=400
  gsfname=webout device=html;

/* create data set REGSALES */
data regsales;
    length Region State $ 8;
    format Sales dollar8.;
    input Region State Sales;
    length links $40; /* the HTML variable */

/* add the HTML variable and assign its values */
if Region='Central' then links='href="salereg1.gif"';
  else if Region='South' then links='href="salereg2.gif"';
  else if Region='West' then links='href="salereg3.gif"';

 West    CA  13636
 West    OR  18988
 West    WA  14523
 Central IL  18038
 Central IN  13611
 Central OH  11084
 Central MI  19660
 South   FL  14541
 South   GA  19022

title1 'Company Sales';
proc gchart data=regsales imagemap=salemap;
 vbar3d region / sumvar=sales
  html=links name='htmldril';

/* change to GIF driver for pie charts */
goptions dev=gif;

proc sort data=regsales out=regsales;
by region;

/* Create three charts that use the HTML variable */
proc gchart data=regsales;
  pie3d state / sumvar=sales
   noheading name='salereg1';
by region;

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.