TEMPLATE Procedure: Creating a Style Template (Definition) |
PROC TEMPLATE features: |
DEFINE STYLE statement:
|
STYLE statement:
|
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..
|
This example creates a style that is not based on any
other style. When you create a style, you will usually base it on one of the
styles that SAS provides (see Using the CLASS Statement).
However, this example is provided to show you some of the basic ways to create
a style.
It is important to understand that by default, certain
table elements are created with certain style elements. For example, unless
you specify a different style element with the STYLE= attribute, ODS produces
SAS titles with the SystemTitle style element. Similarly, unless you specify
otherwise, ODS produces headers with the Header style element. (For information
about each style element, see
ODS Style Elements.
|
proc template;
define style newstyle;
style cellcontents /
fontfamily="arial, helvetica"
fontweight=medium
backgroundcolor=blue
fontstyle=roman
fontsize=5
color=white |
|
style header /
backgroundcolor=very light blue
fontfamily="arial, helvetica"
fontweight=medium
fontstyle=roman
fontsize=5
color=white; |
|
style systemtitle /
fontfamily="arial, helvetica"
fontweight=medium
backgroundcolor=white
fontstyle=italic
fontsize=6
color=red; |
|
style footer from systemtitle /
fontsize=3; |
|
style table /
cellspacing=5
borderwidth=10; |
|
end;
run; |
|
proc template;
define table table1; |
|
mvar sysdate9; |
|
dynamic colhd; |
|
classlevels=on; |
|
define column char_var;
generic=on;
blank_dups=on;
header=colhd;
style=cellcontents;
end; |
|
define column num_var;
generic=on;
header=colhd;
style=cellcontents;
end; |
|
define footer table_footer;
text "Prepared on " sysdate9;
end; |
|
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
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.