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

Before you can view ODS output (other than the default destination), the ODS
destination must be closed. If you run an example without closing the destination, the
SAS log lists the file as being created, but you cannot access the file or see the file when
you issue the ls command. To access the file, execute the following statement in your
SAS session: ODS destination CLOSE;
Note: The ODS _ALL_ CLOSE statement, which closes all open destinations, is
available with SAS Release 8.2 and higher.
In some cases you might not want to create HTML output. Use the ODS HTML CLOSE;
statement at the beginning of your program to close the HTML destination and prevent
SAS from producing HTML output. Closing unnecessary destinations conserves system
resources.
Note: Because ODS statements are global statements, it is good practice to open the
HTML destination at the end of your program. If you execute other programs in your
current SAS session, HTML output is then available. To open the HTML destination,
use the ODS HTML; statement at the end of your program.
Creating Formatted Output
Creating HTML Output for a Web Browser
Understanding the Four Types of HTML Output Files
HTML output is created b default. However, if you want to use ODS HTML statement
options, or create a table file, page file, or frame file, you must use the ODS HTML
statement. When you use the ODS HTML statement, you can create output that is
formatted in HTML. You can browse the output files with Internet Explorer, Netscape,
or any other browser that fully supports the HTML 4.
The ODS HTML statement can create four types of HTML files:
a body file that contains the results of the DATA step or procedure
a table of contents that links to items in the body file
a table of pages that links to items in the body file
a frame file that displays the results of the procedure or DATA step, the table of
contents, and the table of pages
The body file is created by default with all ODS HTML output. If you do not want to
link to your output, then creating a table of contents, a table of pages, and a frame file is
not necessary.
Creating HTML Output: The Simplest Case
To produce the simplest type of HTML output, the only file that you need to create is a
body file. The following example executes the SORT, MEANS, TABULATE,
UNIVARIATE, and SGPANEL procedures. These files contain summary statistics for
the sales of office furniture in various countries. Notice that no ODS statement is needed,
because the HTML destination is open and SAS automatically creates the HTML body
file.
options nodate nonumber;
proc sort data=sashelp.prdsale out=prdsale;
by Country;
648 Chapter 34 Understanding and Customizing SAS Output: The Output Delivery System (ODS)
run;
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;
Creating Formatted Output 649
You can view the output in the Results Viewer window, and browse the output objects in
the Results window. You can view information about each output object such as name,
type, description, and template in the Table Properties window.
Figure 34.2 Output Viewed in the Results Window
650 Chapter 34 Understanding and Customizing SAS Output: The Output Delivery System (ODS)
In the Results window, the following output corresponds to the output object Table 1
under Tabulate: Actual Product Sales ð Cross-tabular summary report. The name
of this output object is Table 1.
Figure 34.3 PROC TABULATE Output
You can view the properties of each output object in the Table Properties window by
right-clicking on the highlight output object and selecting Properties from the drop
down list.
Figure 34.4 PROC TABULATE: Properties of Table 1
Creating Formatted Output 651
In the Results window, the following output corresponds to the output object Moments
under: Univariate: Actual Product Sales ð Country=CANADA ð ACTUAL. The
name of this output object is Moments.
Figure 34.5 PROC UNIVARIATE Output
You can view the properties of each output object in the Table Properties window by
right-clicking on the highlight output object and selecting Properties from the drop
down list.
Figure 34.6 PROC UNIVARIATE: Properties of Moments
652 Chapter 34 Understanding and Customizing SAS Output: The Output Delivery System (ODS)

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