Statistical Graphics Using ODS


Determining Graph Names and Labels

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 section The ODS Statement in Chapter 20: Using the Output Delivery System). You can determine the names of graphs in several ways:

The graph name is not the same as the name of the image file that contains the graph (see the section Naming Graphics Image Files).

This example revisits the analysis described in the section Contour and Surface Plots with PROC KDE. To determine which output objects are created by ODS, you specify the ODS TRACE ON statement prior to the procedure statements as follows:

ods graphics on;
ods trace on;

proc kde data=bivnormal;
   bivar x y / plots=contour surface;
run;

ods trace off;

The trace record from the SAS log is as follows:

   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
   -------------

   Output Added:
   -------------
   Name:       ContourPlot
   Label:      Contour Plot
   Template:   Stat.KDE.Graphics.Contour
   Path:       KDE.Bivar1.x_y.ContourPlot
   -------------

   Output Added:
   -------------
   Name:       SurfacePlot
   Label:      Density Surface
   Template:   Stat.KDE.Graphics.Surface
   Path:       KDE.Bivar1.x_y.SurfacePlot
   -------------

By default, PROC KDE creates table objects named Inputs and Controls, and it creates graph objects named ContourPlot 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 Graphics in the third level. For example, the fully qualified template name for the surface plot created by PROC KDE is Stat.KDE.Graphics.SurfacePlot.

You can specify the LISTING option in the ODS TRACE ON statement to write the trace record to the LISTING destination as follows:

ods trace on / listing;

Each table and graph has a path (or name path), which was previously shown in the trace output. The path consists of the plot name preceded by the names of one or more output groups. Each table and graph also has a label path, which can be seen by adding the LABEL option to the ODS TRACE ON statement, after a slash, as follows:

ods trace on / label;

proc kde data=bivnormal;
   bivar x y / plots=contour surface;
run;

ods trace off;

A portion of the trace output is shown next:

   Path:       KDE.Bivar1.x_y.Inputs
   Label Path: 'The KDE Procedure'.'Bivariate Analysis'.'x and y'.'KDE.Bivar1.x_y'

   Path:       KDE.Bivar1.x_y.Controls
   Label Path: 'The KDE Procedure'.'Bivariate Analysis'.'x and y'.'KDE.Bivar1.x_y'

   Path:       KDE.Bivar1.x_y.ContourPlot
   Label Path: 'The KDE Procedure'.'Bivariate Analysis'.'x and y'.'Contour Plot'

   Path:       KDE.Bivar1.x_y.SurfacePlot
   Label Path: 'The KDE Procedure'.'Bivariate Analysis'.'x and y'.'Density Surface'

The label path contains the information that you see in the HTML table of contents. Names are fixed, they do not vary, and they are not data- or context-dependent. In contrast, labels often reflect data- or context-dependent information.