TEMPLATE Procedure: Creating a Style Template (Definition) |
PROC TEMPLATE features: |
DEFINE STYLE statement:
|
STYLE statement with user-defined attributes: |
|
DEFINE TABLE statement:
|
CLASSLEVELS= table attribute |
|
DYNAMIC statement |
|
MVAR
statement | |
|
DEFINE COLUMN statement:
|
BLANK_DUPS= |
|
GENERIC= |
|
HEADER= |
|
STYLE= | | |
DEFINE
COLUMN statement:
|
BLANK_DUPS= attribute |
|
CELLSTYLE-AS statement |
|
GENERIC=
attribute | |
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 equivalent to the
style that Creating a Stand-Alone Style creates. However, this style uses user-defined attributes to specify colors
and fonts. This technique makes it possible to easily make changes in multiple
places in the output.
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
proc template;
define style newstyle2;
style fonts /
"cellfont"=("arial, helvetica", 4, medium roman)
"headingfont"=("arial, helvetica", 5, bold roman)
"titlefont"=("arial, helvetica", 6, bold italic); |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
style colors /
"light"=white
"medium"=cxaaaaff
"dark"=cx0000ff
"bright"=red; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
style cellcontents /
backgroundcolor=colors("dark")
color=colors("light")
font=fonts("cellfont");
style header /
backgroundcolor=colors("medium")
color=colors("dark")
font=fonts("headingfont");
style systemtitle /
backgroundcolor=colors("light")
color=colors("bright")
font=fonts("titlefont");
style footer from systemtitle /
fontsize=3;
style table /
cellspacing=5
borderwidth=10; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
end;
run; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
proc template;
define table table1; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
mvar sysdate9; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
dynamic colhd; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
classlevels=on; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
define column char_var;
generic=on;
blank_dups=on;
header=colhd;
style=cellcontents;
end; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
define column num_var;
generic=on;
header=colhd;
style=cellcontents;
end; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
define footer table_footer;
text "Prepared on " sysdate9;
end; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
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="newstyle2-body.htm"
style=newstyle2; |
![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
In the program Creating a Stand-Alone Style, to change the color
scheme so that the
blues are replaced by pink and red, change each occurrence of "blue"
and "very light blue." In this program, because colors are defined
as user-defined attributes, make the change only once.
To make the color scheme change, change only this section
of code:
style colors /
"light"=white
"medium"=cxaaaaff
"dark"=cx0000ff
"bright"=red;
Change the attributes as follows:
style colors /
"light"=white
"medium"=pink
"dark"=red
"bright"=red;
Similarly, to change the font in any style element that
uses cellfont, change this section of code:
"cellfont"=("arial, helvetica", 4, medium roman)
Here is one example of how to change the code:
"cellfont"=("courier, arial, helvetica", 4, medium roman)
This HTML output shows the results of running the same
program with these changes.
HTML Output with Changed Colors and Fonts
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.