SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Producing HTML Output
The ODS HTML Statement


To create HTML output, you open the HTML destination using the ODS HTML statement. You can specify up to four HTML files to write to (body files, tables of contents, page descriptions, and frames). The specifications for these files can be
  • the physical name of an external file (with the extension .htm or .html if your operating environment supports these extensions)
  • a fileref (file shortcut) that has been assigned to an external file
  • a SAS catalog entry in the form entry-name.html.

General form, ODS HTML statement:
ODS HTML
       
HTML-file-specification(s)  <option(s)>;

where

  • HTML-file-specification(s) opens the HTML destination and specifies the file to write to. The file remains open until you either specify a new file or close the HTML destination by submitting this form of the ODS HTML statement:

         ODS HTML CLOSE;

    The specifications for these files can be the following:
    BODY=file-specification
    identifies the file that contains the HTML output.

    CONTENTS=file-specification
    identifies a table of contents that links to the body file.

    PAGE=file-specification
    identifies the file that contains a description of each page of the body file and links to the body file.

    FRAME=file-specification
    identifies the file that integrates the table of contents, the page contents, and the body file. If you specify FRAME=, you must specify CONTENTS= or PAGE= or both.
  • <option(s)> include PATH=, which specifies the location for all HTML files, and STYLE=, which specifies the style definition to use in writing the HTML files.


The illustration below shows how a frame file integrates the table of contents and body files. (Page files are not covered in this lesson.)

Frame with TOC and Body File


Example: Creating a Body File

First, let's look at an ODS HTML statement that creates only a body file. Later, we'll see how to create a table of contents and a frame.

Using a simple version of the ODS HTML statement, the program below creates PROC PRINT output in an HTML file. The BODY= option specifies the file F:\admit.html in the Windows environment as the file that contains the PROC PRINT results.

      ods html body='f:\admit.html';
      proc print data=clinic.admit label;
         var sex age height weight actlevel;
         label actlevel='Activity Level';
      run;
      ods html close;

Notice the final ODS HTML statement in the program, which closes the HTML destination. This statement follows the RUN statement for the procedure.

Let's see what the HTML results look like.


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement