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.
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
ods path sasuser.templat(update) sashelp.tmplmst(read); |
![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="sasdefaultstyle-body.htm"
contents="sasdefaultstyle-content.htm"
frame="sasdefaultstyle-frame.htm"
style=styles.default; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
title "Energy Expenditures for Each Region";
title2 "(millions of dollars)"; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
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; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
ods html close;
ods listing; |
HTML Output from PROC PRINT Using the Default Style
![[HTML Output from PROC PRINT Using the Default Style]](images/procstyleex3.gif)
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
proc template;
define style customdefault; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
parent=styles.default; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
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; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
class titlesandfooters/
color=colors("systitlefg")
backgroundcolor=colors("systitlebg")
font=fonts("titlefont2") fontsize=3; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
style byline from titlesandfooters /
color=colors("headerfg"); |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
class header /
fontstyle=italic;
|
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
class text /
"prefix1" = "PROC "
"suffix1" = ":"
"Content Title" = "Contents"
"Pages Title" = "Pages"
"Note Banner" = "Note:"
"Warn Banner" = "Warning:"
"Error Banner" = "Error:"
"Fatal Banner" = "Fatal:"
; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
class table /
rules=cols
cellspacing=0
borderwidth=5; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
class contents /
visitedlinkcolor=colors('systitlefg")
color=colors('systitlefg"); |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
class contentitem /
posthtml="<p>"; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
end;
run; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
ods html body="customdefaultstyle-body.htm"
contents="customdefaultstyle-content.htm"
frame="customdefaultstyle-frame.htm"
style=customdefault; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
title "Energy Expenditures for Each Region";
title2 "(millions of dollars)"; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
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; |
![Note about code](../../../../common/61991/HTML/default/images/snbut.gif) |
ods html close;
ods listing; |
HTML Output from PROC PRINT with the Customized Style
![[HTML Output from PROC PRINT with the Customized Style]](images/styleex3pg2custom1.gif)
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.