Previous Page | Next Page

Dictionary of ODS Language Statements

ODS HTML Statement



Opens, manages, or closes the HTML destination, which produces HTML 4.0 output that contains embedded style sheets.
Valid: anywhere
Category: ODS: Third-Party Formatted
Restriction: When you open the destination, a style sheet is written and linked to the body file. Therefore, you cannot make style sheet changes from within your SAS program. For example, after the destination is open, changing the value of the STYLE= option has no effect. You can make style changes in either of the following ways:
  • Close the destination, edit or create a new style sheet, and submit the program again specifying the new or modified style sheet.

  • Edit the body file, changing the style sheet url to the desired style sheet.

Interaction: By default, when you execute a procedure that uses the FORMCHAR system option (for example, PROC PLOT or PROC CHART), ODS formats the output in SAS Monospace font. If you are creating output that will be viewed in an operating environment where SAS software is not installed, this output will not display correctly because without SAS, the SAS Monospace font is not recognized. To make your document display correctly, include the following statement before your SAS program:
OPTIONS FORMCHAR="|----|+|---+=|-/\<>*"; 
Operating Environment Information: If you use graphics that are created with either the ACTXIMG or JAVAIMG device drivers in the z/OS operating environment, then specify either the GPATH= or the PATH= option in the ODS HTML statement.

Syntax
Without an Action or Options
Actions
Options
Details
Examples
Example 1: Creating a Separate Body File for Each Page of Output
Example 2: Appending to HTML Files
See Also

Syntax

ODS HTML <(<ID=>identifier)> <action>;
ODS HTML <(<ID=>identifier)><option(s)>;


Without an Action or Options

If you use the ODS HTML statement without an action or options, then it opens the HTML destination and creates HTML output.


Actions

The following table lists the actions available for the ODS HTML statement. For complete descriptions of actions see Actions in the ODS MARKUP statement.

ODS HTML Action Summary Table
Task Action
Close the HTML destination and the file that is associated with it CLOSE
Exclude output objects from the HTML destination EXCLUDE
Select output objects for the HTML destination SELECT
Write to the SAS log the current selection or exclusion list for the HTML destination SHOW


Options

The following table lists the options that are available for the ODS HTML statement, which is part of the markup family of statements. For complete descriptions of these options, see Options in the ODS MARKUP statement.

ODS HTML Option Summary Table
Task Option
Specify a unique base name for the anchor tag that identifies each output object in the current body file ANCHOR=
Specify which applet to use to view ODS HTML output ARCHIVE=
Specify attributes to write between the tags that generate dynamic graphics output ATTRIBUTES=
Specify text to use as the first part of all links and references that ODS creates in output files BASE=
Open a markup family destination and specify the file that contains the primary output that is created by the ODS statement BODY=
Specify the character set to be generated in the META declaration for the HTML output CHARSET=
Open the HTML destination and specify that the file that contains relevant style information CODE=
Create a file path that can be used by the GOPTIONS devices CODEBASE=
Open the HTML destination and specify the file that contains a table of contents for the output CONTENTS=
Specify a cascading style sheet to apply to your output CSSSTYLE=
Specify a device for the HTML output destination DEVICE=
Override the encoding for input or output processing (transcodes) of external files ENCODING=
Specify an event and the value for event variables that is associated with the event EVENT=
Specify the file that integrates the table of contents, the page contents, and the body file FRAME=
Control the location where footnotes are printed in the graphics output GFOOTNOTE | NOGFOOTNOTE
Specify the location for all graphics output that is generated while the destination is open GPATH=
Control the location where titles are printed in the graphics output GTITLE | NOGTITLE
Specify HTML tags to place between the <HEAD> and </HEAD> tags in all the files that the destination writes to HEADTEXT=
Open multiple instances of the same destination at the same time ID=
Specify HTML code to use as the <META> tag between the <HEAD> and </HEAD> tags in all the HTML files that the destination writes to METATEXT=
Create a new body file at the specified starting point. Opens a markup family destination and specifies the file that contains a description of each page of the body file, and contains links to the body file NEWFILE=
Specify tagset-specific suboptions and a named value OPTIONS
Specify that the output from the destination be added to an ODS package PACKAGE
Open the HTML destination and specify the file that contains a description of each page of the body file, and contains links to the body file PAGE=
Write the specified parameters between the tags that generate dynamic graphics output PARAMETERS=
Specify the location of an aggregate storage location or a SAS catalog for all markup files PATH=
Specify an alternative character or string to separate lines in the output files RECORD_SEPARATOR=
Specify a style definition to use in writing output files STYLE=
Open the HTML destination and place style information for output into an external file, or read style sheet information from an existing file STYLESHEET=
Insert text into your document TEXT=
Insert into the metadata of a file, a text string that you want to specify as the text to appear in the browser window title bar TITLE=
Specify a translation table to use when transcoding a file for output TRANTAB=


Details

The ODS HTML statement is part of the ODS markup family of statements. ODS statements in the markup family produce output that is formatted using one of many different markup languages such as HTML (Hypertext Markup Language), XML (Extensible Markup Language), and LaTeX. You can specify a markup language that SAS supplies, or create one of your own and store it as a user-defined markup language.


Examples


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

ODS features:

ODS HTML statement:

Action:

CLOSE

Arguments:

CONTENTS=

BODY=

FRAME=

PAGE=

Options:

BASE=

NEWFILE=

Other SAS features:

#BYVAL parameter in titles

NOBYLINE|BYLINE system option

OPTIONS statement

PROC FORMAT

PROC SORT

PROC REPORT

PROC TABULATE

TITLE statement

Data set:

Grain_Production .

Format:

$CNTRY. .


Program Description

The following example creates a separate HTML file for each page of procedure output, as well as a table of contents, a table of pages, and a frame file. 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 filenames that might not be valid in all operating environments. To successfully run the example in your operating environment, you might need to change the file specifications. See ODS HTML Statements for Running Examples in Different Operating Environments.  [cautionend]


Program

 Note about code
proc sort data=grain_production;
   by year country type;
run;
 Note about code
ods listing close;
 Note about code
ods html body='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;
   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;

HTML Output

HTML Frame File

 Note about figure

[HTML Frame File]


Links That Are 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:


Example 2: Appending to HTML Files

ODS features:

ODS HTML statement:

Argument:

BODY= with a fileref

NO_BOTTOM_MATTER suboption

NO_TOP_MATTER suboption

Options:

ANCHOR=

STYLE=

Other SAS features:

FILENAME statement

PROC PRINT

PROC REPORT

DATA _NULL_ statement

Data set:

Grain_Production .

Format:

$CNTRY. .


Program Description

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


Program

 Note about code
ods listing close;
options obs=10;
 Note about code
filename reports 'GrainReport.html';
 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 'GrainReport.html' mod;
 Note about code
data _null_;
   file reports;
   put "<h2>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.</h2>";
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;
   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 "<h2>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.</h2>";
run;
 Note about code
ods html body=reports(no_top_matter)anchor='end';
 Note about code
ods html close;

HTML Output

HTML Output with Appended HTML

 Note about figure

[HTML Output with Appended HTML]


See Also

Statements:

ODS MARKUP Statement

ODS and the HTML Destination

Previous Page | Next Page | Top of Page