Calculating Columns in a Custom Table Template

In the previous example, the DATA step calculated the new variables. This example shows you how to calculate the new columns in the template definition itself. It is as simple as adding a COMPUTE statement within the DEFINE block for each column. Only the changed DEFINE blocks are shown in the following code. This definition assigns the name HR_CALC to the template.

ODS PATH WORK.NEWTEMP(UPDATE) SASHELP.TMPLMST(READ);
proc template;
  define table tables.hr_calc;
  column Department AnnualSalary BonusAmt NewSal;
. . . more code . . . define BonusAmt; compute as AnnualSalary * .05; header = '#Bonus#@5%'; format=7.2; end; define NewSal; compute as AnnualSalary + BonusAmt; header = 'Adjusted'; format=dollar14.2; ...

Get Output Delivery System: The Basics and Beyond now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.