Chapter Contents

Previous

Next
The TEMPLATE Procedure

Example 6: Modifying the Default Style Definition for the HTML Destination


PROC TEMPLATE features:
DEFINE STYLE statement
PARENT= attribute
REPLACE statement
style attributes
user-defined attributes
BACKGROUND=
BORDERCOLORDARK=
BORDERCOLORLIGHT=
BORDERWIDTH=
CELLPADDING=
CELLSPACING=
FONT=
FONT_STYLE=
FOREGROUND=
FRAME=
POSTHTML=
RULES=
Other ODS features:
ODS HTML statement
STYLE= option
ODS LISTING statement
ODS PATH statement
Data set: ENERGY
Formats: DIVFMT. and USETYPE.

Generally, when you are working with style definitions, you are more likely to modify a style definition that SAS Institute supplies than to write a completely new style definition. This example shows you how to make changes to the default style definition for the HTML destination. The new style definition affects both the body file and the contents file in the HTML output. In particular, in the body file, it makes changes to

In the contents file, the style definition makes changes to

Note:   Remember that when a STYLE statement creates a style element in the new style definition, only style elements that explicitly inherit from that style element in the new definition inherit the change. When a REPLACE statement creates a style element in the new style definition, all style elements that inherit from that element inherit the definition that is in the new style definition, so the change appears in all children of the element.  [cautionend]


Program 1: Using the Default Style Definition with PROC PRINT
 Note about code
ods path sasuser.templat(update) sashelp.tmplmst(read);
 Note about code
ods listing close;
 Note about code
ods html body='sasdefaultstyle-body.htm'
         contents='sasdefaultstyle-content.htm'
         frame='sasdefaultstyle-frame.htm'
         style=styles.default;
 Note about code
title 'Energy Expenditures for Each Region';
title2 '(millions of dollars)';
footnote "Report prepared on &sysdate9";
 Note about code
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;


HTML Output from PROC PRINT with the Default Style Definition

HTML Output from PROC PRINT with the Default Style Definition
[HTML Output]


Program 2: Modifying the Default Style Definition and Using It with PROC PRINT

 Note about code
 proc template;
   define style customdefault;
 Note about code
   parent=styles.default;
 Note about code
   replace color_list /
      'fgB2' = cx0066AA
      'fgB1' = cx004488
      'fgA4' = cxAAFFAA
      'bgA4' = cx880000
      'bgA3' = cxD3D3D3
 /* changed from cx0033AA */
      'fgA2' = cx0000FF
      'bgA2' = cxB0B0B0
      'fgA1' = cx000000
      'bgA1' = cxF0F0F0
/* changed from cx002288 */
      'fgA' = cx660099
      'bgA' = cxE0E0E0;
 Note about code
   replace titlesandfooters /
      foreground=colors("systitlefg")
      background=colors("systitlebg")
      font=fonts("titlefont2") font_size=3;
 Note about code
   replace byline from titlesandfooters /
      foreground=colors("headerfg");
 Note about code
   style header from header /
      font_style=italic;
 Note about code
   replace 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
   style table from table /
      rules=cols
      cellspacing=0
      bordercolorlight=colors("headerfg")
      bordercolordark=colors("systitlefg")
      borderwidth=5;
 Note about code
   style contents from contents /
      visitedlinkcolor=colors("systitlefg")
      foreground = colors('systitlefg');
 Note about code
   style contentitem from contentitem /
      posthtml='<p>';
 Note about code
   end;
run;
 Note about code
ods html body='customdefaultstyle-body.htm'
         contents='customdefaultstyle-content.htm'
         frame='customdefaultstyle-frame.htm'
         style=customdefault;
 Note about code
title 'Energy Expenditures for Each Region';
title2 '(millions of dollars)';
footnote "Report prepared on &sysdate9";
 Note about code
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
ods html close;
ods listing;


HTML Output from PROC PRINT with the Customized Style Definition

HTML Output from PROC PRINT with the Customized Style Definition
[HTML Output]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.