Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Using the Output Delivery System

Using the Output Delivery System

The ODS statement is a global statement that enables you to provide instructions to the Output Delivery System. You can use ODS statements to specify options for different ODS destinations, select templates to format your output, and select and exclude output. You can also display the names of individual output tables as they are generated.

In order to select, exclude, or modify a table, you must first know its name. You can obtain the table names in several ways:

Specify the ODS TRACE ON statement prior to the procedure statements that create the output for which you want information. For example, the following statements write the trace record for the specific tables created in this AUTOREG procedure step.


   ods trace on;
   proc autoreg;
      model y1 = time;
      model y2 = time;
   run;

By default, the trace record is written to the SAS log, as displayed in Figure 6.1. Alternatively, you can specify the LISTING option, which writes the information, interleaved with the procedure output, to the SAS listing (see Example 6.1).

   ods trace on;
   proc autoreg;
      model y1 = time;
      model y2 = time;
   run;

.
.
.

Output Added:
-------------
Name:       ParameterEstimates
Label:      Parameter Estimates
Template:   ets.autoreg.ParameterEstimates
Path:       Autoreg.Model1.OLSEst.ParameterEstimates
-------------

.
.
.

Output Added:
-------------
Name:       ParameterEstimates
Label:      Parameter Estimates
Template:   ets.autoreg.ParameterEstimates
Path:       Autoreg.Model2.OLSEst.ParameterEstimates
-------------
Figure 6.1: Partial Contents of the SAS Log: Result of the ODS TRACE Statement

Figure 6.1 displays the trace record, which contains the name of each created table and its associated label, template, and path. The label provides a description of the table. The template name displays the name of the template used to format the table. The path shows the output hierarchy to which the table belongs.

The fully qualified path is given in the trace record. A partially qualified path consists of any part of the full path that begins immediately after a period (.) and continues to the end of the full path. For example, the full path for the parameter estimates for the first model in the preceding regression analysis is


   Autoreg.Model1.OLSEst.ParameterEstimates

Therefore, partially qualified paths for the table are


   Autoreg.Model1.OLSEst.ParameterEstimates
   Model1.OLSEst.ParameterEstimates
   OLSEst.ParameterEstimates
   ParameterEstimates

To refer to a table (in order to select or exclude it from display, for example), specify either the table name or use the table's fully or partially qualified path. You may want to use qualified paths when your SAS program creates several tables that have the same name, as in the preceding example. In such a case, you can use a partially qualified path to select a subset of tables, or you can use a fully qualified path to select a particular table.

You specify the tables that ODS selects or excludes with the ODS SELECT or ODS EXCLUDE statement. Suppose that you want to display only the tables of parameter estimates from the preceding regression analysis. You can give any of the following statements (before invoking the AUTOREG procedure) to display both tables of parameter estimates. For this example, these statements are equivalent:


   ods select Autoreg.Model1.OLSEst.ParameterEstimates
              Autoreg.Model2.OLSEst.ParameterEstimates;

   ods select Model1.OLSEst.ParameterEstimates 
              Model2.OLSEst.ParameterEstimates;

   ods select OLSEst.ParameterEstimates;

   ods select ParameterEstimates;

The first ODS SELECT statement specifies the full path for both tables. The second statement specifies the partially qualified path for both tables. The third and fourth statements specifiy the partial path "OLSEst.ParameterEstimates," and single name "ParameterEstimates," which are shared by both tables.

The Output Delivery System records the specified table names in its internal selection or exclusion list. ODS then processes the output it receives. Note that ODS maintains an overall selection or exclusion list that pertains to all ODS destinations, and it maintains a separate selection or exclusion list for each ODS destination. The list for a specific destination provides the primary filtering step. Restrictions you specify in the overall list are added to the destination-specific lists.

Suppose, for example, that your listing exclusion list (that is, the list of tables you wish to exclude from the SAS listing) contains the "Summary" table, which you specify with the statement


   ods listing exclude Summary;

and your overall selection list (that is, the list of tables you want to select for all destinations) contains the tables "Summary" and "ParameterEstimates," which you specify with the statement


   ods select ParameterEstimates Summary;

The Output Delivery System then sends only the "ParameterEstimates" and "Summary" tables to all open destinations except the SAS listing. It sends only the "ParameterEstimates" table to the SAS listing because the table "Summary" is excluded from that destination.

Some SAS procedures, such as the ARIMA or the MODEL procedure, support run-group processing, which means that a RUN statement does not end the procedure. A QUIT statement explicitly ends such procedures; if you omit the QUIT statement, a PROC or a DATA statement implicitly ends such procedures. When you use the Output Delivery System with procedures that support run-group processing, it is good programming practice to specify a QUIT statement at the end of the procedure. This causes ODS to clear the selection or exclusion list, and you are less likely to encounter unexpected results.

Using ODS with the SAS Explorer

The SAS Explorer is a new feature that enables you to examine the various parts of the SAS System. Display 6.1 displays the Results window from the SAS Explorer. The Results node retains a running record of your output as it is generated during your SAS session. Display 6.1 displays the output hierarchy when the preceding statements are executed.

Display 6.1: The Results Window from the SAS Explorer
odsgs02.gif (14120 bytes)

When you click on the output table names in the Results window, you link directly to the output in the output window or, if you specify the HTML destination, in an HTML browser. The items on the left-hand side of the Results node are output directories. The items on the right-hand side of the Results node are the names of the actual output objects. You can also use the Explorer to determine names of the templates associated with each output table.

Controlling Output Appearance with Templates

A template is an abstract description of how output should appear when it is formatted. Templates describe several characteristics of the output, including headers, column ordering, style information, justification, and formats. All SAS/ETS procedures have templates, which are stored in the SASHELP library.

You can create or modify a template with the TEMPLATE procedure. For example, you can specify different column headings or different orderings of columns in a table. You can find the template associated with a particular output table by using the ODS TRACE statement or the SAS Explorer.

You can display the contents of a template by executing the following statements:


   proc template;
      source templatename;
   run;

where templatename is the name of the template.

Suppose you want to change the way all of the parameter estimates are displayed by the AUTOREG procedure. You can redefine the templates that the procedure uses with PROC TEMPLATE. For example, in order to have the ESTIMATE and STANDARD ERROR columns always displayed with more digits, you can redefine the columns used by the procedure to display them:


   proc template;
      edit ets.autoreg.ParameterEstimates;
         edit Estimate; format=Best16.; end;
         edit StdErr; format=Best16.; end;
      end;
   run;

The BESTw. format enables you to display the most information about a value, according to the available field width. The BEST16. format specifies a field width of 16. Refer to the chapter on formats in SAS Language Reference: Dictionary for detailed information.

When you run PROC TEMPLATE to modify or edit a template, the template is stored in your SASUSER library. You can then modify the path that ODS uses to look up templates with the ODS PATH statement in order to access these new templates in a later SAS session. This means that you can create a default set of templates to modify the presentation format for all your SAS output. (Note that you can specify the SHOW option in the ODS PATH statement to determine the current path.) It is important to note the difference between a style template and a table template. A table template applies only to the specific tables that reference the template. The preceding statements that modify the "ets.autoreg.ParameterEstimates" template provide an example of modifying columns within a table template.

A style template applies to an entire SAS job and can be specified only in the ODS HTML statement. You can specify a style as follows:


   ods html style=Styles.Brown;

A style template controls stylistic elements such as colors, fonts, and presentation attributes. When you use a style template, you ensure that all your output shares a consistent presentation style.

You can also reference style information in table templates for individual headers and data cells. You can modify either type of template with the TEMPLATE procedure. For information on creating your own styles, refer to The Complete Guide to the SAS Output Delivery System.

Interaction Between ODS and the NOPRINT Option

Most SAS/ETS procedures support a NOPRINT option that you can use when you want to create an output data set but do not want any displayed output. Typically, you use an OUTPUT statement in addition to the procedure's NOPRINT option to create a data set and suppress displayed output.

You can also use the Output Delivery System to create output data sets by using the ODS OUTPUT statement. However, if you specify the NOPRINT option, the procedure may not send any output to the Output Delivery System. Therefore, when you want to create output data sets through ODS (using the ODS OUTPUT statement), and you want to suppress the display of all output, specify


   ODS SELECT NONE;

or close the active ODS destinations by giving the command


   ODS destinationname CLOSE;

where destinationname is the name of the active ODS destination (for example, ODS HTML CLOSE).

Note: The ODS statement does not instruct a procedure to generate output: instead, it specifies how the Output Delivery System should manage the table once it is created. The requested data table (output) has to be generated by the procedure before ODS can manage it. You must ensure that the proper options are in effect. For example, the following code does not create the requested data set Parms.


   proc autoreg;
      ods output ML.ParameterEstimates=Parms;
      model y1 = time;
   run;

When you execute these statements, the following line is displayed in the log:


   WARNING: Output 'ML.ParameterEstimates' was not created.

The data set Parms is not created because the table of parameter estimates is generated only when the METHOD=ML option is specified in the MODEL statement in the AUTOREG procedure.

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.