The SAS Output Delivery System and reporting techniques

Class and Replace

New Contributor
Posts: 3

Class and Replace

I am not too familiar with PROC TEMPLATE. Can you let me know why sometimes people use CLASS instead of REPLACE when modifying an existing style?

Also, what would be a good document or class to learn TEMPLATE language? So far, I know you can use PROC TEMPLATE to define style, table, graph, tagsets, etc.

Posts: 9,368

Re: Class and Replace

Posted in reply to ReilingLee
When ODS was first introduced, STYLE templates used only 2 primary statements: the STYLE statement and the REPLACE statement. This occurred because template level inheritance and style element inheritance worked slightly differently when you used a STYLE statement from when you used a REPLACE statement.

In SAS 9.2, the REPLACE statement is no longer a valid statement for use with STYLE templates. In SAS 9.2, a STYLE template can use either a STYLE statement or a CLASS statement.

Programmers who used the REPLACE statement in earlier versions of SAS should find that the REPLACE statement acts just like a STYLE statement, for most situations.

In earlier versions of SAS, you needed to know more about inheritance when you wrote or modified a STYLE template. In SAS 9.2, you only need to know the name of the style element you want to change, because the inheritance model for style elements is contained in an implicit parent template, BASE.TEMPLATE.STYLE, which lives in the SASHELP.TMPLMST item store.

In our Advanced ODS Topics class, we discuss both TABLE templates and STYLE templates. The desciption of that class is here:

If you are only interested in STYLE templates, you will probably find a search of user group papers yields a number of hits that explain how style (and other) templates work. Here are a few to get you started:

The first things you need to figure out are: What version of SAS are you using (9.1.3 or SAS 9.2)? Are you also using SAS Enterprise Guide? (SAS Enterprise Guide has a built-in style editor that creates CSS files which are (sort of) the equivalent of a SAS style template.) In SAS 9.1.3, you could use the EG generated CSS files with ODS HTML. In SAS 9.2, if you did not want to work with STYLE templates, you could design a CSS file with EG and then use the CSS file with ODS HTML, RTF and PDF via the CSSSTYLE= option.

Right now, most people change STYLE and TABLE templates. Rarely do you need to modify or create your own TAGSET template -- unless you are generating custom XML from SAS using either ODS or the SAS XML Libname engine. GRAPH templates were experimental in SAS 9.1.3 and are production in SAS 9.2 -- if you are interested in GRAPH templates, there is a new book by Warren Kuhfeld on the topic:

This book contains a lot of STYLE, TABLE and TAGSET template examples, but has only a few on GRAPH template examples:

The thing about PROC TEMPLATE is that PROC TEMPLATE doesn't follow a single syntax model -- there's one form of syntax for every template type.

I find the best way to work with templates is to decide what type of template you need to change -- and then look for models or samples of changing that template type. Work with the sample program until you understand it and then start to modify the template.

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation