Insight Statistical Consulting Ltd
John Kirkpatrick MSc BSc (Hons) CStat CSci

How to find out which style attribute renders each part of your output

You've got the information you want in your output, but now you need to tweak its appearance: perhaps this text needs to be red or that text needs to be bold. But you can't figure out which style element you need to modify.

When I first started to use the ODS and I ran into this situation, I used to spend hours pouring over the various template definitions in SASHELP.TMPLMST and then altering the likely candidates one by one til I struck lucky. It used to take hours.

Fortunately, there is an easier way. I'm eternally grateful to Ian Sedgwick of SAS Institute in Marlow for showing this trick to me.

To get this to work, you need to use a tagset called style_popup. Don't worry, you don't need to know anything about what a tagset is, or how it works. The only slight problem is that tagsets don't ship as part of the default installation for SAS Version 8. But they can be downloaded from the SAS website here. The tagsets are installed in SAS 9 by default, but if for some reason you've lost them they can be found in the same place. Once you've downloaded the file, simply run it as a standard SAS job.

Check that the tagsets.style_popup tagset exists in the SASHELP.TMPLMST template store. (I've written another FAQ to show you how if you need help.)

Now, simply replace your ODS <destination> statement with the following code:

ODS MARKUP TYPE=style_popup FILE="<your-filename>.htm" STYLESHEET="<your-filename>.css";

and your ODS <Destination> CLOSE statement with

ODS MARKUP CLOSE;

Then simply run your program as normal. Then open the <your-filename>.htm file in your usual browser. Here's some example code and output to show you what will happen.

As you move the cursor around the markup file, the background will turn to a revolting shade of pink. Let your cursor hover for a moment. A tooltip will appear. This is the name of the style element that renders this part of the file. Left click. Another window will appear showing the details of the style attributes that come together to define the style element. Now you have all you need to know to get the appearance you want.

I reckon there are 7 styles used in the example file above.

SystemTitle
SystemFooter
Header
RowHeader
ColumnHeader
Data
Table (you may find this one a little hard to find: the cursor will need to be exactly on one of the cell borders.)

 

One thing this doesn't give you is the inheritance structure that leads to the the actual style element definition you see. For that you still need to return to the style definition in the template browser. However, unless you're developing a very complicated and generic style structure, this will be sufficient. Certainly, I've never needed more in the last four years.