Chapter Contents

Previous

Next
SAS/GRAPH Software: Reference

Example 2: Using ODS with SAS/GRAPH Software

This example uses ODS to generate Web output. It produces a bar chart that shows sales figures for three sales regions. The GCHART procedure uses BY-group processing to generate a separate chart for each region.

The ODS HTML statement creates a body file and contents file, and it uses a frame file to display the output. The NEWFILE= option is used to direct each output graph to its own GIF file. To see each graph, you select the reference to it in the Table of Contents, which is displayed in the left frame when you view file saleFram.html in a browser.

[IMAGE]

In this example, the data and the output are kept simple so that you can focus on the code used in ODS processing. For more detailed examples, see the following:
Example 8. Creating a Simple Web Page with the ODS HTML Statement
Example 9. Combining Graphs and Reports in a Web Page
Example 10. Creating a Bar Chart with Drill-down for the Web

/* This program uses ODS to create html */
/* and gif output. 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 the graphics environment */
goptions reset=global gunit=pct
         htitle=6 htext=4 ctext=black
         ftitle=zapfb ftext=swiss;

/* create data set REGSALES */
data regsales;
    length Region State $ 8;
    format Sales dollar8.;
    input Region State Sales;
    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
;

/* Sort data by the BY variable */
proc sort data=regsales;
by region;
run;

/* assign graphics options for ODS output */
goptions device=gif transparency noborder;

/* open html destination for ODS output */
ods html body='sales.html'
         contents='saleCont.html'
         frame='saleFram.html'
         path=odsout
         newfile=output;

/* Run the GCHART procedure */
title1 'Regional Sales';
proc gchart data=regsales;
   vbar3d state / sumvar=sales
   patternid=by;
by region;
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.