BookmarkSubscribeRSS Feed
ReilingLee
Calcite | Level 5
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.

Thanks,
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
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:
https://support.sas.com/edu/schedules.html?id=256&ctry=US

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:
http://support.sas.com/resources/papers/proceedings09/227-2009.pdf
http://www2.sas.com/proceedings/sugi31/053-31.pdf
http://support.sas.com/resources/papers/proceedings09/014-2009.pdf
http://www2.sas.com/proceedings/sugi27/p186-27.pdf

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:
http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=63120

This book contains a lot of STYLE, TABLE and TAGSET template examples, but has only a few on GRAPH template examples:
http://www.sas.com/apps/pubscat/bookdetails.jsp?catid=1&pc=61686

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.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 720 views
  • 0 likes
  • 2 in conversation