Previous Page | Next Page

TEMPLATE Procedure: Creating a Style Template (Definition)

Example 3: Using the CLASS Statement


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:

STYLE= option

ODS LISTING statement

ODS PATH statement

Data set: Energy.
Formats: DIVFMT. and USETYPE..


Program 1: Description

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:

In the body file, the modified style makes changes to the following:

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.


Program 1: Using the Default Style 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)";
 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 Using the Default Style

[HTML Output from PROC PRINT Using the Default Style]


Program 2: Modifying the Default Style with the CLASS Statement

 Note about code
 proc template;
   define style customdefault;
 Note about code
   parent=styles.default;
 Note about code
   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
   class titlesandfooters/
      color=colors("systitlefg")
      backgroundcolor=colors("systitlebg")
      font=fonts("titlefont2") fontsize=3;
 Note about code
   style byline from titlesandfooters /
      color=colors("headerfg");
 Note about code
   class header  /
      fontstyle=italic;
      
 Note about code
   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
   class table /
      rules=cols
      cellspacing=0
      borderwidth=5;
 Note about code
   class contents /
      visitedlinkcolor=colors('systitlefg")
      color=colors('systitlefg");
 Note about code
   class 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)";
 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

[HTML Output from PROC PRINT with the Customized Style]

Previous Page | Next Page | Top of Page