TEMPLATE Procedure: Creating Table Templates

Example 2: Comparing the EDIT Statement to the DEFINE TABLE Statement

Features:

EDIT statement

COLUMN statement

DEFINE statement : STYLE= attribute

NOTES statement

DYNAMIC statement

Other features:
Other ODS features:
ODS PATH statement
ODS HTML statement
DELETE statement
Data set: Exprev

Details

This example compares the use of an EDIT statement with a DEFINE TABLE statement for the same table template. The first program uses the EDIT statement to change the Base.Summary table template. The foreground color of the NOBS column is changed to orange. The other templates and attributes of the Base.Summary table template remain the same. The second program uses the DEFINE TABLE statement to define a new table using the same name, Base.Summary. The NOBS column is the only column defined in the new table template. When the PROC SUMMARY step executes, only the NOBS column is printed. The only style attribute that formats the column is the color=orange attribute.

Program 1

ods path work.templat (update) sashelp.tmplmst (read);
proc template;
    edit Base.Summary;
    edit nobs;
    style={color=orange background=white};
end;

end;
run;

proc summary data=exprev print;
    class Sale_Type;
run;
proc template;
delete base.Summary;
run;

Program Description

Edit the existing table template Base.Summary. The ODS PATH statement specifies which item store to search first for the table template. The EDIT statement edits the table template Base.Summary. The modified table template Base.Summary is written to the Work.Templat item store.
ods path work.templat (update) sashelp.tmplmst (read);
proc template;
    edit Base.Summary;
    edit nobs;
    style={color=orange background=white};
end;

end;
run;

proc summary data=exprev print;
    class Sale_Type;
run;
Remove the customized summary table template from Work.Templat.The DELETE statement removes the customized summary table that was created in this example. When using the DELETE statement, ODS looks for base.summary in Sasuser.Templat and Work.Templat first. If it is there, it will delete it. If not, it will search Sashelp.Tmplmst.
proc template;
delete base.Summary;
run;

Output for Program 1

The column labeled Age remains in the output because Age is defined as a dynamic variable, which is passed to the original Base.Summary table template, and Age is specified as the CLASS variable. The attributes of the NOBS column are modified in the EDIT statement where the NOBS column is defined.
HTML Output Using an Edited Table Template for Base.Summary
HTML Output Using an Edited Table Template for Base.Summary
The modified Base.Summary table template changes the foreground color of the NOBS column to orange. The vertical alignment and heading of the NOBS column, and the other table attributes, are retained from the default table template and stay the same. To view the Base.Summary table template created by Program 1, submit odstemplates in the command bar. Then select Work.Templatthen selectBase. Right-click the table template Summary and select Open. The table template Base.Summary is displayed in the Template Browser window.
Base.Summary Table Template Modified by the EDIT Statement
Base.Summary Table Template Modified by the EDIT Statement

Program 2

ods path work.templat (update) sashelp.tmplmst (read);
proc template;
   define table Base.Summary;
      notes "Summary table for MEANS and SUMMARY";
      dynamic clmpct one_var_name one_var_label one_var;
      column class nobs id type ways (varname) (label) (min) (max) (range) 
         (n         ) (nmiss) (sumwgt) (sum) (mean) (uss) (css) (var) (stddev) (cv)
         (        stderr) (t) (probt) (lclm) (uclm) (skew) (kurt) (median) (mode) (q1)
         (q3) (qrange) (p1) (p5) (p10) (p25) (p50) (p75) (p90) (p95) (p99);


      define nobs;
        style={color=orange backgroundcolor=white};

      end;

   end;
run;

proc summary data=exprev print;
class Sale_Type;
run;
proc template;
delete base.Summary;
run;

Program Description

Define the table Base.Summary. The ODS PATH statement specifies which item store to search first for the table template. The DEFINE TABLE statement creates a new table template Base.Summary. The new table template Base.Summary is written to the Work.Templat item store.
ods path work.templat (update) sashelp.tmplmst (read);
proc template;
   define table Base.Summary;
      notes "Summary table for MEANS and SUMMARY";
      dynamic clmpct one_var_name one_var_label one_var;
      column class nobs id type ways (varname) (label) (min) (max) (range) 
         (n         ) (nmiss) (sumwgt) (sum) (mean) (uss) (css) (var) (stddev) (cv)
         (        stderr) (t) (probt) (lclm) (uclm) (skew) (kurt) (median) (mode) (q1)
         (q3) (qrange) (p1) (p5) (p10) (p25) (p50) (p75) (p90) (p95) (p99);


      define nobs;
        style={color=orange backgroundcolor=white};

      end;

   end;
run;

proc summary data=exprev print;
class Sale_Type;
run;
Remove the customized summary table template from Work.Templat.The DELETE statement removes the customized summary table that was created in this example. When using the DELETE statement, ODS looks for base.summary in Sasuser.Templat and Work.Templat first. If it is there, it will delete it. If not, it will search Sashelp.Tmplmst.
proc template;
delete base.Summary;
run;

Output for Program 2

The column labeled Age is missing because it was not defined in the new table template Base.Summary. The new table template only defined the NOBS column with an orange foreground and no column headings.
HTML Output That Uses the Table Template Base.Summary.
HTML Output That Uses the Table Template Base.Summary.
The Base.Summary table template defines the foreground color of the NOBS column as orange. Because the vertical alignment and heading of the NOBS column and the other table attributes are not defined, they are no longer part of the Base.Summary table template. To view the table template Base.Summary created by Program 2, do the following: Submit odstemplates in the command bar. Then select Work.Templatthen selectBase. Right-click the table template Summary and select Open. The table template Base.Summary is displayed in the Template Browser window.
Base.Summary Table Template Created by the DEFINE TABLE Statement
Base.Summary Table Template Created by the DEFINE TABLE Statement