Previous Page | Next Page

TEMPLATE Procedure: Creating Tabular Output

Example 5: Setting the Style Element for a Specific Column, Row, and Cell


PROC TEMPLATE features:

DEFINE STYLE statement:

REPLACE statement

DEFINE TABLE statement:

CELLSYTLE-AS statement

DEFINE COLUMN statement:

DEFINE HEADER statement:

TEXT statement

DEFINE HEADER statement:

TEXT statement

Other ODS features:

FILE statement with ODS= option

ODS HTML statement:

STYLE= option

ODS PDF statement:

STYLE= option

PUT statement with _ODS_ argument

ODS TRACE statement

Data set: See Creating the Exprev Data Set.


Program Description

This example combines a customized style with a customized table template to produce output with a checkerboard pattern of table cells.


Program

options obs=20;
title;

 Note about code
proc template;
   define style greenbar;
 Note about code
   parent=styles.printer;
 Note about code
   replace headersandfooters from cell /
         backgroundcolor=light green
         color=black
         fontsize=3
         fontweight=bold
       ;
 Note about code
    end;
 run;
 Note about code
ods html body="greenbar.html" style=greenbar;
ods pdf file="greenbar.pdf" style=greenbar;
 Note about code
proc template;
   define table Checkerboard;
 Note about code
cellstyle mod(_row_,2) && mod(_col_,2) as data{backgroundcolor=yellow fontweight=bold },
                not(mod(_row_,2)) && not(mod(_col_,2)) as data{backgroundcolor=yellow fontweight=bold },
                1 as data;     
 Note about code
define header top;
   text "Checkerboard Table Template";
end; 
 Note about code
      define column country;
         dataname=country; 
         define header bar;
            text "Country";
         end;
         header=bar;
      end;
 Note about code
      define column OrderDate;
         dataname=Order_Date;
         define header bar;
            text "Order Date";
         end;
         header=bar;
      end;
 Note about code
      define column ShipDate;
         dataname=Ship_Date;
         define header bar;
            text "Ship Date";
         end;
         header=bar;
      end;
 Note about code
      define column SaleType;
         dataname=Sale_Type;
         define header bar;
            text "Sale Type";
         end;
         header=bar;
      end;
 Note about code
end;
run;
 Note about code
data _null_;
   set work.exprev;
 Note about code
file print ods=(template="Checkerboard");
  put _ods_;
run;
 Note about code
ods html close;
ods pdf close;

HTML Output (Viewed with Internet Explorer 6.0)

[HTML Output (Viewed with Internet Explorer 6.0)]

PDF Output (Viewed with Acrobat Reader 5.0)

[PDF Output (Viewed with Acrobat Reader 5.0)]

Previous Page | Next Page | Top of Page