Previous Page | Next Page

TEMPLATE Procedure: Creating a Style Template (Definition)

Example 1: Creating a Stand-Alone Style


PROC TEMPLATE features:

DEFINE STYLE statement:

STYLE statement:

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..


Program Description

This example creates a style that is not based on any other style. When you create a style, you will usually base it on one of the styles that SAS provides (see Using the CLASS Statement). However, this example is provided to show you some of the basic ways to create a style.

It is important to understand that by default, certain table elements are created with certain style elements. For example, unless you specify a different style element with the STYLE= attribute, ODS produces SAS titles with the SystemTitle style element. Similarly, unless you specify otherwise, ODS produces headers with the Header style element. (For information about each style element, see ODS Style Elements.


Program

 Note about code
proc template;
   define style newstyle;
      style cellcontents /
         fontfamily="arial, helvetica"
         fontweight=medium
         backgroundcolor=blue
         fontstyle=roman
         fontsize=5
         color=white
 Note about code
      style header /
         backgroundcolor=very light blue
         fontfamily="arial, helvetica"
         fontweight=medium         
         fontstyle=roman
         fontsize=5
         color=white;
 Note about code
     style systemtitle /
         fontfamily="arial, helvetica"
         fontweight=medium
         backgroundcolor=white
         fontstyle=italic
         fontsize=6
         color=red;
 Note about code
     style footer from systemtitle /
         fontsize=3;
 Note about code
     style table /
         cellspacing=5
         borderwidth=10;
 Note about code
   end;
run;
 Note about code
proc template;
   define table table1;
 Note about code
   mvar sysdate9;
 Note about code
   dynamic colhd;
 Note about code
   classlevels=on;
 Note about code
   define column char_var;
      generic=on;
      blank_dups=on;
      header=colhd;
      style=cellcontents;
   end;
 Note about code
   define column num_var;
      generic=on;
      header=colhd;
      style=cellcontents;
   end;
 Note about code
   define footer table_footer;
      text "Prepared on " sysdate9;
   end;
 Note about code
   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 with User-Defined Attributes

HTML Output

 Note about figure

[HTML Output]

Previous Page | Next Page | Top of Page