TEMPLATE Procedure: Creating a Style Template

STYLE Statement

Creates or modifies one or more style elements.
Restriction: The STYLE statement must be used within a DEFINE STYLE template block.
Creating a Stand-Alone Style

Syntax

Required Argument

style-element-name
specifies one or more style elements to be created or modified. If style-element-name is a new style element, then PROC TEMPLATE stores the style element in the current style. If style-element-name overrides a style element that is a parent of another element, then all of the descendents of style-element-name, including those inherited from parent styles, also inherit the new attributes.
Style element inheritance follows these general guidelines:
  • If a like-named style element already exists in the child style and it is not created by using the FROM option, then the style element in the child style overrides the style element of the same name in the parent style.
  • If a like-named style element already exists in the child style and it is created by using the FROM option, then the style attributes from the parent style element are absorbed into the style element in the child style.
  • If an attribute is defined in a like-named style element in the parent style and it is not explicitly specified in the STYLE statement of the new like-named style element, then the attribute is not inherited, unless you specify the FROM option.
  • If there are multiple identical style element names specified within a style and an attribute is specified more then once, then the value of the last attribute specified is used.
Requirement:Style elements must be separated by commas.
See:ODS Style Elements for a list of style elements
Example:The following STYLE statement uses a style element list:
style data, data1, dataempty from _self_ /  
      color = red         
      backgroundcolor = black;
That statement is equivalent to specifying the following STYLE statements together:
style data  from data /
      color = red
      backgroundcolor = black; 
style data1 from data1/         
      color = red         
      backgroundcolor = black; 
style dataempty from dataempty /         
      color = red         
      backgroundcolor = black

Optional Arguments

FROM existing-style-element-name | _SELF_
specifies that the preceding style-element-name inherit the style attributes from the existing-style-element-name.
existing-style-element-name
specifies the existing style element that another style element inherits from. existing-style-element-name can have the same name as the preceding style-element-name, or it can be the name of another style element. The style element must exist in the current style or in the parent of the current style. Style inheritance using the FROM option follows these general guidelines:
  • If a like-named style element already exists in the child style and it is not created by using the FROM option, then the style element in the child style overrides the style element of the same name in the parent style.
  • If a like-named style element already exists in the child style and it is created by using the FROM option, then the style attributes from the parent style element are absorbed into the style element in the child style.
  • If an attribute is defined in a like-named style element in the parent style and it is not explicitly specified in the STYLE statement of the new like-named style element, then the attribute is not inherited, unless you specify the FROM option.
  • PROC TEMPLATE looks first in the current style for the style element. If PROC TEMPLATE does not find the style element, then it looks in the parent style.
Example:The following statement specifies that the style element Data1 be created from the style element Data2, and that the COLOR=BLACK style attribute be added.
style data1 from data2 / color=black;
_SELF_
specifies that the parent of the style element should have the same name as the new style element.
Tip:The _SELF_ option is most useful when specifying multiple style elements.
See:ODS Style Elements for a list of style elements
Example:The following STYLE statement uses the FROM _SELF_ option:
style data, data1, dataempty from _self_ /
      color = red backgroundcolor = black;
That statement is equivalent to specifying the following STYLE statements together:
style data from  data /
      color = red         
      backgroundcolor = black; 

style data1 from  data1 /
      color = red  
      backgroundcolor = black; 

style dataempty from dataempty /         
      color = red 
      backgroundcolor = black
style-attribute-specification(s)
specifies new style attributes or modifications to existing style attributes for the new style element. Each style-attribute-specification has this general form:
style-attribute-name=<|>style-attribute-value
style-attribute-name
is the name of an attribute that is listed in Style Attributes Tables , or it is the name of a user-defined style attribute.
Tip:If style-attribute-name refers to a user-defined attribute, then enclose the name in quotation marks. If style-attribute-name refers to an attribute that is listed in Style Attributes Tables , then do not enclose the name in quotation marks.
style-attribute-value
assigns the value to the attribute. If an attribute from the table in Style Attributes Tables is specified, then specify the type of value that the attribute expects.
For more information about style-attribute values, see Style Attribute Values.
|
prevents the style attribute from being inherited by any child style elements.
Restriction:If there are multiple style element names specified within a style and an attribute is specified more than once, then the value of the last attribute specified is used.
Tips:Override any attribute of the parent style element, whether it is inherited or explicitly defined, by specifying it in the STYLE statement without the FROM option.

If an attribute is defined in a like-named style element in the parent style and it is not explicitly specified in the STYLE statement of the new like-named style element, then the attribute is not inherited, unless you specify the FROM option.

"text"
provides information about the STYLE statement. Text of this type becomes part of the compiled template, which you can view with the SOURCE statement, whereas SAS comments do not become part of the compiled style.