TEMPLATE Procedure: Creating a Style Template (Definition) |
PROC TEMPLATE features: |
DEFINE STYLE statement:
|
CLASS statement: |
|
PARENT= statement: |
|
Style attributes:
|
User-defined
attributes |
|
BACKGROUNDCOLOR= |
|
BORDERWIDTH= |
|
CELLPADDING= |
|
CELLSPACING= |
|
COLOR= |
|
FONT= |
|
FONTSTYLE= |
|
FRAME= |
|
POSTHTML= |
|
RULES= |
|
VISITEDLINKCOLOR= | | |
|
Other ODS features: |
ODS HTML statement:
|
ODS LISTING statement |
ODS PATH
statement |
|
Data set: |
Energy.
|
Formats: |
DIVFMT. and USETYPE..
|
When you are working with styles, you are more likely
to modify a SAS style than to write a completely new style. This example makes
changes to the default style for the HTML destination. The new style affects
both the contents file and the body file in the HTML output. In the contents
file, the modified style makes changes to the following:
-
the text of the header and the text that identifies
the procedure that produced the output
-
the colors for some parts of the text
-
the font size of some parts of the
text
-
the spacing in the list of entries in the table
of contents.
In the body file, the modified style makes changes to the
following:
-
two of the colors in the color list. Style1 of
these colors is the foreground color for the table of contents, the byline,
and column headings. The other is the foreground of many parts of the body
file, including SAS titles and footnotes.
-
the font size for titles and footnotes
-
the font style for
headers
-
the presentation of the data in the table by changing
attributes such as cellspacing, rules, and border width.
When you modify a style element in a new style that
has a like-named style element in the parent style, then you must use the
CLASS statement or the STYLE statement with the FROM option specified. This
example uses the CLASS statement to produce a shorter, easier to read program.
|
ods path sasuser.templat(update) sashelp.tmplmst(read); |
|
ods listing close; |
|
ods html body="sasdefaultstyle-body.htm"
contents="sasdefaultstyle-content.htm"
frame="sasdefaultstyle-frame.htm"
style=styles.default; |
|
title "Energy Expenditures for Each Region";
title2 "(millions of dollars)"; |
|
proc print data=energy noobs;
var state type expenditures;
format division divfmt. type usetype. expenditures comma12.;
by division;
where division=2 or division=3;
run; |
|
ods html close;
ods listing; |
HTML Output from PROC PRINT Using the Default Style
|
proc template;
define style customdefault; |
|
parent=styles.default; |
|
class color_list/
/* changed from cxD3D3D3*/
"bgA3" = #778899
/* changed from cx0033AA */
"fgA2" = #68228b
/* changed from cxB0B0B0 */
"bgA2" = #fff8dc
/* changed from cx000000 */
"fgA1" = #fff8dc
/* changed from cxE0E0E0 */
"bgA" = #c6e2ff; |
|
class titlesandfooters/
color=colors("systitlefg")
backgroundcolor=colors("systitlebg")
font=fonts("titlefont2") fontsize=3; |
|
style byline from titlesandfooters /
color=colors("headerfg"); |
|
class header /
fontstyle=italic;
|
|
class text /
"prefix1" = "PROC "
"suffix1" = ":"
"Content Title" = "Contents"
"Pages Title" = "Pages"
"Note Banner" = "Note:"
"Warn Banner" = "Warning:"
"Error Banner" = "Error:"
"Fatal Banner" = "Fatal:"
; |
|
class table /
rules=cols
cellspacing=0
borderwidth=5; |
|
class contents /
visitedlinkcolor=colors('systitlefg")
color=colors('systitlefg"); |
|
class contentitem /
posthtml="<p>"; |
|
end;
run; |
|
ods html body="customdefaultstyle-body.htm"
contents="customdefaultstyle-content.htm"
frame="customdefaultstyle-frame.htm"
style=customdefault; |
|
title "Energy Expenditures for Each Region";
title2 "(millions of dollars)"; |
|
proc print data=energy noobs;
var state type expenditures;
format
division divfmt. type usetype. expenditures comma12.;
by division;
where division=2 or division=3;
run; |
|
ods html close;
ods listing; |
HTML Output from PROC PRINT with the Customized Style
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.