TEMPLATE Procedure: Creating a Style Template (Definition) |
Creates a style for any destination that supports the
STYLE= option.
DEFINE STYLE style-path | Base.Template.Style </
STORE=libref.template-store>;
|
CLASS style-element-name(s)<"text">
</ style-attribute-specification(s)>;
|
|
IMPORT
style-specification<media-type-1 <, ...,
media-type-10>>
|
|
STYLE style-element-name(s) <FROM style-element-name | _SELF_> <"text">
</
style-attribute-specification(s)>;
|
|
DEFINE STYLE Statements
Task |
Statement |
Creates a style element from a style element of the same name |
CLASS
|
Imports Cascading Style Sheet (CSS) information from a file into the
style |
IMPORT
|
Provides information about the style |
NOTES
|
Specifies the style from which the current style inherits its style
elements and attributes |
PARENT=
|
Creates or modifies one or more style elements |
STYLE
|
Ends the style |
END
|
-
style-path
-
specifies where to store the style. A style-path consists of one or more names, separated by periods.
Each name represents a directory in a template store.
PROC TEMPLATE writes the style to the first writable template store in the
current path.
- Base.Template.Style
-
creates a style that is the parent of all styles that do
not explicitly specify a parent. After this template is created, you do
not need to explicitly specify it in your SAS programs. It is automatically
applied to all output until you specifically remove it from the item store.
- CAUTION:
- The Base.Template.Style supplied by SAS contains inheritance
information used by many styles. If this inheritance information is not retained,
some style elements might not appear in the output. To safely create your
own Base.Template.Style, you can start with the existing Base.Template.Style
template by writing it to an external file and editing the existing template
contents.
Interaction: |
The Base.Template.Style master template
attributes are overridden by other style templates. |
Restriction: |
If the PARENT= statement is specified,
then PARENT= must refer to a style other than Base.Template.Style. |
Tip: |
To view an existing style to base your
own Base.Template.Style on, see Viewing the Contents of a Style. |
-
STORE=libref.template-store
-
specifies the template store in which to
store the style. If the template store does not exist, then it is created.
Restriction: |
The syntax of the
STORE= option does not become part of the compiled template. |
Creates a style element from a like-named style element.
Example: |
The following statements are equivalent:
class fonts;
style fonts from fonts;
style fonts from _self_;
|
CLASS style-element-name(s) <"text"> </
style-attribute-specification(s)>;
|
- style-element-name
-
specifies one or more style elements to be duplicated and
modified.
Tip: |
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. |
See: |
style-element-name in the STYLE statement for a complete description. |
See: |
ODS Style Elements for a list of style
elements. |
The following table lists the options that are available for the CLASS
statement. For more detailed descriptions of these options, see the STYLE Statement.
Imports Cascading Style Sheet
(CSS) information from a file into
the style.
Requirement: |
CSS files must be written in the same type
of CSS that the ODS HTML statement produces. Only class names that match ODS
style element names are supported, with no IDs and no context based selectors.
To view the CSS code that ODS creates, you can specify the STYLESHEET= option,
or you can view the source of an HTML file and look at the code between the
tags at the top of the file.
|
Featured in: |
Importing a CSS file
|
IMPORT file-specification <media-type-1<, ...,
media-type-10>>
|
- file-specification
-
specifies a file, fileref, or URL that contains CSS code.
After you import the CSS code, it is converted to style attributes and style
elements that can be used with PROC TEMPLATE.
file-specification is one of the
following:
- "external-file"
-
is the name of the external CSS file.
Requirement: |
You must enclose external-file in quotation
marks. |
- fileref
-
is a file reference that has been assigned to an external
CSS file. Use the FILENAME statement to assign a fileref.
See: |
For information about the FILENAME statement,
see
SAS Language Reference: Dictionary. |
- "URL"
-
is a URL to an external CSS file.
Requirement: |
You must enclose external-file in quotation
marks. |
- media-type-1 <, .. media-type-10>
-
specifies one or more media blocks that correspond to the
type of media on which your output will be rendered. CSS uses media type blocks
to specify how a document is to be presented on different media--for
example, on the screen, on paper, with a speech synthesizer, or with a braille
device.
The media block is added to your output in addition to the CSS code
that is not contained in any media blocks. By using the media-type option, in addition to the general CSS code, you can import
the section of a CSS file intended only for a specific media type.
Default: |
If no media-type
is specified in your ODS statement, but you have specified media types in
your CSS file, then ODS uses the Screen media type. |
Range: |
You can specify up to ten different media
types. |
Requirement: |
You must separate multiple media-types with commas. |
Tip: |
If you specify multiple media types, all
of the style information in all of the media types is applied to your output.
However, if there is duplicate style information in different media blocks,
then the styles from the last media block are used. |
Provides information about the style.
Tip: |
The NOTES statement becomes part of the compiled
style template, which you can view with the SOURCE statement, whereas SAS
comments do not.
|
-
"text"
-
provides information about the style.
Specifies the style from which the current style inherits.
- style-path
-
specifies the style to inherit from.
style-path consists of one or more names,
separated by periods. Each name represents a directory in a template store.
The current style inherits from the specified style in the first readable
template store in the current path.
When you specify a parent, all of the style elements, style attributes,
and statements that are specified in the parent's style template are used
in the current style template unless the current style template overrides
them.
SAS provides some styles. You can specify one of these styles for style-path, or you can specify a user-defined style. These
are some of the styles that are currently shipped with
SAS:
-
styles.default
-
styles.beige
-
styles.brick
-
styles.brown
-
styles.d3d
-
styles.minimal
-
styles.printer
-
styles.statdoc.
For
information about finding an up-to-date list of the styles and for
viewing a style, see
Viewing the Contents of a Style.
Restriction: |
If the PARENT= statement is specified,
then PARENT= must refer to a style other than
Base.Template.Style. |
The
REPLACE statement is no longer supported. Use the STYLE Statement or CLASS Statement
to create and modify style
elements.
Creates or modifies one or more style
elements.
STYLE style-element-name(s)
|
<FROM existing-style-element-name |
_SELF_><"text">
</ style-attribute-specification(s)>;
|
|
-
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.
Tip: |
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. |
Tip: |
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. |
Tip: |
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. |
Tip: |
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. |
Example: |
The following STYLE statement ,
which uses a style element list, is equivalent to STYLE statements -:
1 style data, data1, dataempty from _self_ /
color = red
backgroundcolor = black;
2 style data from data /
color = red
backgroundcolor = black;
3 style data1 from data1/
color = red
backgroundcolor = black;
4 style dataempty from dataempty /
color = red
backgroundcolor = black |
See also: |
style-element-name |
See: |
ODS Style Elements for a list of style elements. |
Featured in: |
Defining Multiple Style Elements in One STYLE Statement |
-
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.
Tip: |
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. |
Tip: |
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. |
Tip: |
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. |
Tip: |
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 Data2 be created from the style element Data1, 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. |
Example: |
The following STYLE statement
is equivalent to STYLE statements -:
1 style data, data1, dataempty from _self_ /
color = red
backgroundcolor = black;
2 style data from data /
color = red
backgroundcolor = black;
3 style data1 from data1 /
color = red
backgroundcolor = black;
4 style dataempty from dataempty /
color = red
backgroundcolor = black |
See: |
ODS Style Elements for a list of style
elements. |
-
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 and Their Values,
or it is the name of a user-defined style attribute.
Restriction: |
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 and Their Values, then do not enclose the
name in quotation marks. |
-
style-attribute-value
-
assigns the value to the attribute. If an
attribute from the list in Style Attributes and Their Values is specified, then specify the kind of value that the attribute expects.
For more information about style-attribute values, see Style Attributes and Their 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. |
Tip: |
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. |
Tip: |
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.
Ends the style.
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.