SAS Institute. The Power to Know

FOCUS AREAS

Return to previous page

Base SAS

Microsoft Theme to PROC TEMPLATE Style Converter

Writing ODS styles has never been considered an easy task. This stems mainly from the fact that a decent style editor doesn't exist. You might be surprised to know that if you use Microsoft Windows XP (or have the Windows Plus! package), you do have a style editor! Since SAS 8.2, ODS has shipped with a style called styles.theme. By default, this theme simply makes your ODS HTML reports look like the color scheme on your desktop, but it actually has a much more colorful history. The styles.theme style was actually created to work with the %THM2TPL macro that converts MS Windows themes to ODS styles.

The %THM2TPL macro actually parses the MS Windows theme file and maps the colors, pictures, and sounds from that theme into an ODS style. See a sample ODS report generated by using the MS Theme called "Nature." Notice that the colors and background image are used. Sounds are also included; try clicking the words "Table of Contents" at the top of the table of contents, or hovering the cursor over the "Note" banner on notes. It is also possible to have the icons appear in the note banner, but that takes some manual intervention because Web browsers don't support the icon image format.

Generating an ODS Style

Using the macro is fairly simple. Just download and run the SAS job that contains the macro, and then execute the macro on your favorite theme with the following syntax:

    %THM2TPL(pathname, style<, SND=n, ICO=n, BG=n>);

The first argument is the path to the theme file. The second argument is the name of the ODS style that will be created. The rest of the arguments are optional boolean arguments that accept either a '1' for true or '0' for false:

SND
indicates whether sound should be included in the ODS style
ICO
indicates whether icons should be included in the ODS style
BG
indicates whether the background image should be included in the ODS style

After you execute this macro, you just specify the STYLE= option on your ODS statement (STYLE=style, substituting the style name that you specified in the second argument to %THM2TPL).

The Nature-themed sample was created with the following command:

    %thm2tpl(nature.theme, nature, snd=1, ico=0, bg=1);

In addition to the ODS style being created in the template store, you will also get a file named nature.tpl. You can modify this file and re-run as desired.


Gotchas!

Here are some issues to watch out for when converting a theme to an ODS style.

Colors

Colors generally work okay, but there is no logic to make sure that the contrast is sufficient to read. You might have to tweak the colors in some themes.

External Files

The macro tries to interpret the paths to background images, sound files, and icons correctly, but sometimes it just doesn't work out. The easiest way to fix this is to simply open the .tpl file that was generated and manually fix the path.

Tagset Incompatibilities

Themes take advantage of some workarounds in tagsets that have to be kept up-to-date with the %THM2TPL macro. Since tagsets were a moving target between SAS 8.2 and 9, you may have an incompatible tagset in your current library. If things don't seem to be working correctly, copy the updated tagset code from the file theme.tpl and run it.


Creating and Downloading Themes

Starting with Windows XP, you can use your Display control panel applet to create themes. Simply set up the colors and background image to your liking and save the settings as a theme. Then run the %THM2TPL macro on that theme.

Another option is to simply download themes created by others at Web sites like ThemeWorld.com or ThemeXP.org.


Understanding ODS Styles

For more examples of styles generated from MS Windows themes, plus an introduction to ODS styles presentation given by Kevin D. Smith, see ODS Styles: Escaping PROC TEMPLATE Purgatory.


Feedback

Send e-mail to ods@sas.com with your comments.