Understanding and Customizing SAS Output: The Output Delivery System (ODS) |
Customizing ODS Output at the Level of a SAS Job |
ODS provides a way for you to customize output at the level of the SAS job. To do this, you use a style definition, which describes how to show such items as color, font face, font size, and so on. The style definition determines the appearance of the output. The fancyprinter style definition is one of several that is available with SAS.
The following example uses the fancyprinter style definition to customize program output. The output consists of two output objects, Moments and BasicMeasures, that the UNIVARIATE procedure creates. The STYLE= option on the ODS PRINTER statement specifies that the program use the fancyprinter style.
options nodate pageno=1; ods listing close; ods printer ps file='style_job.ps' style=fancyprinter; ods select Moments BasicMeasures; proc univariate data=sat_scores; var SATscore; title 'Average SAT Scores for Entering College Classes, 1972-1982*'; footnote1 '* Recentered Scale for 1987-1995'; run; ods printer close; ods listing;
The following output shows the results:
Printer Output: Titles, Footnote, and Variables Printed in Italics
For detailed information about style and table definitions, as well as the TEMPLATE procedure, see SAS Output Delivery System: User's Guide.
Customizing ODS Output by Using a Template |
Another way to customize ODS output is by using a template. In ODS, templates are called table definitions. A table definition describes how to format the output. It can determine the order of table headings and footnotes, the order of columns, and the appearance of the output. A table definition can contain one or more columns, headings, or footnotes.
Many procedures that fully support ODS provide table definitions that you can customize. You can also create your own table definition by using the TEMPLATE procedure. The following is a simplified form of the TEMPLATE procedure:
PROC TEMPLATE; DEFINE table-definition; HEADER header(s); COLUMN column(s); END; |
The DEFINE statement creates the table definition that serves as the template for writing the output. The HEADER statement specifies the order of the headings, and the COLUMN statement specifies the order of the columns. The arguments in each of these statements point to routines in the program that format the output. The END statement ends the table definition.
The following example shows how to use PROC TEMPLATE to create customized HTML and printer output. In the example, the SAS program creates a customized table definition for the Basic Measures output table from PROC UNIVARIATE. The following customized version shows that
the "Measures of Variability" section precedes the "Measures of Location" section
statistics are displayed in a bold, italic font with a 7.3 format.
options nodate nonumber linesize=80 pagesize=60; 1 proc template; 2 define table base.univariate.Measures; 3 header h1 h2 h3; 4 column VarMeasure VarValue LocMeasure LocValue; 5 define h1; 6 text "Basic Statistical Measures"; spill_margin=on; space=1; end; define h2; 6 text "Measures of Variability"; start=VarMeasure; end=VarValue; end; define h3; 6 text "Measures of Location"; start=LocMeasure; end=LocValue; end; define LocMeasure; 7 print_headers=off; glue=2; space=3; style=rowheader; end; define LocValue; 7 print_headers=off; space=5; format=7.3; style=data{font_style=italic font_weight=bold}; end; define VarMeasure; 7 print_headers=off; glue=2; space=3; style=rowheader; end; define VarValue; 7 print_headers=off; format=7.3; style=data{font_style=italic font_weight=bold}; end; end; 8 run; 9 ods listing close; ods html file='scores-body.htm' 10 contents='scores-contents.htm' page='scores-page.htm' frame='scores-frame.htm'; ods printer file='scores.ps'; 11 ods select BasicMeasures; 12 title; proc univariate data=sorted_scores mu0=3.5; 13 var SATscore; run; ods html close; 14 ods printer close; 14 ods listing; 15
The following list corresponds to the numbered items in the preceding program:
The following display shows the printer output:
Customized Printer Output from the TEMPLATE Procedure
The following display shows the HTML output:
Customized HTML Output from the TEMPLATE Procedure
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.