TEMPLATE Procedure: Creating a Style Template (Definition) |
PROC TEMPLATE features: |
DEFINE STYLE statement:
|
STYLE statement:
|
FROM option |
|
Style attributes:
|
BACKGROUNDCOLOR= |
|
BORDERWIDTH= |
|
CELLSPACING= |
|
FONTFAMILY= |
|
FONTSIZE= |
|
FONTSTYLE= |
|
FONTWEIGHT= |
|
COLOR= | | | |
DEFINE
TABLE statement:
|
CLASSLEVELS= table attribute |
|
DYNAMIC statement |
|
MVAR statement | |
DEFINE
COLUMN statement:
|
BLANK_DUPS= |
|
GENERIC= |
|
HEADER= |
|
STYLE= | |
DEFINE
FOOTER statement:
|
|
Other ODS features: |
ODS HTML statement |
ODS LISTING statement |
FILE statement with ODS= option |
PUT statement with _ODS_
argument |
|
Data set: |
Grain_Production.
|
Format: |
$CNTRY..
|
Table template: |
Table1.
|
This example creates a style that defines multiple style elements concurrently.
When style element names are specified multiple times, all of the attributes
from all instances of that name are collected to create the final set of style
attributes. Defining multiple style elements in one STYLE statement makes
it possible to create shorter, easier to read programs and to make changes
to style attributes in a single STYLE statement rather than in many STYLE
statements.
For example, if you wanted to add the style element BorderColor=black
to the style elements CellContents, Header, and SystemTitle in the program
below, you could add it once, to the first STYLE statement, instead of adding
it three times, to each individual STYLE statement.
|
proc template;
define style newstyle; |
|
style cellcontents, header, systemtitle /
fontfamily="arial, helvetica"
fontweight=medium
backgroundcolor=blue
fontstyle=roman
fontsize=5
color=white; |
|
class header /
backgroundcolor=very light blue; |
|
class systemtitle /
backgroundcolor=white
color=red
fontstyle=italic
fontsize=6; |
|
style footer from systemtitle /
fontsize=3; |
|
class table /
cellspacing=5
borderwidth=10;
end;
run; |
|
ods listing close; |
|
ods html body="newstyle-body.htm"
style=newstyle; |
|
title "Leading Grain Producers";
title2 "in 1996"; |
|
data _null_;
set grain_production;
where type in ("Rice", "Corn") and year=1996; |
|
file print ods=(
template="table1" |
|
columns=(
char_var=country(generic=on format=$cntry.
dynamic=(colhd="Country"))
char_var=type(generic dynamic=(colhd="Year"))
num_var=kilotons(generic=on format=comma12.
dynamic=(colhd="Kilotons"))
)
); |
|
put _ods_;
run; |
|
ods html close;
ods listing; |
HTML Output
style cell / backgroundcolor=symget("bkgr");
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.