Formatting Your Results

Using Page Formats

The HTML Formatting Tools create valid HTML page formats without requiring you to know what they are. However, as browsers and scripting continue to evolve, and Web users start demanding more from their Web pages, you may want more flexibility in how the page format is written in each file you create. For this reason, the Formatters include some syntax arguments that offer you the flexibility to control these formats.

Before we go any further in describing the types of customization you can perform. Let's define what we mean by page formats. The page format includes the following:

Controlling the Use of DOCTYPE

You can control the use and contents of the <DOCTYPE> header element by specifying the DOCTYPE argument when you invoke any of the Formatters. By default, the Formatters write the following line to the top of your HTML file:

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

To add text for DOCTYPE other than the default text, you must provide the exact text that you want added. For example, if you want to reference a different DTD, you must provide the entire string, including !DOCTYPE and the opening and closing angle brackets. If you do not want <DOCTYPE> added to your file at all, include DOCTYPE= when you invoke a Formatter.


Controlling the Use of Headers and Footers

In almost all cases, you want your file to include the HTML header and footer. What you don't want is for these tags to be included in the middle of an HTML file. This can happen when you append the resulting HTML output to an existing file.

To avoid getting the header and footer tags in the middle of your HTML file, use the PAGEPART argument. The default behavior of the PAGEPART argument is to write the HTML header information, your SAS data or output, and the HTML footer information to the file. This is the behavior you want if you are creating a new file or replacing the contents of an existing file and you are not appending more information to this file once it is created.

The PAGEPART argument also allows you to include:

For example, the Formatter invocations in your SAS program might look like the following:

   %ds2htm(htmlfile=myfile.html,
           openmode=replace,
           runmode=b,
           doctype=3.2,
           pagepart=head,
           data=monthly,
           where=year eq 1996,
           caption=Information for 1996);
 
   <some code omitted>

   %out2htm(htmlfile=myfile.html,
            capture=off,
            window=output,
            openmode=append,
            pagepart=body,
            runmode=b,
            tcolor=red,
            hcolor=blue);

   <more code omitted>

   %ds2htm(htmlfile=myfile.html,
           openmode=append,
           pagepart=foot,
           data=monthly,
           obsnum=y,
           where=year lt 2000,
           var=year month begpri payment int repay endpri,
           sum=payment int repay,
           caption=Information prior to the year 2000);

Adding Information to the Header

In addition to controlling the <DOCTYPE>, <HTML>, and <BODY> tags, the HTML Formatters give you the ability to include style sheet and script information. You can link to or embed style sheet information using the following tags:

The ssfile1-ssfile5 and ssfref1-ssfref5 arguments instruct the Formatters to collect the text contained in the specified file and write that text between the <HEAD> and </HEAD> tags exactly as it appears in the referenced file. Using these arguments, you can include any text you want into your HTML file.

For example, you may want to include the following types of information: