Select Your Region
Americas
Europe
Middle East & Africa
Asia Pacific
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
This example shows you how style sheet classes are applied to elements in the HTML file created by the formatting tools. The explanation that follows describes how the formatting was achieved. It does not explain all of the steps necessary to write a SAS program that produces these results.
This example consists of the following three parts:
You can also use style sheets with the Output Formatter; however, no example is provided. For more information, see Using Style Sheets.
First you need to create your style sheet. If you have an existing style sheet, you might need to update it to include some information specific to your data. Take a look at the style sheet used for this example. It includes classes that are named for values in the data. You can use these classes with any of your output. You do not have to use them only when they match the values in your data.
In this part of the example, style sheet classes are used to
The following code is the Data Set Formatter invocation used to produce the first section of this example:
%ds2htm(data=report, htmlfile=exstyle.html, openmode=replace, pagepart=head, /* new argument in V1.2 */ brtitle=Style Sheet Example, twidth=75, twunits=percent, border=n, cpad=0, cspace=0, ihalign=left, vhalign=right, ttag=header 3, ftag=header 3, rowssvar=_break_, /* new argument in V1.2 */ ssfile1=css.txt, /* new argument in V1.2 */ clclass=gray, /* new argument in V1.2 */ id=country region prodtype product, var=actual percent, by=c, where=c eq 'U.S.A.');
This invocation includes the following arguments, which enable you to format output using classes defined in a style sheet:
SSFILE1=CSS.TXT, which tells the formatter to locate a file named css.txt and embed the contents of the file before the end head tag (</HEAD>
) in the resulting HTML file. When you embed style sheet information, you must ensure that the file contains all the necessary style information.
ROWSSVAR=_BREAK_, which instructs the formatter to add CLASS=VALUE to each row in the table that contains a value for the variable named _BREAK_. If _BREAK_ is not present, the CLASS= attribute is not added to the table row tag <TR>
). For this process to work, the style sheet must include class definitions that match each of the values of _BREAK_. In css.txt, the class definitions that represent values in the data are
The style sheet includes other elements that affect the formatting of the resulting HTML file, such as the H3, TH, and TD definitions. For information on how these work, refer to your style sheet documentation.
For this example, use the same PROC TABULATE code used in the previous Tabulate Formatter example. However, this time add style sheet support.
In this portion of the example, style sheet support enhances the output. Most of the formatting can also be accomplished without using style sheets. However, because this example uses style sheets, you can change the appearance of the output by changing the class definitions. (Note: If you link to the style sheet instead of embedding it, you can change the appearance of all of the HTML files that use the style sheet by changing only the style sheet file.)
The following code is the Tabulate Formatter invocation used to produce the second section of this example:
%tab2htm(capture=off, runmode=b, openmode=append, htmlfile=exstyle.html, pagepart=foot, ttag=header 3, ftag=header 3, twidth=90, encode=N, tbclass=beige, /* style sheet argument */ bxclass=gray, /* style sheet argument */ bxhalign=center, bxvalign=middle, clclass=teal, /* style sheet argument */ rlclass=teal); /* style sheet argument */
This invocation includes arguments that enable you to format output using classes defined in a style sheet, as follows:
TBCLASS=BEIGE, which specifies that CLASS=BEIGE be included in the TABLE
tag.
BXCLASS=GRAY, which instructs the formatter to add CLASS=GRAY to the TD
tag for the box cell in the table. If your Web browser supports images in table cells, you might include an image in this cell using the BXCLASS= argument.
CLCLASS=TEAL, which instructs the formatter to add CLASS=TEAL to the TH
tag for all of the column labels.
RLCLASS=TEAL, which instructs the formatter to add CLASS=TEAL to the TH
tag for all of the row labels.
Note: This invocation does not include information about which style sheet to use. This information is appended from the Tabulate Formatter to the file created earlier for the Data Set Formatter output.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.