O'Reilly logo

Step-by-Step Programming with Base SAS 9.4, Second Edition, 2nd Edition by SAS Institute

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The following list corresponds to the numbered items in the preceding program:
1
By default, the HTML destination is open. To conserve resources, the ODS HTML
CLOSE statement closes this destination.
2
The ODS OUTPUT statement opens the Output destination and specifies the
permanent data set to create from the output object BasicMeasures.
3
The UNIVARIATE procedure produces summary statistics for the average SAT
scores of entering first-year college students. The output is grouped by the CLASS
variable Gender.
4
The ODS OUTPUT CLOSE statement closes the Output destination.
5
The ODS HTML statement reopens the default HTML destination so that the next
program that you run can produce HTML output.
The following SAS log shows that the WORK.MEASURES data set was created with
the ODS OUTPUT statement:
Log 34.3 Partial SAS Log: SAS Data Set Creation
166
167
168 ods html close;
169 ods output BasicMeasures=measures;
170
171
172 proc univariate data=sat_scores;
173
174 var SATscore;
175 class Gender;
176 run;
NOTE: The data set WORK.MEASURES has 8 observations and 6 variables.
NOTE: PROCEDURE UNIVARIATE used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
177
178 ods output close;
179 ods html;
NOTE: Writing HTML Body file: sashtml3.htm
Customizing ODS Output
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 template, which describes how to show such items as color, font face,
font size, and so on. The style template determines the appearance of the output. The
FancyPrinter style template is one of several that is available with SAS.
To view the available ODS style templates, run the following code:
proc template;
list styles;
Customizing ODS Output 667
run;
Output 34.1 Sample Listing of ODS Styles
The following example uses the FancyPrinter style template to customize program
output. The STYLE= option in the ODS PRINTER statement specifies that the program
use the FancyPrinter style. This style causes ODS to write the titles, footnote, and
variable names of the printer output in italics. The PDFTOC= option controls the level of
the expansion of the table of contents in PDF documents. The PDFTOC=1 option
specifies that the TOC has two levels of expansion.
options nodate nonumber;
proc sort data=sashelp.prdsale out=prdsale;
by Country;
run;
ods html close;
ods pdf file='odspdf_output_custom.pdf' pdftoc=2 style=fancyprinter;
title;
668 Chapter 34 Understanding and Customizing SAS Output: The Output Delivery System (ODS)
proc tabulate data=prdsale;
class region division prodtype;
classlev region division prodtype;
var actual;
keyword all sum;
keylabel all='Total';
table (region all)*(division all),
(prodtype all)*(actual*f=dollar10.) /
misstext=[label='Missing']
box=[label='Region by Division and Type'];
run;
title 'Actual Product Sales';
title2 '(millions of dollars)';
proc univariate data=prdsale;
by Country;
var actual;
run;
title 'Sales Figures for First Quarter by Product';
proc sgpanel data=prdsale;
where quarter=1;
panelby product / novarname;
vbar region / response=predict;
vline region / response=actual lineattrs=GraphFit;
colaxis fitpolicy=thin;
rowaxis label='Sales';
run;
ods pdf close;
ods html;
The following output displays the results:
Customizing ODS Output 669
Figure 34.14 Printer Output: Titles, Footnote, and Variables Printed in Italics
For more information about ODS styles, see “Style Templates” in SAS Output Delivery
System: Users Guide.
Customizing ODS Output By Using a Template
Another way to customize ODS output is by using a table template. A table template
describes how to format tabular output. It can determine the order of table headings and
footnotes, the order of columns, and the appearance of the output. A table template can
contain one or more columns, headings, or footnotes. You can create your own table
template, or modify an existing one. Many procedures that fully support ODS provide
table templates that you can customize.
In the SAS Windowing Environment, to view the SAS style templates that are supplied
by SAS, do the following:
1. In the Results window, select the Results folder. Right-click and select Templates to
open the Templates window.
2. Expand a directory, such as Sashelp.Tmplmst or Sashelp.Tmplbase to view the
contents of that directory.
3. Double-click a directory, such as Base to view the contents of that directory.
In this example, we are changing a template that PROC UNIVARIATE creates. To view
the template names for PROC UNIVARIATE, in the Templates window, select
670 Chapter 34 Understanding and Customizing SAS Output: The Output Delivery System (ODS)
Sashelp.Tmplbase ð Base ð Univariate. We are using the Measures table template as
a template to make changes to the output.
Output 34.2 PROC UNIVARIATE Templates That Are Supplied by SAS
Customizing ODS Output 671

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required