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.
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
proc template;
define style newstyle; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
style cellcontents, header, systemtitle /
fontfamily="arial, helvetica"
fontweight=medium
backgroundcolor=blue
fontstyle=roman
fontsize=5
color=white; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
class header /
backgroundcolor=very light blue; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
class systemtitle /
backgroundcolor=white
color=red
fontstyle=italic
fontsize=6; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
style footer from systemtitle /
fontsize=3; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
class table /
cellspacing=5
borderwidth=10;
end;
run; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
ods listing close; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
ods html body="newstyle-body.htm"
style=newstyle; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
title "Leading Grain Producers";
title2 "in 1996"; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
data _null_;
set grain_production;
where type in ("Rice", "Corn") and year=1996; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
file print ods=(
template="table1" |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
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"))
)
); |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
put _ods_;
run; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
ods html close;
ods listing; |
HTML Output
style cell / backgroundcolor=symget("bkgr");
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.