Managing Your Graphics


This section describes techniques for managing your graphics:

  • specifying an ODS destination for graphics

  • viewing your graphs in the SAS windowing environment

  • referring to graphs by name when using ODS

  • selecting and excluding graphs from your output

  • modifying the appearance of all your graphs with styles

Specifying an ODS Destination for Graphics

Whenever you use ODS Graphics you must specify a valid ODS destination. The examples in Getting Started illustrate how to specify an HTML destination. Other destinations are specified in a similar way. For example, you can specify an RTF destination with the following statements.

  ods rtf;   ods graphics on;    ...SAS statements...    ods graphics off;   ods rtf close;  

The supported ODS destinations are shown in Table 15.1.

Table 15.1: Destinations Supported by ODS Graphics

Destination

Destination Family

Viewer

DOCUMENT

 

Not Applicable

HTML

MARKUP

Browser

LATEX

MARKUP

Ghostview

PCL

PRINTER

Ghostview

PDF

PRINTER

Acrobat

PS

PRINTER

Ghostview

RTF

 

Microsoft Word

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.

Specifying a File for ODS Output

You can specify a file name for your output with the FILE= option in the ODS destination statement, as in the following example:

  ods html file = "test.htm";  

The output is written to the file test.htm , which is saved in the SAS current folder. At startup, the SAS current folder is the same directory in which you start your SAS session. If you are running SAS with the windowing environment in the Windows operating system, then the current folder is displayed in the status line at the bottom of the main SAS window, as shown in Figure 15.6.

click to expand
Figure 15.6: Current Folder (Right Bottom)

If you do not specify a file name for your output, then SAS provides a default file, which depends on the ODS destination. This file is saved in the SAS current folder. You can always check the SAS log to verify the name of the file in which your output is saved. For example, suppose you specify the following statement at startup:

  ods html;  

Then the following message is displayed in the SAS log:

  NOTE: Writing HTML Body file: sashtml.htm  

The default file names for each destination are specified in the SAS Registry. For more information, refer to the SAS Companion for your operating system.

Viewing Your Graphs in the SAS Windowing Environment

The mechanism for viewing graphics created with ODS can vary depending on your operating system, which viewers are installed on your computer, and the ODS destination you have selected.

If you are using the SAS windowing environment in the Windows operating system and you specify an HTML destination, then by default the results are displayed in the SAS Results Viewer as they are being generated. Depending on your configuration, this may also apply to the PDF and RTF destinations. [ *] For information about the windowing environment in a different operating system, refer to the SAS Companion for that operating system.

If you do not want to view the results as they are being generated, then select Tools Options Preferences... from the menu at the top of the main SAS window. Then in the Results tab disable View results as they are generated , as shown in Figure 15.7.

click to expand
Figure 15.7: Disabling View of Results as Generated

You can change the default to use an external viewer instead of the Results Viewer. Select Tools Options Preferences... from the menu at the top of the main SAS window. Then in the Results tab select Preferred web browser , as shown in Figure 15.8. Your results will then be displayed in the default viewer that is configured in your computer for the corresponding destination.

click to expand
Figure 15.8: Selecting an External Browser

You can also choose which browser to use for HTML output. Select Tools Options Preferences... from the menu at the top of the main SAS window. Then in the Web tab select Other browser , and type (or browse) the path of your preferred browser, as shown in Figure 15.9.

click to expand
Figure 15.9: Changing the Default External Browser

Referring to Graphs by Name

Procedures assign a name to each graph they create with ODS Graphics. This enables you to refer to ODS graphs in the same way that you refer to ODS tables (see the Using the Output Delivery System section on page 274 in Chapter 14, Using the Output Delivery System ). You can determine the names of graphs in several ways:

  • You can look up graph names in the ODS Graphics section of chapters for procedures that use ODS Graphics. See, for example, the ODS Graphics section on page 3922 in Chapter 61, The REG Procedure.

  • You can use the Results window to view the names of ODS graphs created in your SAS session. See the section Using ODS with the SAS Explorer on page 277 for more information.

  • You can use the ODS TRACE ON statement to list the names of graphs created by your SAS session. This statement adds identifying information in the SAS log (or, optionally , in the SAS listing) for each graph that is produced. See page 330 for an example, and the Using the Output Delivery System section on page 274 for more information.

Note that the graph name is not the same as the name of the file containing the graph (see page 335).

Selecting and Excluding Graphs

You can use graph names to specify which ODS graphs are displayed with the ODS SELECT and ODS EXCLUDE statements. See the section Using the Output Delivery System on page 274 for information on how to use these statements.

Example

This example revisits the analysis described in the section Using the ODS GRAPHICS Statement and Procedure Options on page 324.

To determine which output objects are created by ODS, you specify the ODS TRACE ON statement prior to the procedure statements.

  ods trace on;   ods html;   ods graphics on;   proc kde data = bivnormal;   bivarxy/plots = contour surface;   run;   ods graphics off;   ods html close;   ods trace off;  

Figure 15.10 displays the trace record, which is added to the SAS log. By default, the KDE procedure creates table objects named Inputs and Controls, and it creates graph objects named Contour and SurfacePlot. In addition to the name, the trace record provides the label, template, and path for each output object. Graph templates are distinguished from table templates by a naming convention that uses the procedure name in the second level and the word Graphics in the third level. For example, the fully qualified template name for the surface plot created by PROC KDE, as shown in Figure 15.10, is

start figure
  Stat.KDE.Graphics.HistSurface   Output Added:   -------------   Name:       Inputs   Template:   Stat.KDE.Inputs   Path:       KDE.Bivar1.x_y.Inputs   -------------   Output Added:   -------------   Name:       Controls   Template:   Stat.KDE.Controls   Path:       KDE.Bivar1.x_y.Controls   -------------   WARNING: Statistical graphics displays created with ODS are experimental in   this release.   Output Added:   -------------   Name:       Contour   Label:      Contour Plot   Template:   Stat.KDE.Graphics.ContourScatter   Path:       KDE.Bivar1.x_y.Contour   -------------   Output Added:   -------------   Name:       SurfacePlot   Label:      Density Surface   Template:   Stat.KDE.Graphics.HistSurface   Path:       KDE.Bivar1.x_y.SurfacePlot   -------------  
end figure

Figure 15.10: ODS Trace Record in SAS Log

Note that you can specify the LISTING option in the ODS TRACE ON statement to write the trace record to the LISTING destination:

  ods trace on / listing;  

The following statements use the ODS SELECT statement to specify that only the two graph objects named Contour and SurfacePlot are to be included in the HTML output.

  ods html;   ods graphics on;   ods select Contour SurfacePlot;   proc kde data = bivnormal;   bivar x y / plots = contour surface;   run;   ods graphics off;   ods html close;  

A sample program named odsgr02.sas is available for this example in the SAS Sample Library for SAS/STAT software.

Specifying Styles for Graphics

ODS styles control the overall look of your output. A style definition provides formatting information for specific visual aspects of your SAS output. For ODS tables this information typically includes a list of font definitions (each font defines a family, size , weight, and style) and a list of colors, which are associated with common areas of printed output, including titles, footnotes, by-groups, table headers, and table cells .

Starting with SAS 9, ODS styles also include graphical appearance information such as line and marker properties in addition to font and color information. Furthermore, in SAS 9.1, ODS styles include graphics appearance informats for common elements of statistical graphics created with ODS Graphics. These elements include fitted lines, confidence and prediction bands, and outliers.

For more information about styles, refer to the TEMPLATE Procedure: Creating a Style Definition in the SAS Output Delivery System User s Guide .

Specifying a Style

You can specify a style using the STYLE= option in a valid ODS destination, [ *] such as HTML, PDF, RTF, or PRINTER. Each style produces output with the same content, but a somewhat different visual appearance. For example, the following statement request output using the Journal style.

  ods html style = Journal;  

Any SAS-supplied or user-defined style can be used for ODS Graphics. However, of the SAS-supplied styles for SAS 9.1, four are specifically designed and recommended for use with ODS Graphics:

  • Analysis

  • Default

  • Journal

  • Statistical

Figure 15.11 and Figure 15.12 illustrate the difference between the Default and the Journal styles for the HTML destination. Note that the appearance of tables and graphics is coordinated within a particular style. This is also illustrated in the series of examples starting with Example 15.11.

click to expand
Figure 15.11: HTML Output with Default Style
click to expand
Figure 15.12: HTML Output with Journal Style

For more information about styles for ODS Graphics, see the section Styles for Graphics on page 344 or refer to the ODS Statistical Graphics and ODS Styles: Usage and Reference (Experimental) at http://support.sas.com/documentation/onlinedoc/base/.

[ *] If you are using the LATEX or the PS destinations you must use a PostScript viewer, such as Ghostview.

[ *] Style definitions do not apply to the LISTING destination, which uses the SAS monospace format by default for output tables. The LISTING destination is not a valid destination for ODS Graphics in SAS 9.1.




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