To show some of what the HTML Tabulate Formatter can do, we start with a SAS program that does not include Tabulate Formatter code. Then, we will describe how we performed the following enhancements to the SAS program:
The example shows how to use the Tabulate Formatter in batch mode, which lets you enter code directly into your SAS program. You can also work with the Tabulate Formatter interactively via windows. For information about working interactively, see Capturing Output Interactively. For an overview of the Tabulate Formatter, review the Overview page.
The example uses PROC TABULATE to provide actual and predicted product sales across different geographical areas. This first example code shows our SAS program without any Tabulate Formatter macro calls. We submitted this code and saved the results to a file. The results output file displays as plain text and contains no HTML formatting.
The easiest way to add HTML formatting to your PROC TABULATE output is to embed the Tabulate Formatter macro calls into the SAS program and use the Tabulate Formatter default properties. These properties provide HTML 2.0 tags as the default properties so that the formatting will be valid on a wider range of browsers. The Tabulate Formatter lets you override these defaults easily to create customized HTML-enhanced output. (In this example we changed the default table alignment and font size.)
For the example, we added two sections of code to the example program that do the following:
To format our output using the default properties, we inserted the following after the TITLE statement in our code:
%tab2htm(capture=on,
runmode=b);
where
capture=onrunmode=bNote: We also added a FORMCHAR option in our PROC TABULATE statement to specify the formatting characters displayed in the output. Formatting characters are used to outline the tabular output. In order for the Tabulate Formatter to work, special form characters must be used. You can choose to either set the FORMCHAR system option or use the FORMCHAR option of PROC TABULATE. To see the code examples, see the discussion of FORMCHAR in Capturing Tabulate Output Interactively.
Every time you turn capturing on, you must include a corresponding capture off statement. When you mark the end of the capture, the Tabulate Formatter creates the HTML file. We left the original SAS code unchanged after marking the start of the capture, then added the following to the end of the file:
%tab2htm(capture=off,
runmode=b,
openmode=replace,
htmlfile=ex2.html,
brtitle=Tabulate Formatter Example,
center=Y,
tsize=+3);
where
capture=offrunmode=bopenmode=replacehtmlfile=ex2.html
brtitle=Tabulate Formatter Examplecenter=Ytsize=+3N, +N, and -N,
where N is an integer. Valid values for N are browser specific. This argument
overrides the font size setting in the property list.Before submitting the program, you must ensure that the Output window contains only output from the TABULATE procedure. If output from any SAS procedure other than TABULATE exists in the Output window, the Tabulate Formatter will fail. If necessary, clear the window before submitting the program.
Look at our modified example code and the resulting HTML file. Some parts of the output appear in a bold font. Remember, these are the default formatting instructions defined by the default properties. (To review definitions of code arguments, see Tabulate Formatter: Macro Syntax Reference.)
For the second enhancement, we changed colors of some elements in the output.
You can use one of the following methods to customize your output:
To create our second enhancement, we added arguments to the Tabulate Formatter macro call. For this enhancement we added custom formatting to our PROC TABULATE output by overriding some default properties and changing the color of the output. (We chose to customize with color because it is easy to see and is valid in most browsers. You could choose to override any property settings.)
It might be easier to follow our changes if you look at the customized output before we discuss the changes. We have also provided our modified example code.
Immediately after PROC TABULATE, we modified the following block of code to mark the end of the capture and specify the custom colors that will be used in our HTML output. We also specified that the table displays as 90 percent of the browser window. The items that differ from the previous enhancement are denoted in bold.
%tab2htm(capture=off,
runmode=b,
openmode=replace,
htmlfile=ex3.html,
brtitle=Tabulate Formatter Example,
center=Y,
tsize=+3,
clcolor=blue,
rlcolor=blue,
twidth=90);
where
clcolor=bluerlcolor=bluetwidth=90PERCENT in the default property list.
The output from PROC TABULATE is written to the specified file and the necessary HTML tags are included so that the colors and table width are used as indicated in your SAS macro call.
Take another look at our customized output to see that our changes do appear in the HTML file as we specified. If you cannot see the color changes that we made, it is because your browser does not support colored text. You can view the document source and see that the HTML tags to change the color are included in the file.
In the next enhancement, we added the following:
Take a look at the customized output first before we discuss the changes. We have also provided our modified example code.
Immediately after PROC TABULATE we modified the following block of code to mark the end of the capture and specify the background image that will be used in our HTML output. The items that differ from the second enhancement are denoted in bold.
%tab2htm(capture=off,
runmode=b,
openmode=replace,
htmlfile=final.html,
brtitle=Tabulate Formatter Example,
center=Y,
tsize=+3,
clcolor=blue,
rlcolor=blue,
twidth=90,
bgtype=image,
bg=marble1.jpg,
encode=N);
where
bgtype=imagebg=marble1.jpgencode=Nencode=N ensures that the Tabulate Formatter
will pass the brackets to the browser (where the browser
will attempt to act on them as an HTML-formatting instruction).
We also included an animated .GIF at the top of the page. We included this statement to produce the image. Bold text denotes the changes.
title '<IMG ALIGN=CENTER SRC=globeanm.gif> World Wide Product Sales Report';
The output from PROC TABULATE is written to the specified file and the necessary HTML tags are included so that the images display.
Take another look at our customized output to see that our changes do appear in the HTML file as we specified.
These samples illustrate how you can enhance SAS code to process PROC TABULATE output and format the results in an HTML table ready for display on the Web. To review the Tabulate Formatter product documentation, return to the HTML Tabulate Formatter main page.