Chapter Contents |
Previous |
Next |
SAS/GRAPH Software: Reference |
You can use ODS to generate a drill-down graph (see About Drill-down Graphs). All you have to do is 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 ODS creates the HTML files to display the output and implement the drill-down capability.
Planning the Web Page |
To plan a Web page when using ODS to generate a drill-down graph, you must determine what output you need, what HTML files you will name to store that output, and what links you need to implement the drill-down capability. This example generates a simple drill-down bar chart that shows 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 report 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 report 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 reports to show the state sales figures for each region. |
HTML files | You can write all of the output to
a single body file, or distribute the output across multiple body files. This
example will direct each piece of output to its own body file.
You can name the HTML files with any legal file name in your operating environment. This example will use the following names: sales.html for the file that references the drill-down chart, and central.html, south.html, and west.html for the reports on regional sales figures. |
links | Each bar in the bar chart requires
a link to the corresponding region's report. Because the example will direct
each report to its own HTML file, 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.
The drill-down capability for this design requires only one drill-down level: from the bar chart to the reports. 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 RPT. |
To provide the drill-down capability, the example creates an HTML variable named RPT. For each sales region, RPT stores the HREF value that links to the target output. The example then specifies RPT as the HTML variable for the GCHART procedure that generates the drill-down graph. To generate the target reports, the example uses PROC PRINT. The example assumes that users will access all output through a file system.
In this example, the data, the bar chart, and the reports are simple so that you can focus on the code needed to generate a drill-down graph. For more realistic drill-down examples, see Creating Bar Charts with Drill-down for the Web and Creating Maps with Drill-down for the Web.
Producing the Output for the Drill-down Graph |
To generate the drill-down bar chart for this example, you must run the GCHART procedure with the VBAR3D statement. The VBAR3D statement must use the HTML= option to specify the HTML variable that contains the linking information - in this case the variable RPT. To generate the reports, you can run the PRINT procedure. To direct each report to its own body file, a separate ODS HTML statement must precede each PRINT procedure.
In this example code, note the following:
For more information about ODS and how it constructs HTML links and references, see How ODS Constructs Links and References.
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 odsout 'path-to-Web-server'; /* close the listing destination */ ods listing close; /* set general graphic options */ goptions reset=global gunit=pct htitle=6 htext=4 ftitle=zapfb ftext=swiss; /* create data set REGSALES */ data regsales; length Region State $ 8; format Sales dollar8.; input Region State Sales; /* the HTML variable */ length rpt $40; /* assign values to HTML variable */ if Region='Central' then rpt='href="central.html"'; else if Region='South' then rpt='href="south.html"'; else if Region='West' then rpt='href="west.html"'; datalines; 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 ; /* assign graphics options for ODS output */ goptions device=gif transparency noborder xpixels=450 ypixels=400; /* open the html destination for ODS output */ ods html body='sales.html' path=odsout; /* Create a chart that uses HTML variable */ title1 'Company Sales'; proc gchart data=regsales; vbar3d region / sumvar=sales patternid=midpoint html=rpt; run; quit; /* open a body file for report */ /* on central sales */ ods html body='central.html' path=odsout; title1 'Central Sales'; proc print data=regsales noobs; var state sales; where region='Central'; run; /* open a body file for report */ /* on southern sales */ title1 'Southern Sales'; ods html body='south.html' path=odsout; proc print data=regsales noobs; var state sales; where region='South'; run; /* open a body file for report */ /* on western sales */ title1 'Western Sales'; ods html body='west.html' path=odsout; proc print data=regsales noobs; var state sales; where region='West'; run; quit; /* close the html destination */ ods html close; /* open the listing destination */ ods listing;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.