proc template;
source styles.template-name;
run;
proc template; define style concepts.style; style celldata / fontfamily="roman, arial" color=blue fontweight =bold "dark"=black; style cellemphasis from celldata / color=celldata("dark") borderspacing=10; end; run;
1 | Concepts.Style is a style. Styles describe how to display presentation aspects (color, font, font size, and so on) of the output for an entire SAS job. A style determines the overall appearance of the ODS documents that use it. Each style consists of style elements. Styles are created with the DEFINE STYLE Statement. New styles can be created independently or from an existing style. You can use the PARENT= Statement to create a new style from an existing style. |
2 | CellData
and CellEmphasis are style elements. A style
element is a collection of style attributes that apply to a particular
part of the output for a SAS program. For example, a style element
might contain instructions for the presentation of column headings
or for the presentation of the data inside table cells. Style elements
might also specify default colors and fonts for output that uses the
style. Style elements exist inside of styles and are defined by the STYLE Statement.
Note: For a list of the default
style elements used for HTML and markup languages and their inheritance,
see ODS Style Elements.
|
3 | The
following are style attribute-value pairs:
blue for the foreground color
of a table, and the FONTFAMILY= attribute specifies the values roman and arial as
the font to use. Style attributes exist within style elements and
can be supplied by SAS or be user-defined. FONTFAMILY=, COLOR=, FONTWEIGHT=,
and BORDERSPACING= are style attributes supplied by SAS. For a list
of style attributes supplied by SAS, see Style Attributes Tables . |
4 | "Dark"
is a user-defined style attribute. It specifies
to substitute the value black whenever
the value "dark" is specified.
|
5 | The
value celldata("dark") is a style
reference. Style attributes can be referenced with style
references. This style reference specifies that PROC TEMPLATE go to
the CellData style element and use the value that is specified for
the "dark" style attribute. See style-reference for more information about style references.
|
define style style1;
style fonts /
"docfont" = ("Arial", 3)
"tablefont" = ("Times", 2);
style output /
cellpadding = 5
borderspacing = 0
font = fonts("docfont");
style table from output /
borderspacing = 2
font = fonts("tablefont");
style header /
backgroundcolor=white
color=blue
fontfamily="arial, helvetica"
fontweight=bold;
end;
define style style2;
parent = style1;
style fonts from fonts /
"docfont" = ("Helvetica", 3);
style table from table /
borderspacing = 4;
style header /
fontstyle=roman
fontsize=5;
end;
define style style2;
style fonts/
"docfont" = ("Helvetica", 3)
"tablefont" = ("Times", 2);
style output /
cellpadding = 5
borderspacing = 0
font = fonts("docfont");
style table from output /
borderspacing=4
font = fonts("tablefont");
style header /
fontstyle=roman
fontsize=5;
end;
style table from output / ...,
statement,
ends up with the following style attributes:
style datacell / backgroundcolor=blue color=white;To ensure that another style element, NewCell, uses the same background color, use a style reference in the NewCell element, like this:
style newcell / backgroundcolor=datacell(backgroundcolor);
The
style reference datacell(backgroundcolor)
indicates
that the value for the style attribute BACKGROUNDCOLOR= of the style
element named DataCell should be used.
style highlighting / "go"=green "caution"=yellow "stop"=red;You can then define a style element named Messages that references the colors that are defined in the HighLighting style element:
style messages; "note"=highlighting("go") "warning"=highlighting("caution") "error"=highlighting("stop");Because you used style references, multiple style elements can use the colors defined in the HighLighting style element. If you change the value of
go
to blue
in
the HighLighting style element, then every style element that uses
the style reference highlighting("go")
will
use blue instead of green.
fonts("docfont")
tells
PROC TEMPLATE to go to the last instance of the style element named
Fonts and use the value for the style attribute DocFont.
fonts("tablefont")
tells
PROC TEMPLATE to go to the last instance of the style element named
Fonts and use the value for the style attribute TableFont.
define style style1; style fonts / "docfont" = ("Arial", 3) "tablefont" = ("Times", 2); style output / cellpadding = 5 borderspacing = 0 font = fonts("docfont"); style table from output / borderspacing = 2 font = fonts("tablefont"); style header / backgroundcolor=white color=blue fontfamily="arial, helvetica" fontweight=bold; end; define style style2; parent = style1; style fonts from fonts / "docfont" = ("Helvetica", 3); style table from table / borderspacing = 4; style header / fontstyle=roman fontsize=5; end;
("helvetica", 3)
, not ("Arial",
3)
. This is because the "DocFont" user-supplied style
attribute in the Style2 style overrides the like-named style attribute
in the Style1 style.
define style style1; style fonts / "docfont" = ("Arial", 3) "tablefont" = ("Times", 2); style output / cellpadding = 5 borderspacing = 0 /*** Resolved from "docfont" in Style2***/ font = fonts("helvetica", 3); style table from output / borderspacing = 2 /*** Resolved from "tablefont" in Style1***/ font = fonts("Times", 2); style header / backgroundcolor=white color=blue fontfamily="arial, helvetica" fontweight=bold; end; define style style2; parent = style1; style fonts from fonts / "docfont" = ("Helvetica", 3); style table from table / borderspacing = 4; style header / fontstyle=roman fontsize=5; end;
"dark"=dark
blue
.
"dark"
style attribute.
Style references in Concepts.Style1 and Concepts.Style2 such as colors("fancy")
and colors("medium")
do
not resolve because they refer to attributes that were not copied
into the current instance of the Colors style element. The resulting
output is Output Created without the FROM Option. style colors from colors / "dark"=dark blue;
proc template; define style concepts.style1; style colors / "default"=white "fancy"=very light vivid blue "medium"=red ; style celldatasimple / fontfamily=arial backgroundcolor=colors("fancy") color=colors("default"); style celldataemphasis from celldatasimple / color=colors("medium") fontstyle=italic; style celldatalarge from celldataemphasis / fontweight=bold fontsize=3; end; run; proc template; define style concepts.style2; parent=concepts.style1; style colors / "dark"=dark blue; style celldataemphasis from celldataemphasis / backgroundcolor=white; style celldatasmall from celldatalarge / fontsize=5 color=colors("dark") backgroundcolor=colors("medium"); end; run;
proc template; define style concepts.style1; style celldatasimple / fontfamily=arial backgroundcolor=very light vivid blue color=white; style celldataemphasis from celldatasimple / color=red1 fontstyle=italic; style celldatalarge from celldataemphasis / fontweight=bold fontsize=5; end; run; proc template; define style concepts.style2; parent=concepts.style1; style celldataemphasis from celldataemphasis3/ backgroundcolor=yellow2; style celldatasmall from celldatalarge / fontsize=2; end; run;