Chapter Contents

Previous

Next
The ODS Statements

Example 7: Appending to HTML Files


ODS features:
ODS HTML statement:
ANCHOR=
BODY= option with a fileref
NO_BOTTOM_MATTER suboption
STYLE=
Other SAS features:
FILENAME statement
PROC PRINT
PROC REPORT
DATA _null_ statement
Data set: GRAIN_PRODUCTION
Format: $CNTRY.

This example creates HTML output from PROC PRINT and PROC REPORT. It also uses the DATA step to write customized HTML to the file that contains the HTML output. The DATA step executes between procedure steps.


Program
 Note about code
filename reports 'external-file';
 Note about code
ods listing close;
 Note about code
ods html body=reports (no_bottom_matter)
 Note about code
         style=D3D;
 Note about code
proc print data=grain_production;
   var country type kilotons;
   format country $cntry. kilotons comma12.;
   where year=1996;
   title 'Leading Grain-Producing Countries';
   footnote 'Measurements are in metric tons.';
run;
 Note about code
ods html close;
 Note about code
filename reports 'external-file' mod;
 Note about code
data _null_;
   file reports;
   put '<h1>The preceding output is from PROC PRINT.';
   put 'I am going to try a variety of procedures.';
   put 'Let me know which procedure you prefer.';
   put 'By the way, this report uses the D3D style.</h1>';
run;
 Note about code
ods html body=reports (no_top_matter no_bottom_matter)
 Note about code
         anchor='report';
 Note about code
proc report data=grain_production nowindows
            headline headskip;
   where year=1996;
   column country type kilotons;
   define country / group width=14 format=$cntry.;
   define type / group 'Type of Grain';
   define kilotons / format=comma12.;
run;
 Note about code
ods html close;
 Note about code
data _null_;
   file reports;
   put "<h1>The preceding output is from PROC REPORT.";
   put "It doesn't repeat the name of the country on every line.";
   put "This report uses the default style.</h1>";
run;
 Note about code
ods html file=reports(no_top_matter) anchor='end';
 Note about code
ods html close;


HTML Output
[HTML Output]


Chapter Contents

Previous

Next

Top of Page

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