SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating Drill-Down Graphs in HTML
Lesson Summary

This page contains


I. Text Summary

To go to the page where a task, programming feature, or concept was presented, select a link.


Tasks in Creating Drill-Down Graphs
To display the full depth of complex data, use ODS HTML with PROC GCHART to generate a drill-down graph. The elements of the graph will be linked so that a click will load another, more detailed chart or table in the user's browser. To create a drill-down graph, you write a SAS program to do the following:

  1. Create the initial chart that you want to use as the primary chart.
  2. Create a variable to hold HREF addresses for the linked HTML files.
  3. Define values for the new variable.
  4. Set ODS output to HTML.
  5. Create a primary chart, using SAS/GRAPH software, and attach links.
  6. Create the secondary, linked charts and tables.
Creating a Variable for Link Locations
After you have decided on the graph you want to use, you should create a variable for storing its HREF links. Because HREF links are long text strings, begin with a LENGTH statement to define the new character variable.

Defining Values for Link Locations
After you've created the link location variable, you need to supply it with values. These values are HREF addresses and will determine what pages are loaded when users click parts of the chart. Assign the addresses according to the chart's axis values, beginning each string with HREF=.

Setting ODS HTML Options
Use the ODS HTML statement to switch output to HTML. Add the PATH= option to specify a directory path for storing HTML and GIF files. Add the BODY= option to provide a name for the page containing the drill-down chart. Depending on your operating environment, you may need to specify additional statements or options.

Attaching Links to the Primary Chart
To save your charts as GIF files, write a GOPTIONS statement and specify DEVICE=GIF. Use the GCHART procedure as you normally would, but tie the link location variable to the chart by adding the HTML= option and specifying the variable. Chart elements will become links and load the HREF addresses defined by the variable's values.

Creating the Secondary Charts and Tables
For every HREF address assigned to the chart, you need a matching HTML file or page location. Create these secondary charts and tables with SAS procedures, subsetting data with WHERE statements. For drill-downs to anchors within the same page, use a pound sign (#) when you assign location values. Then assign the anchors to procedure output with the ANCHOR= option in the ODS HTML statement.


II. Syntax

To go to the page where a statement or option was presented, select a link.

DATA SAS-data-set;
         SET SAS-data-set;
         LENGTH variable-1 <...variable-n> <$> length;
         IF expression THEN statement;
         <ELSE statement;>
RUN;
ODS LISTING CLOSE;
ODS HTML <PATH='html-file-path'>
         <BODY='html-file-name'>
         
<ANCHOR='html-anchor-name'>;
GOPTIONS <DEVICE=GIF> <XPIXELS=value>
         <YPIXELS=value>;
TITLE<n> <'text' | "text">;
PROC GCHART <DATA=SAS-data-set>;
         VBAR chart-variable(s) </ option(s)>
         HTML=chart-drill-down-variable;
         WHERE where-expression;
RUN;
QUIT;
ODS HTML CLOSE;
ODS LISTING;

III. Sample Program

Here you can view the final, annotated version of the program you developed.


IV. Points to Remember

  • The directory specified by PATH= must exist on your system; ODS will not create it for you.

  • If you transfer your files to a different operating environment, you also need to consider case in links in your HTML files.

  • When you link a graph to anchors that are on the same page, insert the code that produces the anchored output right after the code that creates the graph and page.


  back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement