Previous Page | Next Page

Getting Started With SAS/GRAPH

Generating Output With SAS/GRAPH Procedures

ODS provides many destinations to which you can send output. Some of the most often used destinations are LISTING, HTML (a Web page), RTF (an Microsoft Word document), and PDF. As described in Introduction to Styles, each destination is associated with a default style. The following topics each show the default output for each of the destinations listed above.

Each destination is also associated with a default device driver for generating graphics output. Device drivers determine the form that your graphics output takes. For example, the PNG device driver generates PNG image files, and the JAVA device driver generates Java applets that can be run from within HTML pages.

Each destination is associated with a default style and a default device, so you do not need to specify either one to get professional-quality output. You can even send output to several destinations at the same time without specifying either a device or a style.


Sending Output to the GRAPH Window (LISTING Destination)

When working in an interactive environment such as Windows, the LISTING destination is the GRAPH window. By default, the LISTING destination is open, so to send output to it, you simply submit your SAS/GRAPH program. The following example is a simple GCHART program that produces the output shown in LISTING Destination Output Using the Listing Style (Shown in the GRAPH Window).

goptions reset=all border;
title  "US Electric Power - Revenue and Generation Sources";

proc gchart data=sashelp.electric (where=(year >= 2000)) ;
   vbar year / discrete sumvar=Revenue subgroup=Customer;
run;
quit;

LISTING Destination Output Using the Listing Style (Shown in the GRAPH Window)

[LISTING Destination Output Using the Listing Style (Shown in the GRAPH Window)]

The default style applied to output sent to the LISTING destination is the Listing style. When you send output to the LISTING destination, SAS/GRAPH uses a default device driver that generates output for the GRAPH window. This device driver does not write an image file to disk.(footnote 1) For the LISTING destination, the default device driver varies by operating environment. In a Display Manager Session (DMS), the default device driver on Windows systems is WIN. On UNIX systems, the default device driver is XCOLOR, and on z/OS systems, the default device driver is IBMPCGX.


Sending Output to a File

To send output to disk file, send your output to the ODS LISTING destination, but specify a graphics output device using the DEVICE= graphics option. You can use a FILENAME statement and the GSFNAME= graphics option to specify a name and location for the graphics output file. If you do not specify a name with the GSFNAME= graphics option, the default name for the procedure or the name specified with the NAME= option is used as the filename.

To create a GIF file with the graph shown in LISTING Destination Output Using the Listing Style (Shown in the GRAPH Window), in the procedure code, add a FILENAME statement to create a file reference to the desired output file. Then, add the DEVICE=GIF and GSFNAME=FileRef graphics options to the GOPTIONS statement, where FileRef is the file reference that you created in the FILENAME statement.

filename gout "./revgensrcs.gif";
goptions reset=all device=gif gsfname=gout border;
title  "US Electric Power - Revenue and Generation Sources";

proc gchart data=sashelp.electric (where=(year >= 2000)) ;
   vbar year / discrete sumvar=Revenue subgroup=Customer;
run;
quit;

By default, the Listing style is applied to the graph as shown in LISTING Destination Output Using the Listing Style (Shown in the GRAPH Window). In the FILENAME statement, the current directory is the default SAS output directory.

For more information on sending graphics output to a file, see Controlling Where Your Output is Stored.


Sending Output to a Web Page

Tosend output to a Web page, send your output to the HTML destination by specifying the ODS HTML statement. This statement opens the HTML destination so that it can receive output. You must also close the HTML destination before output can be generated.

To create a Web page with the graph shown in LISTING Destination Output Using the Listing Style (Shown in the GRAPH Window), add the ODS HTML statements around the procedure code.

ods listing close;
ods html;
goptions reset=all border;
title  "US Electric Power - Revenue and Generation Sources";

proc gchart data=sashelp.electric (where=(year >= 2000)) ;
   vbar year / discrete sumvar=Revenue subgroup=Customer;
run;
quit;
ods html close;
ods listing;

HTML Destination Output Using the Default Style (Styles.Default)

[HTML Destination Output Using the Default Style (Styles.Default)]

By default, SAS/GRAPH creates a PNG file that contains the graph and an HTML page that references the PNG file. You can use the BODY= and PATH= options in the ODS HTML statement to specify a specific filename and location for the HTML and PNG files. SAS/GRAPH displays the HTML page in the Results Viewer. You can also view the graph outside of your SAS session by displaying the HTML page in your browser. The default device driver is PNG, and the default style is Default (STYLES.DEFAULT).


Sending Output to an RTF File (Microsoft Word Document)

To send output to an RTF file, send your output to the RTF destination by specifying the ODS RTF statement. This statement opens the RTF destination so that it can receive output. You must also close the RTF destination before output can be generated.

To create an RTF document that contains the graph shown in LISTING Destination Output Using the Listing Style (Shown in the GRAPH Window), add the ODS RTF statements around the procedure code.

ods listing close;
ods rtf;
goptions reset=all border;
title  "US Electric Power - Revenue and Generation Sources";

proc gchart data=sashelp.electric (where=(year >= 2000)) ;
   vbar year / discrete sumvar=Revenue subgroup=Customer;
run;
quit;
ods rtf close;
ods listing;

RTF Output Using the Rtf Style

[RTF Output Using the Rtf Style]

By default, SAS/GRAPH creates an RTF file with the graph embedded in it and displays this RTF file in the Results Viewer. When you send output to the RTF destination, SAS/GRAPH does not write a separate image file to disk. The default device driver is the SASEMF driver, and the default style is Rtf.


Sending Output to a PDF File

To send output to a PDF file, send your output to the PDF destination by specifying the ODS PDF statement. This statement opens the PDF destination so that it can receive output. You must also close the PDF destination before output can be generated.

To create a PDF document that contains the graph shown in LISTING Destination Output Using the Listing Style (Shown in the GRAPH Window), add the ODS PDF statements around the procedure code.

ods listing close;
ods pdf;
goptions reset=all border;
title  "US Electric Power - Revenue and Generation Sources";

proc gchart data=sashelp.electric (where=(year >= 2000)) ;
   vbar year / discrete sumvar=Revenue subgroup=Customer;
run;
quit;
ods pdf close;
ods listing;

PDF Output Using the Printer Style

[PDF Output Using the Printer Style]

By default, SAS/GRAPH creates a PDF file and displays this PDF file in the Results Viewer. When you send output to the PDF destination, SAS/GRAPH does not write a separate image file to disk. The default device driver is the SASPRTC device driver, and the default style applied to output sent to the PDF destination is Printer.


FOOTNOTE 1:   SAS/GRAPH procedures create GRSEG catalog entries when you send output to the LISTING destination, but the GRSEG file format is an internal file format specific to SAS/GRAPH. It cannot be used as if it was an image file such as a PNG, GIF, or JPEG file.  [arrow]

Previous Page | Next Page | Top of Page