TEMPLATE Procedure: Creating Table Templates

COMPUTE AS Statement

Computes values for a column that is not in the data component, or modifies the values of a column that is in the data component.
Restriction: The COMPUTE AS statement can be used only within a column template.


COMPUTE AS expression;

Required Argument

is an expression that assigns a value to each table cell in the column.
expression has this form:
expression-1 <comparison-operator expression-n>
is an arithmetic or logical sequence of operators and operands. An operator is a symbol that requests a comparison, a logical operation, or an arithmetic calculation. An operand is one of the following:
is a fixed value, such as the name of a column, or symbols that are declared in a DYNAMIC, MVAR, or NMVAR statement in the current template.
To reference another column in a COMPUTE AS statement, use the name of the column. In addition, if the column has values in the data component, you can reference the column itself in the expression.
For example, this DEFINE COLUMN block defines a column that contains the square root of the value in the column called Source:
define column sqroot;    
   compute as sqrt(source);    
   header="Square Root";    
specifies a SAS function. For information about SAS functions, see SAS Functions and CALL Routines: Reference.
built-in variable
is a special type of WHERE expression operand that helps you find common values in column templates. Built-in variables are one or more of the following:
is a column number. Column numbering begins with 1.
is a data-column name.
is a column label.
is a row number. Row numbering begins with 1.
is a style-element name.
is the data value of a cell.
Tip:Use _VAL_ to represent the value of the current column.
compares a variable with a value or another variable.
Comparison Operators
Mnemonic Equivalent
Equal to
^= or ~= or ¬= or <>
Not equal to
Greater than
Less than
Greater than or equal to
Less than or equal to
Equal to one from a list of values
Tip:The COMPUTE AS statement can alter values in an output object. None of the templates that SAS provides modifies any values. To determine whether a template was provided by SAS, use the ODS VERIFY Statement. If the template is not from SAS, the ODS VERIFY statement returns a warning when it runs the SAS program that uses the template. If you receive such a warning, use the SOURCE statement to look at the template and determine whether the COMPUTE AS statement alters values. (See SOURCE Statement.)
See:You can use any expression that can be used in the WHERE= data set option. For information about expressions that you can use in the WHERE data set option, see the WHERE data set option in SAS Data Set Options: Reference and the section on WHERE-Expression Processing in SAS Language Reference: Concepts.