Chapter Contents

Previous

Next
The Complete Guide to the SAS Output Delivery System

Customizing Procedure Results

Many procedures that fully support ODS provide table definitions that enable you to customize each output object that the procedure produces. You can do this by creating an alternative table definition for the procedure to use. This section illustrates how to make an alternative table definition. The explanation here focuses on the structure of the table. For detailed explanations of all the statements and attributes that the program uses, see The TEMPLATE Procedure.

For example, the following SAS program creates a customized table definition for the BasicMeasures output object from PROC UNIVARIATE. (The trace record provides the name of the table definition that each object uses. See SAS Log Produced by the ODS TRACE Statement.) In the customized version

The customized output, from both the HTML and the Listing destinations, appears in Customized Listing Output from PROC UNIVARIATE. The customized Printer output appears in Customized Printer Output from PROC UNIVARIATE.

Note:   This example uses file names that may not be valid in all operating environments. To successfully run the example in your operating environment, you may need to change the file specifications. See Alternative ODS HTML Statements for Running Examples in Different Operating Environments.  [cautionend]

/* These four options all affect the Listing output. */
/* NODATE and NONUMBER also affect the Printer output.*/
/* None of them affects the HTML output.              */
options nodate nonumber linesize=80 pagesize=60;
/* This PROC TEMPLATE step creates a table definition */
/* base.univariate.Measures in the SASUSER template   */
/* store. Table definitions that are provided         */
/* by SAS Institute are stored in a template          */
/* store in the SASHELP library. By default, ODS      */
/* searches for a table definition in SASUSER before  */
/* SASHELP, so when PROC UNIVARIATE calls for a       */
/* table definition by this name, ODS uses the one    */
/* from SASUSER.                                      */
proc template;
   define table base.univariate.Measures;

   notes "Basic measures of location and variability";

   translate _val_ = ._ into '';
   /* The HEADER statement determines the order */
   /* in which the table definition uses the    */
   /* headers, which are defined later.         */
   header h1 h2 h3;

   /* The COLUMN statement determines the order */
   /* in which the variables appear. PROC       */
   /* UNIVARIATE names the variables.           */
   column VarMeasure VarValue LocMeasure LocValue;
   /* These DEFINE blocks define the headers.   */
   /* They specify the text for each header. By */
   /* default, a header spans all columns, so   */
   /* H1 does so. H2 spans the variables        */
   /* VarMeasure and VarValue. H3 spans         */
   /* LocMeasure and LocValue.                  */
   define h1;
      text "Basic Statistical Measures";
      spill_margin=on;
      space=1;
   end;

   define h2;
      text "Measures of Variability";
      start=VarMeasure;
      end=VarValue;
   end;

   define h3;
      text "Measures of Location";
      start=LocMeasure;
      end=LocValue;
   end;
   /* These DEFINE blocks specify characteristics  */
   /* for each of the variables. There are two     */
   /* differences between these DEFINE blocks and  */
   /* the ones in the table definition in SASHELP. */
   /* These blocks use FORMAT= to specify a format */
   /* of 7.3 for LocValue and VarValue. They also  */
   /* use STYLE= to specify a bold, italic font    */
   /* for these two variables. The STYLE= option   */
   /* does not affect the Listing output.          */
   define LocMeasure;
      print_headers=off;
      glue=2;
      space=3;
      style=rowheader;
   end;

   define LocValue;
      print_headers=off;
      space=5;
      format=7.3;
      style=data{font_style=italic font_weight=bold};
   end;

   define VarMeasure;
      print_headers=off;
      glue=2;
      space=3;
      style=rowheader;
   end;

   define VarValue;
      print_headers=off;
      format=7.3;
      style=data{font_style=italic font_weight=bold};
   end;
    /* End the table definition.             */
   end;
/* Run the procedure.                        */
run;
/* Begin the program that uses the            */
/* customized table definition.               */

/* The ODS HTML statement opens the HTML      */
/* destination and identifies the files to    */
/* write to.                                  */
ods html file='statepop-body.htm'
     contents='statepop-contents.htm'
         page='statepop-page.htm'
        frame='statepop-frame.htm';

/* The ODS PRINTER statement opens the        */
/* Printer destination and identifies the     */
/* file to write to.                          */
ods printer file='statepop.ps';
/* The ODS SELECT statement selects just the       */
/* output object that contains the basic measures. */ 
ods select BasicMeasures;

/* PROC UNIVARIATE produces one object for each    */
/* variable. It uses the customized table          */
/* definition to format the data because the       */
/* customized definition is in SASUSER. (See the   */
/* explanation with the PROC TEMPLATE statement in */
/* this example.)                                  */
title;
proc univariate data=statepop mu0=3.5;
   var citypop_90 noncitypop_90;
run;

/* Close the HTML destination.    */
ods html close;

/* Close the Printer destination. */
ods printer close;

Customized Listing Output from PROC UNIVARIATE
[HTML Output]  [Listing Output]

Customized Printer Output from PROC UNIVARIATE

[IMAGE]

[IMAGE]


Chapter Contents

Previous

Next

Top of Page

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