Previous Page | Next Page

TEMPLATE Procedure: Creating a Style Template (Definition)

Example 5: Defining Multiple Style Elements in One STYLE Statement


PROC TEMPLATE features:

DEFINE STYLE statement:

STYLE statement:

FROM option

Style attributes:

BACKGROUNDCOLOR=

BORDERWIDTH=

CELLSPACING=

FONTFAMILY=

FONTSIZE=

FONTSTYLE=

FONTWEIGHT=

COLOR=

DEFINE TABLE statement:

CLASSLEVELS= table attribute

DYNAMIC statement

MVAR statement

DEFINE COLUMN statement:

BLANK_DUPS=

GENERIC=

HEADER=

STYLE=

DEFINE FOOTER statement:

TEXT 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..
Table template: Table1.


Program Description

This example creates a style that defines multiple style elements concurrently. When style element names are specified multiple times, all of the attributes from all instances of that name are collected to create the final set of style attributes. Defining multiple style elements in one STYLE statement makes it possible to create shorter, easier to read programs and to make changes to style attributes in a single STYLE statement rather than in many STYLE statements.

For example, if you wanted to add the style element BorderColor=black to the style elements CellContents, Header, and SystemTitle in the program below, you could add it once, to the first STYLE statement, instead of adding it three times, to each individual STYLE statement.


Program

 Note about code
proc template;
   define style newstyle;
 Note about code
      style cellcontents, header, systemtitle / 
         fontfamily="arial, helvetica"
         fontweight=medium
         backgroundcolor=blue
         fontstyle=roman
         fontsize=5
         color=white;
 Note about code
      class header /
         backgroundcolor=very light blue;
 Note about code
      class systemtitle /
         backgroundcolor=white
         color=red
         fontstyle=italic
         fontsize=6;
 Note about code
      style footer from systemtitle /
         fontsize=3;
 Note about code
      class table /
         cellspacing=5
         borderwidth=10;
      end;
run;
 Note about code
ods listing close;
 Note about code
ods html body="newstyle-body.htm"
         style=newstyle;
 Note about code
   title "Leading Grain Producers";
   title2 "in 1996";
 Note about code
data _null_;
   set grain_production;
   where type  in ("Rice", "Corn") and year=1996;
 Note about code
   file print ods=(
        template="table1"
 Note about code
        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"))
           )
        );
 Note about code
   put _ods_;
run;
 Note about code
ods html close;
ods listing;

HTML Output: Specifying Colors and Fonts

HTML Output

 Note about figure

[HTML Output]

style cell / backgroundcolor=symget("bkgr");

Previous Page | Next Page | Top of Page