I think REPLACE statement is very useful. It can update a style element and do not affect other style elements. However, it has been removed from SAS 9.2
Here is my question:
How can I substitue REPLACE statement in SAS 9.2
In my opinion, if I want to modify style element A, I have to follow the steps at below:
1. identify what style elements inherit from A.
2. create a new duplicate style element A_dup and switch all inheritance relationship from A to A_dup
3. modify style element A using CLASS statement.
In the documentation for the REPLACE statement, it says that: If you use the REPLACE statement to create a style element in the new style definition, all style elements that inherit from that element inherit the definition that is in the new style definition. If you want to keep any attributes that are specified in the definition that is in the parent, you must respecify them in the definition that you create in the child style definition.
From the 9.1.3 doc as outlined here: http://support.sas.com/rnd/base/early-access/odsdoc2/sashtml/tw5195/z1072349.htm
One reason for using REPLACE in 9.1.3 is that if you used the STYLE statement WITHOUT the correct FROM, inheritance did not cascade down to all the child elements, especially in situations with multiple parent templates involved. The use of REPLACE, especially with respecifying, allowed inheritance to happen after the style changes were applied. For example, if you only needed to change 2 colors in the color list, if you used REPLACE, and only specified the 2 colors, all the other colors in the color list would be undefined and would take on a default value. If you used REPLACE, you had to respecify ALL the colors including the 2 colors you wanted to change.
I'm not clear on why you think that the CLASS statement is -more- work than the REPLACE statement. In prior versions of SAS, you -did- have to trace inheritance. In SAS 9.2, I find that I do NOT have to do much inheritance tracing at all, in order to make my change. I just have to know what the style element is that needs to change. Compare these ways to make the header foreground color purple:
** 9.2 syntax:
style Header /
You should find in SAS 9.2 that every element that inherits from Header will now show a color of purple, no matter which statement form you use. In SAS 9.1.3, different ways of specifying STYLE or REPLACE would have an adverse impact on inheritance -- sometimes you'd get purple, sometimes you wouldn't. That's the reason that REPLACE went away. For more information about the new syntax, refer to: http://www2.sas.com/proceedings/sugi31/053-31.pdf
For help with a specific style template or the conversion of a 9.1.3 style template to a 9.2 style template, you might wish to work with Tech Support. In my experience, when converting from SAS 9.1.3 to SAS 9.2 syntax, my templates got shorter using the CLASS statement.
You say you find it useful to update a style element, but not have an impact on other style elements. That seems to defeat the purpose of having inheritance in the first place. I'm not sure you have an issue with the REPLACE statement. It sounds to me like you need to define an entirely new style element and then point to that style element for the report pieces where you don't want any impact from inheritance.
The fact that you could bypass inheritance depending on whether you used a STYLE statement or a REPLACE statement was considered to be unacceptable/undesirable behavior by most style template writers. So the underlying assumption (in making REPLACE go away) was to make sure that inheritance was resolved in style templates more like the resolution in CSS (Cascading Style Sheets). The intent is to make sure that a child element changes when a parent element changes -- that's the whole point of inheritance.
If you wanted a child element NOT to change when a parent element changed, that would bypass the inheritance entirely. You could accidentally achieve this behavior in earlier versions of SAS -- usually, by using a STYLE statement without a FROM.
I guess I'd do a couple of different things if you needed a PARENT element to have one set of characteristics and wanted the child element to have another set of characteristics. Let's say you have specifically Header and RowHeader. RowHeader inherits from Header. Note that I am picking "concrete" elements -- these are elements whose color changes you can see in the resulting output. It is harder to give a practical example when talking about "abstract" elements like Cell or Container. Since I don't know -specifically- which elements you do or don't want to change, I picked elements that are quickly visible in an output table. Header controls the Header style of the columns going from left to right in the output results. RowHeader controls the style of the rightmost area, where the OBS column is in PROC PRINT or the row headers and class levels are in PROC TABULATE.
The code below shows the following:
1 - Use inheritance to change both Header and RowHeader. Style template only explicitly changes Header.
2 - Change Header colors down in the CLASS statement and point RowHeader to the color list for the original colors.
3 - Change the color_list element, which both Header and RowHeader inherit from -- so Header gets one set of colors and RowHeader gets another set of colors.
4 - Change Header colors directly in the CLASS statement, but point RowHeader to the HeadersandFooters element, which still points to the original colors.
5 - Don't use inheritance at all and define a style template from "scratch" -- this was much harder to do in SAS 9.1.3 -- but is easy to do in SAS 9.2 because you only have to define the style elements you need.
If you need help converting a 9.1.3 style template to a 9.2 style template in order to achieve specific results for a particular destination, your best resource is to open a track with Tech Support.