Programs that Illustrate Inheritance


Programs that Illustrate Inheritance

The programs in this section show the PROC TEMPLATE steps that were used in 'About Style Definition Inheritance and Style Element Inheritance' on page 322 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 Display 9.3 on page 324.

 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 html3 body='display1-body.htm'           style=concepts.style1;  data _null_;     set test;     file print ods=(template='mytable');     put _ods_;  run;  ods html3 close; 

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

This program generates the HTML output in Creating a Second Style Element Independently or from an Existing Style Element on page 324. 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 html3 body='display2-body.htm'           style=concepts.style1;  data _null_;      set test;      file print ods=(template='mytable');      put _ods_;  run;  ods html3 close; 

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

This program generates the HTML output in Creating a Second Style Element Independently or from an Existing Style Element on page 324. 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 html3 body='display2-body.htm'           style=concepts.style1;  data _null_;      set test;      file print ods=(template='mytable');      put _ods_;  run;  ods html3 close; 

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

This program generates the HTML output in Display 9.5 on page 327.

 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 html3 body='display3-body.htm'           style=concepts.style1;  data _null_;     set test;     file print ods=(template='mytable');     put _ods_;  run;  ods html3 close; 

SAS Program for Inheriting a Change to a Style Element

This program generates the HTML output in Display 9.6 on page 327. 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          '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 html3 body='display4-body.htm'           style=concepts.style1;  data _null_;     set test;     file print ods=(template='mytable');     put _ods_;  run;  ods html3 close; 

SAS Program for Creating the Style Element celldatalarge

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

 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 html3 body='display5-body.htm'           style=concepts.style1;  data _null_;        set test;        file print ods=(template='mytable');     put _ods_;  run;  ods html3 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 on page 333.

 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 html3 body='display6-body.htm'           style=concepts.style2;  data _null_;        set test;        file print ods=(template='mytable');        put _ods_;  run;  ods html3 close; 

SAS Program for Inheriting Changes to the Parent Style Definition

This program generates the HTML output in Display 9.9 on page 335.

 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 celldataemphasis from celldataemphasis /           background=white;        style celldatasmall from celldatalarge /           font_size=2;        end;  run;  ods html3 body='display7-body.htm'           style=concepts.style2;  data _null_;     set test;     file print ods=(template='mytable');     put _ods_;  run;  ods html3 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 Display 9.10 on page 337.

 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 html3 body='display8-body.htm'           style=concepts.style2;  data _null_;        set test;        file print ods=(template='mytable');        put _ods_;  run;  ods html3 close; 

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

This program generates the HTML output in Display 9.11 on page 341.

 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 html3 body='display9-body.htm'           style=concepts.style2;  data _null_;     set test;     file print ods=(template='mytable');     put _ods_;  run;  ods html3 close; 



SAS 9.1 Output Delivery System. Users Guide
SAS 9.1 Output Delivery System Users Guide
ISBN: 1590472187
EAN: 2147483647
Year: 2004
Pages: 99
Authors: SAS Institute

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net