PROC TEMPLATE features: |
DEFINE STYLE statement
| STYLE statement
| BACKGROUND= |
| BORDERCOLORDARK= |
| BORDERCOLORLIGHT= |
| BORDERWIDTH= |
| CELLSPACING= |
| FONT_FACE= |
| FONT_SIZE= |
| FONT_STYLE= |
| FONT_WEIGHT= |
| FOREGROUND= | | |
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 definition that is not based on
any other style definition. In general, when you create a style definition,
you are likely to base it on one of the definitions that SAS Institute provides
(see Modifying the Default Style Definition for the HTML Destination).
However, this example is provided to show you some of the basics of creating
a style definition.
It is important to understand that by default, certain table elements
are rendered with certain style elements. For instance, unless you specify
a different style element with the STYLE= attribute, ODS renders SAS titles
with the systemtitle
style element. Similarly,
unless you specify otherwise, ODS renders headers with the header
style element. (For information of what each style
element does, see What Is the Default Style Definition Like?.)
![Note about code](../common/images/snbut.gif) | proc template;
define style newstyle;
style cellcontents /
background=blue
foreground=white
font_face="arial, helvetica"
font_weight=medium
font_style=roman
font_size=4; |
![Note about code](../common/images/snbut.gif) | style header /
background=very light blue
foreground=blue
font_face="arial, helvetica"
font_weight=bold
font_style=roman
font_size=5; |
![Note about code](../common/images/snbut.gif) | style systemtitle /
background=white
foreground=red
font_face="arial, helvetica"
font_weight=bold
font_style=italic
font_size=6; |
![Note about code](../common/images/snbut.gif) | style footer from systemtitle /
font_size=3; |
![Note about code](../common/images/snbut.gif) | style table /
cellspacing=5
borderwidth=10
bordercolorlight=very light blue
bordercolordark=blue; |
![Note about code](../common/images/snbut.gif) | end;
run; |
![Note about code](../common/images/snbut.gif) | proc template;
define table table1; |
![Note about code](../common/images/snbut.gif) | mvar sysdate9; |
![Note about code](../common/images/snbut.gif) | dynamic colhd; |
![Note about code](../common/images/snbut.gif) | classlevels=on; |
![Note about code](../common/images/snbut.gif) | define column char_var;
generic=on;
blank_dups=on;
header=colhd;
style=cellcontents;
end; |
![Note about code](../common/images/snbut.gif) | define column num_var;
generic=on;
header=colhd;
style=cellcontents;
end; |
![Note about code](../common/images/snbut.gif) | define footer table_footer;
text 'Prepared on ' sysdate9;
end; |
![Note about code](../common/images/snbut.gif) | end;
run; |
![Note about code](../common/images/snbut.gif) | ods listing close; |
![Note about code](../common/images/snbut.gif) | ods html body='newstyle-body.htm'
style=newstyle; |
![Note about code](../common/images/snbut.gif) | title 'Leading Grain Producers';
title2 'in 1996'; |
![Note about code](../common/images/snbut.gif) | data _null_;
set grain_production;
where type in ('Rice', 'Corn') and year=1996; |
![Note about code](../common/images/snbut.gif) | file print ods=(
template='table1' |
![Note about code](../common/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/images/snbut.gif) | put _ods_;
run; |
![Note about code](../common/images/snbut.gif) | ods html close;
ods listing; |
HTML Output Produced with a New Style Definition
You can use the colors and fonts to confirm that SAS titles use the systemtitle style element, that column headers use the header style element, that the footer uses the table-footer style element, and that the contents of both
character and numeric cells use the cellcontents
style element. Use the width of the table border, the border colors, and the
spacing between cells to confirm that the table itself is rendered with the table style element.
|
![[HTML Output]](../common/images/outhtml.gif) |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.