Understanding and Customizing SAS Output: The Output Delivery System (ODS) |
Creating HTML Output for a Web Browser |
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 3.2 tag set.
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 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 required 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.
To produce the simplest kind of HTML output, the only file you need to create is a body file.
The following example executes the MEANS procedure and creates an HTML body file and the default Listing file. These files contain summary statistics for the average SAT scores of entering first-year college students. The output is grouped by the CLASS variables Test and Gender.
options pageno=1 nodate pagesize=30 linesize=78; ods html file='summary-results.htm'; 1 proc means data=sat_scores fw=8; 2 var SATscore; class Test Gender; title1 'Average SAT Scores Entering College Classes, 1972-1998*'; footnote1 '* Recentered Scale for 1987-1995'; run; ods html close; 3
The following list corresponds to the numbered items in the preceding program:
The following output shows the results in HTML format:
ODS Output: HTML Format
The following output shows the results in the Listing format:
Average SAT Scores Entering College Classes, 1972-1998* 1 The MEANS Procedure Analysis Variable : SATscore N Test Gender Obs N Mean Std Dev Minimum Maximum --------------------------------------------------------------------------- Math f 27 27 481.8 7.0057 473.0 496.0 m 27 27 521.6 4.3175 515.0 531.0 Verbal f 27 27 503.0 8.2671 495.0 529.0 m 27 27 510.5 6.7218 501.0 531.0 --------------------------------------------------------------------------- * Recentered Scale for 1987-1995
The ODS HTML destination enables you to link to your results from a table of contents and a table of pages. To do this, you need to create the following HTML files: a body file, a frame file, a table of contents, and a table of pages (see Understanding the Four Types of HTML Output Files). When you view the frame file and select a link in the table of contents or the table of pages, the HTML table that contains the selected part of the procedure results appears at the top of your browser.
The following example creates multiple pages of output from the UNIVARIATE procedure. You can access specific output results (tables) from links in the table of contents or the table of pages. The results contain statistics for the average SAT scores of entering first-year college classes. The output is grouped by the value of Gender in the CLASS statement and by the value of Test in the BY statement.
proc sort data=sat_scores out=sorted_scores; by Test; run;
options pageno=1 nodate; ods listing close; 1 ods html file='odshtml-body.htm' 2 contents='odshtml-contents.htm' page='odshtml-page.htm' frame='odshtml-frame.htm'; proc univariate data=sorted_scores; 3 var SATscore; class Gender; by Test; title1 'Average SAT Scores Entering College Classes, 1972-1998*'; footnote1 '* Recentered Scale for 1987-1995'; run; ods html close; 4 ods listing; 5
The following list corresponds to the numbered items in the preceding program:
The following SAS log shows that four HTML files are created with the ODS HTML statement:
Partial SAS Log: HTML File Creation
489 ods listing close; 490 ods html file='odshtml-body.htm' 491 contents='odshtml-contents.htm' 492 page='odshtml-page.htm' 493 frame='odshtml-frame.htm'; NOTE: Writing HTML Body file: odshtml-body.htm NOTE: Writing HTML Contents file: odshtml-contents.htm NOTE: Writing HTML Pages file: odshtml-page.htm NOTE: Writing HTML Frames file: odshtml-frame.htm 494 495 proc univariate data=sorted_scores; 496 var SATscore; 497 class Gender; 498 by Test; 499 title1 'Average SAT Scores Entering College Classes, 1972-1998*'; 500 footnote1 '* Recentered Scale for 1987-1995'; 501 run;
The following output shows the frame file, which displays the table of contents (upper left side), the table of pages (lower left side), and the body file (right side).
View of the HTML Frame File
Both the Table of Contents and the Table of Pages contain links to the results in the body file. If you click on a link in the Table of Contents or the Table of Pages, SAS displays the corresponding results at the top of the browser.
Creating PostScript Output for a High-Resolution Printer |
You can create output that is formatted for a high-resolution printer if you open the Printer destination. Before you can access the file, however, you must close the Printer destination.
The following example executes the MEANS procedure and creates a PostScript file which contains summary statistics for the average SAT scores of entering first-year college students. The output is grouped by the value of Gender in the CLASS statement and the value of Test in the BY statement.
proc sort data=sat_scores out=sorted_scores; by Test; run; options pageno=1 nodate; ods listing close; 1 ods printer ps file='odsprinter_output.ps'; 2 proc means data=sorted_scores fw=8; 3 var SATscore; class Gender ; by Test; title1 'Average SAT Scores Entering College Classes, 1972-1998*'; footnote1 '* Recentered Scale for 1987-1995'; run; ods printer close; 4 ods listing; 5
The following list corresponds to the numbered items in the preceding program:
The following output shows the results:
ODS Output: PostScript Format
Creating RTF Output for Microsoft Word |
You can create output that is formatted for use with Microsoft Word if you open the RTF destination. Before you can access the file, you must close the RTF destination.
The following example executes the UNIVARIATE procedure and creates an RTF file that contains summary statistics for the average SAT scores of entering first-year college students. The output is grouped by the CLASS variable Gender.
ods listing close; 1 ods rtf file='odsrtf_output.rtf'; 2 proc univariate data=sat_scores; 3 var SATscore; class Gender; title1 'Average SAT Scores Entering College Classes, 1972-1998*'; footnote1 '* Recentered Scale for 1987-1995'; run; ods rtf close; 4 ods listing; 5
The following list corresponds to the numbered items in the preceding program:
The following output shows the first page of the RTF output:
ODS Output: RTF Format
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.