Graphics Image Files


Accessing your graphs as individual image files is useful when you want to include them in various types of documents. The default image file type depends on the ODS destination, but there are other supported image file types that you can specify. You can also specify the names for your graphics image files and the directory in which you want to save them.

This section describes the image file types supported by ODS Graphics, and it explains how to name and save graphics image files.

Describing Supported Image File Types

If you are using an HTML or a LATEX destination, your graphs are individually produced in a specific image file type, such as GIF or PostScript.

If you are using a destination in the PRINTER family or the RTF destination, the graphs are contained in the ODS output file and cannot be accessed as individual image files. However, you can open an RTF output file in Microsoft Word and then copy and paste the graphs into another document, such as a Microsoft PowerPoint presentation; this is illustrated in Example 15.3.

Table 15.2 shows the various ODS destinations supported by ODS Graphics, the viewer that is appropriate for displaying graphs in each destination, and the image file types supported for each destination.

Table 15.2: Destinations and Image File Types Supported by ODS Graphics

Destination

Destination Family

Viewer

Image File Types

DOCUMENT

 

Not Applicable

Not Applicable

HTML

MARKUP

Browser

GIF (default), JPEG, PNG

LATEX

MARKUP

Ghostview

PostScript (default), EPSI, GIF, JPEG, PNG

PCL

PRINTER

Ghostview

Contained in PostScript file

PDF

PRINTER

Acrobat

Contained in PDF file

PS

PRINTER

Ghostview

Contained in PostScript file

RTF

 

Microsoft Word

Contained in RTF file

Note: In SAS 9.1 the LISTING destination does not support ODS Graphics. You must specify a supported ODS destination in order to produce ODS Graphics, as illustrated by all the examples in this chapter.

Naming Graphics Image Files

The names of graphics image files are determined by a base file name , an index counter , and an extension . By default, the base file name is the ODS graph name (see page 330). The index counter is set to zero when you begin a SAS session, and it is increased by one after you create a graph, independently of the graph type or the SAS procedure that creates it. The extension indicates the image file type.

For instance, if you run the example on page 324 at the beginning of a SAS session, the two graphics image files created are Contour0.gif and SurfacePlot1.gif . If you immediately rerun this example, then ODS creates the same graphs in different image files named Contour2.gif and SurfacePlot3.gif .

You can specify the RESET option in the ODS GRAPHICS statement to reset the index counter to zero. This is useful to avoid duplication of graphics image files if you are rerunning a SAS program in the same session.

  ods graphics on / reset;  

Note: The index counter is initialized to zero at the beginning of your SAS session or if you specify the RESET option in the ODS GRAPHICS statement. Graphics image files with the same name are overwritten.

You can specify a base file name for all your graphics image files with the IMAGENAME= option in the ODS GRAPHICS statement. For example:

  ods graphics on / imagename = "MyName";  

You can also specify

  ods graphics on / imagename = "MyName" reset;  

With the preceding statement, the graphics image files are named MyName0 , MyName1 , and so on.

You can specify the image file type for the HTML or LATEX destinations with the IMAGEFMT= option in the ODS GRAPHICS statement. For example:

  ods graphics on / imagefmt = png;  

For more information, see the ODS GRAPHICS Statement section on page 349.

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 Viewer (see page 327), or if you plan to access the files for inclusion in a document. The following discussion assumes you are running SAS under the Windows operating system. If you are running on a different operating system, refer to the SAS Companion for your operating system.

Your graphics image files are saved by default in the SAS current folder. If you are using the SAS windowing environment, the current folder is displayed in the status line at the bottom of the main SAS window (see also page 327). 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 instance, suppose the SAS current folder is C:\myfiles . If you specify the ODS GRAPHICS statement, then your graphics image files are saved in the directory C:\myfiles . Unlike traditional high resolution graphics created with SAS/GRAPH, ODS Graphics are not temporarily stored in a catalog in your Work directory.

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

HTML Destination

If you are using the HTML destination, the individual graphs are created as GIF 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\gif , then you specify

  ods html path  = "C:\myfiles"   gpath = "C:\myfiles\gif"   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 gif directory in all the links and references contained in test.htm .

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

If you do not specify the URL= suboption, SAS creates absolute paths that are hard-coded in the HTML file; these may cause broken links if you move the files. For more information, refer to the ODS HTML statement in the Dictionary of ODS Language Statements ( SAS Output Delivery System User s Guide ).

LATEX Destination

LATEX is a document preparation system for high-quality typesetting. The experimental 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, 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 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 15.4 for an illustration.

The ODS LATEX statement is an alias for the ODS MARKUP statement using the TAGSET=LATEX option. For more information, refer to the ODS MARKUP statement in the Dictionary of ODS Language Statements ( SAS Output Delivery System User s Guide ).

If you are using a LATEX destination with the default PostScript image file type, your ODS graphs are created in gray-scale , regardless of the style you are using. When you use this destination, it is recommended that you use the Journal style to obtain high quality graphics. For more information about styles, see the Specifying Styles for Graphics section on page 332.

To create color graphics using a LATEX destination, specify JPEG, GIF, or PNG with the IMAGEFMT= option in the ODS GRAPHICS statement. If you specify GIF you can use a distiller to obtain a PostScript or a PDF file. If you specify JPEG you may need to include the \ DeclareGraphicsExtensions and the \ DeclareGraphicsRule commands in the preamble of your LATEX file. For more information, refer to the LATEX documentation for the graphicx package.

PRINTER and RTF Destinations

If you are using a destination in the PRINTER family (PCL, PDF, PS) or the RTF destination, the graphs are contained in the output file and cannot be accessed as individual graphics image files. You can specify the path where the output file is to be saved using the FILE= option of the ODS destination statement. For example, suppose that you specify

  ods pdf file = "test.pdf";  

Then your ODS output is saved as the PDF file test.pdf in the SAS current folder (for example, in C:\myfiles ).

You can specify a full path name for your output with the FILE= option. For instance to save your PDF file to the directory C:\temp you specify

  ods pdf file = "C:\temp\test.pdf";  

You can always check the SAS log to verify where your output is saved. For example, the preceding statement would result in the following log message:

  NOTE: Writing ODS PDF output to DISK destination   "C:\temp\test.pdf", printer "PDF".  



SAS.STAT 9.1 Users Guide (Vol. 1)
SAS/STAT 9.1 Users Guide, Volumes 1-7
ISBN: 1590472438
EAN: 2147483647
Year: 2004
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net