Chapter Contents

Previous

Next
The ODS Statements

Example 5: Creating a Separate Body File for Each Page of Output


ODS features:
ODS HTML statement:
BASE=
CLOSE
NEWFILE=
Other SAS features:
PROC FORMAT
PROC SORT
PROC TABULATE
NOBYLINE|BYLINE system option
#BYVAL parameter in titles

This example creates a separate HTML file for each page of procedure output. The table of contents and table of pages do not appear any different or behave any differently from those that would be created if all the output were in a single file. Because the output is in separate files, you cannot scroll from one page of output to the next. However, you can select individual HTML files to include in a report.

Note:   This example uses file names that may not be valid in all operating environments. To successfully run the example in your operating environment, you may need to change the file specifications. See Alternative ODS HTML Statements for Running Examples in Different Operating Environments.  [cautionend]


Program
 Note about code
data grain_production;
   length Country $ 3 Type $ 5;
   input Year country $ type $ Kilotons;
   datalines;
1995 BRZ  Wheat    1516
1995 BRZ  Rice     11236
1995 BRZ  Corn     36276
1995 CHN  Wheat    102207
1995 CHN  Rice     185226
1995 CHN  Corn     112331
1995 IND  Wheat    63007
1995 IND  Rice     122372
1995 IND  Corn     9800
1995 INS  Wheat    .
1995 INS  Rice     49860
1995 INS  Corn     8223
1995 USA  Wheat    59494
1995 USA  Rice     7888
1995 USA  Corn     187300
1996 BRZ  Wheat    3302
1996 BRZ  Rice     10035
1996 BRZ  Corn     31975
1996 CHN  Wheat    109000
1996 CHN  Rice     190100
1996 CHN  Corn     119350
1996 IND  Wheat    62620
1996 IND  Rice     120012
1996 IND  Corn     8660
1996 INS  Wheat    .
1996 INS  Rice     51165
1996 INS  Corn     8925
1996 USA  Wheat    62099
1996 USA  Rice     7771
1996 USA  Corn     236064
;
 Note about code
proc sort data=grain_production;
   by year country type;
run;
 Note about code
proc format;
   value $cntry 'BRZ'='Brazil'
                'CHN'='China'
                'IND'='India'
                'INS'='Indonesia'
                'USA'='United States';
run;
 Note about code
ods listing close;
 Note about code
ods html file='grain-body.htm'
     contents='grain-contents.htm'
        frame='grain-frame.htm'
         page='grain-page.htm 
         base='http://www.yourcompany.com/local-address/'
 Note about code
     newfile=page;
 Note about code
options nobyline;
title 'Leading Grain-Producing Countries';
title2 'for #byval(year)';
 Note about code
proc report data=grain_production nowindows
     headline headskip;
   by year;
   column country type kilotons;
   define country  / group width=14 format=$cntry.;
   define type     / group 'Type of Grain';
   define kilotons / format=comma12.;
   footnote 'Measurements are in metric tons.';
run;
 Note about code
options byline;
title2;
 Note about code
proc tabulate data=grain_production format=comma12.;
   class year country type;
   var kilotons;
   table year, 
         country*type, 
         kilotons*sum=' ' / box=_page_ misstext='No data';
   format country $cntry.;
   footnote 'Measurements are in metric tons.';
run;
 Note about code
ods html close;
ods listing;


HTML Output
This frame file shows the first body file. Links in the table of contents and the table of pages point to the other body files. [HTML Output]


Links Created in the HTML Output

These HREF= attributes from the links in the contents file point to the HTML tables that ODS creates from the PROC REPORT and PROC TABULATE steps.

HREF="http://www.yourcompany.com/local-address/grain-body.htm#IDX"
HREF="http://www.yourcompany.com/local-address/grain-body1.htm#IDX1"
HREF="http://www.yourcompany.com/local-address/grain-body2.htm#IDX2"
HREF="http://www.yourcompany.com/local-address/grain-body3.htm#IDX3"

Notice how these HREF attributes are constructed:


Chapter Contents

Previous

Next

Top of Page

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