Chapter Contents

Previous

Next
The Complete Guide to the SAS Output Delivery System

Programs that Illustrate Inheritance

The programs in this section show the PROC TEMPLATE steps that were used in How Do Style-Definition Inheritance and Style-Element Inheritance Work? to illustrate inheritance in style definitions. These programs also show the SAS code that uses the style definitions.


SAS Program for a Style with One Style Element

This program generates the HTML output in Using a Style Definition with One Style Element.

ods path sashelp.tmplmst(read) sasuser.templat(update);
title; 
options nodate pageno=1 linesize=72 pagesize=60; 
data test;
   input country $ 1-13 grain $ 15-18 kilotons;
   datalines; 
Brazil        Rice   10035 
China         Rice   190100 
India         Rice   120012 
Indonesia     Rice   51165
United States Rice   7771 
;

proc template;
   define table mytable; 
      column x y z; 
      define x; 
         style=celldatasimple; 
         dataname=country; 
         header='Country'; 
      end; 
      define y; 
           style=celldatasimple; 
           dataname=grain; 
           header='Grain'; 
      end; 
      define z; 
         style=celldatasimple; 
         dataname=kilotons; 
         header='Kilotons'; 
      end; 
   end; 
run; 

proc template; 
   /* to ensure a fresh start with the styles */
   delete concepts.style1;
   delete concepts.style2; 
run;

proc template; 
   define style concepts.style1; 
      style celldatasimple / 
         font_face=arial 
         background=very light vivid blue 
         foreground=white; 
   end; 
run; 

ods html body='display1-body.htm' 
         style=concepts.style1; 
data _null_; 
   set test; 
   file print ods=(template='mytable'); 
   put _ods_; 
run; 
ods html close;


SAS Program for a Style with Two Style Elements (Independently Defined)

This program generates the HTML output in A Style Definition with Two Style Elements. In this version of the code, the style element celldataemphasis is created independently of celldatasimple.

ods path sashelp.tmplmst(read) sasuser.templat(update);
title; 
options nodate pageno=1 linesize=72 pagesize=60; 
data test;
   input country $ 1-13 grain $ 15-18 kilotons;
   datalines; 
Brazil        Rice   10035 
China         Rice   190100 
India         Rice   120012 
Indonesia     Rice   51165
United States Rice   7771 
;

proc template;
   define table mytable; 
      column x y z; 
      define x; 
         style=celldatasimple; 
         dataname=country; 
         header='Country'; 
      end; 
      define y; 
           style=celldataemphasis; 
           dataname=grain; 
           header='Grain'; 
      end; 
      define z; 
         style=celldatasimple; 
         dataname=kilotons; 
         header='Kilotons'; 
      end; 
   end; 
run; 

proc template; 
   /* to ensure a fresh start with the styles */
   delete concepts.style1;
   delete concepts.style2; 
run;
proc template; 
   define style concepts.style1; 
      style celldatasimple / 
         font_face=arial 
         background=very light vivid blue 
         foreground=white;
      style celldataemphasis from celldatasimple /
         foreground=blue
         font_style=italic;
   end; 
run; 

ods html body='display2-body.htm' 
         style=concepts.style1; 
data _null_; 
   set test; 
   file print ods=(template='mytable'); 
   put _ods_; 
run; 
ods html close;


SAS Program for a Style with Two Style Elements (Defined with Inheritance)

This program generates the HTML output in A Style Definition with Two Style Elements. In this version of the code, the style element celldataemphasis is created as a child of celldatasimple.

ods path sashelp.tmplmst(read) sasuser.templat(update);
title; 
options nodate pageno=1 linesize=72 pagesize=60; 
data test;
   input country $ 1-13 grain $ 15-18 kilotons;
   datalines; 
Brazil        Rice   10035 
China         Rice   190100 
India         Rice   120012 
Indonesia     Rice   51165
United States Rice   7771 
;

proc template;
   define table mytable; 
      column x y z; 
      define x; 
         style=celldatasimple; 
         dataname=country; 
         header='Country'; 
      end; 
      define y; 
           style=celldataemphasis; 
           dataname=grain; 
           header='Grain'; 
      end; 
      define z; 
         style=celldatasimple; 
         dataname=kilotons; 
         header='Kilotons'; 
      end; 
   end; 
run; 

proc template; 
   /* to ensure a fresh start with the styles */
   delete concepts.style1;
   delete concepts.style2; 
run;
proc template; 
   define style concepts.style1; 
      style celldatasimple / 
         font_face=arial 
         background=very light vivid blue 
         foreground=white;
      style celldataemphasis from celldatasimple /
         foreground=blue
         font_style=italic;
   end; 
run; 

ods html body='display2-body.htm' 
         style=concepts.style1; 
data _null_; 
   set test; 
   file print ods=(template='mytable'); 
   put _ods_; 
run; 
ods html close;


SAS Program for Changing the Font Face in Only One Style Element

This program generates the HTML output in Changing the Font Face in Only One Style Element.

ods path sashelp.tmplmst(read) sasuser.templat(update);
title; 
options nodate pageno=1 linesize=72 pagesize=60; 
data test;
   input country $ 1-13 grain $ 15-18 kilotons;
   datalines; 
Brazil        Rice   10035 
China         Rice   190100 
India         Rice   120012 
Indonesia     Rice   51165
United States Rice   7771 
;

proc template;
   define table mytable; 
      column x y z; 
      define x; 
         style=celldatasimple; 
         dataname=country; 
         header='Country'; 
      end; 
      define y; 
           style=celldataemphasis; 
           dataname=grain; 
           header='Grain'; 
      end; 
      define z; 
         style=celldatasimple; 
         dataname=kilotons; 
         header='Kilotons'; 
      end; 
   end; 
run; 

proc template; 
   /* to ensure a fresh start with the styles */
   delete concepts.style1;
   delete concepts.style2; 
run;
proc template; 
   define style concepts.style1; 
      style celldatasimple 
        'The change to FONT_FACE does not 
         affect celldataemphasis.'
      /  font_face=times 
         background=very light vivid blue 
         foreground=white;
      style celldataemphasis /
         font_face=arial
         background=very light vivid blue
         foreground=blue
         font_style=italic;
   end; 
run; 

ods html body='display3-body.htm' 
         style=concepts.style1; 
data _null_; 
   set test; 
   file print ods=(template='mytable'); 
   put _ods_; 
run; 
ods html close;


SAS Program for Inheriting a Change to a Style Element

This program generates the HTML output in Inheriting a Change to a Style Element. In this version of the code, the style element celldataemphasis is created as a child ofcelldatasimple.

ods path sashelp.tmplmst(read) sasuser.templat(update);
title; 
options nodate pageno=1 linesize=72 pagesize=60; 
data test;
   input country $ 1-13 grain $ 15-18 kilotons;
   datalines; 
Brazil        Rice   10035 
China         Rice   190100 
India         Rice   120012 
Indonesia     Rice   51165
United States Rice   7771 
;

proc template;
   define table mytable; 
      column x y z; 
      define x; 
         style=celldatasimple; 
         dataname=country; 
         header='Country'; 
      end; 
      define y; 
           style=celldataemphasis; 
           dataname=grain; 
           header='Grain'; 
      end; 
      define z; 
         style=celldatasimple; 
         dataname=kilotons; 
         header='Kilotons'; 
      end; 
   end; 
run; 

proc template; 
   /* to ensure a fresh start with the styles */
   delete concepts.style1;
   delete concepts.style2; 
run;
proc template; 
   define style concepts.style1; 
      style celldatasimple 
        'The change to FONT_FACE is passed to 
         celldataemphasis, which inherits all the
         attributes of celldatasimple.'
      /  font_face=times 
         background=very light vivid blue 
         foreground=white;
      style celldataemphasis from celldatasimple /
         foreground=blue
         font_style=italic;
   end; 
run; 

ods html body='display4-body.htm' 
         style=concepts.style1; 
data _null_; 
   set test; 
   file print ods=(template='mytable'); 
   put _ods_; 
run; 
ods html close;


SAS Program for Creating the Style Element celldatalarge

This program generates the HTML output in Adding the Style Element celldatalarge.

ods path sashelp.tmplmst(read) sasuser.templat(update);
title; 
options nodate pageno=1 linesize=72 pagesize=60; 
data test;
   input country $ 1-13 grain $ 15-18 kilotons;
   datalines; 
Brazil        Rice   10035 
China         Rice   190100 
India         Rice   120012 
Indonesia     Rice   51165
United States Rice   7771 
;

proc template;
   define table mytable; 
      column x y z; 
      define x; 
         style=celldatasimple; 
         dataname=country; 
         header='Country'; 
      end; 
      define y; 
           style=celldataemphasis; 
           dataname=grain; 
           header='Grain'; 
      end; 
      define z; 
         style=celldatalarge; 
         dataname=kilotons; 
         header='Kilotons'; 
      end; 
   end; 
run; 

proc template; 
   /* to ensure a fresh start with the styles */
   delete concepts.style1;
   delete concepts.style2; 
run;
proc template; 
   define style concepts.style1; 
      style celldatasimple /
         font_face=arial 
         background=very light vivid blue 
         foreground=white;
      style celldataemphasis from celldatasimple /
         foreground=blue
         font_style=italic;
      style celldatalarge from celldataemphasis /
         font_weight=bold
         font_size=5;
   end; 
run; 

ods html body='display5-body.htm' 
         style=concepts.style1; 
data _null_; 
   set test; 
   file print ods=(template='mytable'); 
   put _ods_; 
run; 
ods html close;


SAS Program for Creating a New Style Element from a Style Element in the Parent Style Definition

This program generates the HTML output in Creating a New Style Element from a Style Element in the Parent Style Definition.

ods path sashelp.tmplmst(read) sasuser.templat(update);
title; 
options nodate pageno=1 linesize=72 pagesize=60; 
data test;
   input country $ 1-13 grain $ 15-18 kilotons;
   datalines; 
Brazil        Rice   10035 
China         Rice   190100 
India         Rice   120012 
Indonesia     Rice   51165
United States Rice   7771 
;

proc template;
   define table mytable; 
      column x y z w; 
      define x; 
         style=celldatasimple; 
         dataname=country; 
         header='Country'; 
      end; 
      define y; 
           style=celldataemphasis; 
           dataname=grain; 
           header='Grain'; 
      end; 
      define z; 
         style=celldatalarge; 
         dataname=kilotons; 
         header='Kilotons'; 
      end;
      define w;
         style=celldatasmall;
         dataname=kilotons;
         header='Kilotons';
      end; 
   end; 
run; 

proc template; 
   /* to ensure a fresh start with the styles */
   delete concepts.style1;
   delete concepts.style2; 
run;

proc template; 
   define style concepts.style1; 
      style celldatasimple /
         font_face=arial 
         background=very light vivid blue 
         foreground=white;
      style celldataemphasis from celldatasimple /
         foreground=blue
         font_style=italic;
      style celldatalarge from celldataemphasis /
         font_weight=bold
         font_size=5;
   end; 
run; 

proc template;
   define style concepts.style2;
      parent=concepts.style1;
      style celldatasmall from celldatalarge /
         font_size=2;
   end;
run;
ods html body='display6-body.htm' 
         style=concepts.style2; 
data _null_; 
   set test; 
   file print ods=(template='mytable'); 
   put _ods_; 
run; 
ods html close;


SAS Program for Inheriting Changes to the Parent Style Definition

This program generates the HTML output in Inheriting Changes to the Parent Style Definition.

ods path sashelp.tmplmst(read) sasuser.templat(update);
title; 
options nodate pageno=1 linesize=72 pagesize=60; 
data test;
   input country $ 1-13 grain $ 15-18 kilotons;
   datalines; 
Brazil        Rice   10035 
China         Rice   190100 
India         Rice   120012 
Indonesia     Rice   51165
United States Rice   7771 
;

proc template;
   define table mytable; 
      column x y z w; 
      define x; 
         style=celldatasimple; 
         dataname=country; 
         header='Country'; 
      end; 
      define y; 
           style=celldataemphasis; 
           dataname=grain; 
           header='Grain'; 
      end; 
      define z; 
         style=celldatalarge; 
         dataname=kilotons; 
         header='Kilotons'; 
      end;
      define w;
         style=celldatasmall;
         dataname=kilotons;
         header='Kilotons';
      end; 
   end; 
run; 

proc template; 
   /* to ensure a fresh start with the styles */
   delete concepts.style1;
   delete concepts.style2; 
run;

proc template; 
   define style concepts.style1; 
      style celldatasimple /
         font_face=times 
         background=very light vivid blue 
         foreground=white;
      style celldataemphasis from celldatasimple /
         foreground=black
         font_style=italic;
      style celldatalarge from celldataemphasis /
         font_weight=bold
         font_size=5;
   end; 
run; 

proc template;
   define style concepts.style2;
      parent=concepts.style1;
      style celldatasmall from celldatalarge /
         font_size=2;
   end;
run;
ods html body='display7-body.htm' 
         style=concepts.style2; 
data _null_; 
   set test; 
   file print ods=(template='mytable'); 
   put _ods_; 
run; 
ods html close;


SAS Program for Using the STYLE Statement to Alter an Existing Style Element in the Child Definition

This program generates the HTML output in Using the STYLE Statement to Alter an Existing Style Element in the Child Style Definition.

ods path sashelp.tmplmst(read) sasuser.templat(update);
title; 
options nodate pageno=1 linesize=72 pagesize=60; 
data test;
   input country $ 1-13 grain $ 15-18 kilotons;
   datalines; 
Brazil        Rice   10035 
China         Rice   190100 
India         Rice   120012 
Indonesia     Rice   51165
United States Rice   7771 
;

proc template;
   define table mytable; 
      column x y z w; 
      define x; 
         style=celldatasimple; 
         dataname=country; 
         header='Country'; 
      end; 
      define y; 
           style=celldataemphasis; 
           dataname=grain; 
           header='Grain'; 
      end; 
      define z; 
         style=celldatalarge; 
         dataname=kilotons; 
         header='Kilotons'; 
      end;
      define w;
         style=celldatasmall;
         dataname=kilotons;
         header='Kilotons';
      end; 
   end; 
run; 

proc template; 
   /* to ensure a fresh start with the styles */
   delete concepts.style1;
   delete concepts.style2; 
run;

proc template; 
   define style concepts.style1; 
      style celldatasimple /
         font_face=arial 
         background=very light vivid blue 
         foreground=white;
      style celldataemphasis from celldatasimple /
         foreground=blue
         font_style=italic;
      style celldatalarge from celldataemphasis /
         font_weight=bold
         font_size=5;
   end; 
run; 

proc template;
   define style concepts.style2;
      parent=concepts.style1;
      style celldataemphasis from celldataemphasis /
         background=white;
      style celldatasmall from celldatalarge /
         font_size=2;
   end;
run;
ods html body='display8-body.htm' 
         style=concepts.style2; 
data _null_; 
   set test; 
   file print ods=(template='mytable'); 
   put _ods_; 
run; 
ods html close;


SAS Program for Using the REPLACE Statement to Alter a Style Element and Its Children

This program generates the HTML output in Using the REPLACE Statement to Alter a Style Element and Its Children.

ods path sashelp.tmplmst(read) sasuser.templat(update);
title; 
options nodate pageno=1 linesize=72 pagesize=60; 
data test;
   input country $ 1-13 grain $ 15-18 kilotons;
   datalines; 
Brazil        Rice   10035 
China         Rice   190100 
India         Rice   120012 
Indonesia     Rice   51165
United States Rice   7771 
;

proc template;
   define table mytable; 
      column x y z w; 
      define x; 
         style=celldatasimple; 
         dataname=country; 
         header='Country'; 
      end; 
      define y; 
           style=celldataemphasis; 
           dataname=grain; 
           header='Grain'; 
      end; 
      define z; 
         style=celldatalarge; 
         dataname=kilotons; 
         header='Kilotons'; 
      end;
      define w;
         style=celldatasmall;
         dataname=kilotons;
         header='Kilotons';
      end; 
   end; 
run; 

proc template; 
   /* to ensure a fresh start with the styles */
   delete concepts.style1;
   delete concepts.style2; 
run;

proc template; 
   define style concepts.style1; 
      style celldatasimple /
         font_face=arial 
         background=very light vivid blue 
         foreground=white;
      style celldataemphasis from celldatasimple /
         foreground=blue
         font_style=italic;
      style celldatalarge from celldataemphasis /
         font_weight=bold
         font_size=5;
   end; 
run; 

proc template;
   define style concepts.style2;
      parent=concepts.style1;
      replace celldataemphasis from celldatasimple /
         foreground=blue
         font_style=italic
         background=white;
      style celldatasmall from celldatalarge /
         font_size=2;
   end;
run;
ods html body='display9-body.htm' 
         style=concepts.style2; 
data _null_; 
   set test; 
   file print ods=(template='mytable'); 
   put _ods_; 
run; 
ods html close;


Chapter Contents

Previous

Next

Top of Page

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