Statistical Graphics Using ODS


Saving Graphics Image Files

Knowing where your graphics image files are saved and how they are named is particularly important if you are running in batch mode, if you have disabled the SAS Results window (see the section Viewing Your Graphs in the SAS Windowing Environment), or if you plan to access the files for inclusion in a paper or presentation. The following discussion assumes you are running SAS under the Windows operating system. If you are running on a different operating system, see the SAS Companion for your operating system.

In the SAS windowing environment, the current folder is displayed in the status line at the bottom of the main SAS window. When Use WORK folder is cleared in the Tools $\blacktriangleright $ Options $\blacktriangleright $ Preferences $\blacktriangleright $ Results tab, graph image files are saved in the current folder and are available after your SAS session ends. They can accumulate with time and take up a great deal of space. When Use WORK folder is selected, graph image files are stored in the Work folder and are not available after your SAS session ends.

If you are running your SAS programs in batch mode, the graphs are saved by default in the same directory where you started your SAS session. For example, suppose the SAS current folder is C:\myfiles. If ODS Graphics is enabled, then your graphics image files are saved in the directory C:\myfiles. Traditional graphics are always saved in a catalog in your Work directory.

With the LISTING, HTML, and LATEX destinations, you can specify a directory for saving your graphics image files. With a destination in the PRINTER family and with the RTF destination, you can specify a directory only for your output file. The remainder of this discussion provides details for each destination type.

LISTING Destination

If you are using the LISTING destination, the individual graphs are created as PNG files by default. You can use the GPATH= option in the ODS LISTING statement to specify the directory where your graphics files are saved. For example, if you want to save your graphics image files in C:\figures, then you can specify the following:

ods listing gpath="C:\figures";

It is important to note that the GPATH= option applies only to ODS Graphics. It does not affect the behavior of graphs created with traditional SAS/GRAPH procedures.

HTML Destination

If you are using the HTML destination, the individual graphs are created as PNG files by default. You can use the PATH= and GPATH= options in the ODS HTML statement to specify the directory where your HTML and graphics files are saved, respectively. This also gives you more control over your graphs. For example, if you want to save your HTML file named test.htm in the C:\myfiles directory, but you want to save your graphics image files in C:\myfiles\png, then you can specify the following:

ods html path  = "C:\myfiles"
         gpath = "C:\myfiles\png"
         file  = "test.htm";

When you specify the URL= suboption with the GPATH= option, SAS creates relative paths for the links and references to the graphics image files in the HTML file. This is useful for building output files that are easily moved from one location to another. For example, the following statements create a relative path to the png directory in all the links and references contained in test.htm:

ods html path  = "C:\myfiles"
         gpath = "C:\myfiles\png" (url="png/")
         file  = "test.htm";

If you do not specify the URL= suboption, SAS creates absolute paths that are hard-coded in the HTML file. These can cause broken links if you move the files. For more information, see the ODS HTML statement in the SAS Output Delivery System: User's Guide.

LATEX Destination

LaTeX is a document preparation system for high-quality typesetting. The ODS LATEX statement produces output in the form of a LaTeX source file that is ready to compile in LaTeX. When you request ODS Graphics for a LATEX destination[10], ODS creates the requested graphs as PostScript files by default, and the LaTeX source file includes references to these image graphics files. You can compile the LaTeX file, or you can ignore this file and simply access the individual PostScript files to include your graphs in a different LaTeX document, such as a paper that you are writing. You can specify the PATH= and GPATH= options in the ODS LATEX statement, as explained previously for the ODS HTML statement. See Example 21.3 for an illustration. The ODS LATEX statement is an alias for the ODS MARKUP statement with the TAGSET=LATEX option. For more information, see the SAS Output Delivery System: User's Guide.

The default image file type for the LATEX destination is PostScript. When you use LaTeX to compile your document, the graphics format for included images is Postscript. However, if you prefer to use pdfLaTeX, you can specify a different format such as JPEG, PDF, or PNG, any of which can be directly included into your pdfLaTeXdocument. To specify one of these formats, you use the OUTPUTFMT= option in the ODS GRAPHICS statement. For more information, see the LaTeX documentation for the graphicx package.



[10] The LATEX destination is experimental.