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?.)
| proc template;
define style newstyle;
style cellcontents /
background=blue
foreground=white
font_face="arial, helvetica"
font_weight=medium
font_style=roman
font_size=4; |
| style header /
background=very light blue
foreground=blue
font_face="arial, helvetica"
font_weight=bold
font_style=roman
font_size=5; |
| style systemtitle /
background=white
foreground=red
font_face="arial, helvetica"
font_weight=bold
font_style=italic
font_size=6; |
| style footer from systemtitle /
font_size=3; |
| style table /
cellspacing=5
borderwidth=10
bordercolorlight=very light blue
bordercolordark=blue; |
| 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 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.
|
|
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.