![]() | ![]() | ![]() |
SAS/GRAPH® software provides many device drivers that enable you to create graphics output which you can then view with another software product. When writing a single graphics output file to disk without using ODS, add the following statements to your SAS® code, before the SAS/GRAPH procedure step:
filename grafout 'filename.ext';
goptions reset=goptions device=device-driver-name
gsfname=grafout gsfmode=replace;
If you are running on a Microsoft Windows operating system and you want to write a PNG file called SASTEST.PNG to the TEMP folder on your C: drive, add the following statements to your SAS code, right before your SAS/GRAPH procedure step:
filename grafout 'c:\temp\sastest.png';
goptions reset=goptions device=png
gsfname=grafout gsfmode=replace;
Here is a list of some of the most commonly used SAS/GRAPH device drivers when writing a graphics output file to disk:
GIF PNG PNG300 (300 DPI driver that is new with SAS® 9.2) JPEG JPEG300 (300 DPI driver that is new with SAS 9.2) CGMOFML (creates landscape mode CGM output) CGMOFMP (creates portrait mode CGM output) EMF SASEMF TIFFB (creates black and white TIFF output) TIFFP (creates color TIFF output) TIFFB300 (300 DPI driver that is new with SAS 9.2) TIFFP300 (300 DPI driver that is new with SAS 9.2)
With the graph formats listed above, you can only write one graph per output file. This is not a SAS limitation, but a limitation of the graphics file format itself. If your SAS code produces multiple graphs, you will have to write multiple graph files to disk. If you need to write multiple graphs to a single file or document, you might want to consider writing your graphics output to either a PDF file or a RTF file.
If your SAS code creates multiple graphs, you can have SAS/GRAPH automatically write multiple graph files to disk by using a technique similar to that shown above. However, with this technique, modify the SAS FILENAME statement for GRAFOUT so that it only points to a directory instead of a specific output file. Let us assume that you are running on a Windows operating system and that your code produces multiple graphs. To have SAS/GRAPH write multiple PNG files to the TEMP folder on your C: drive, use code similar to the following:
filename grafout 'c:\temp';
goptions reset=all device=png
gsfname=grafout gsfmode=replace;
/* Your SAS/GRAPH procedure code goes here */
When using the technique shown above to write multiple graph files to disk, SAS/GRAPH will assign the graph files default names (such as GPLOT.PNG, GPLOT1.PNG, and so on). To write graph files to disk with names of your choice, use the NAME= option as part of your SAS/GRAPH procedure syntax (such as the NAME= option in the PLOT statement of GPLOT or the NAME= option in the VBAR statement of PROC GCHART).
Using ODS together with SAS/GRAPH, you can also export your SAS/GRAPH output in HTML, PDF, and RTF formats.
In general, when using SAS/GRAPH with the ODS HTML statement to create graphics output for the Web, your SAS statements should look similar to the following:
goptions reset=goptions device=device-driver-name; ods listing close; ods html path='your-directory' (url=none) file='sastest.html'; /* Your SAS/GRAPH procedure code goes here */ ods html close; ods listing;
The value for device-driver-name for the DEVICE= option in the GOPTIONS statement above can be one of the following:
PNG GIF ACTIVEX ACTXIMG (Windows only) JAVA JAVAIMG JAVAMETA
The recommended statements and options to use when exporting SAS/GRAPH output in PDF format are documented in Usage Note 19331.
The recommended statements and options to use when exporting SAS/GRAPH output in RTF format when running on the Windows operating system are documented in Usage Note 32474.
The recommended statements and options to use when exporting SAS/GRAPH output in RTF format when running on a non-Windows operating system are documented in Usage Note 35957.
| Product Family | Product | System | SAS Release | |
| Reported | Fixed* | |||
| SAS System | SAS/GRAPH | All | n/a | |
| Type: | Usage Note |
| Priority: | low |
| Date Modified: | 2011-11-03 10:43:51 |
| Date Created: | 2002-12-16 10:56:42 |


