The Data Table

Computing New Variables

You can specify an expression for creating a new column in the data table. Select Data arrow Transform arrow Compute ... to display the Compute dialog.

Compute Dialog

Figure 2.16: Compute Dialog

Type the expression in the box under the new column name, or use a combination of typing and selecting variables, functions, and operators. A numeric column is created by default.

Click on an operator at the right of the expression box to add it to the expression. You can also type in an operator.

To add a variable to the expression, double-click on the variable name or select it and click on the arrow above the Variables list. You can also type in a variable name.

Functions are organized into categories. Select a category by clicking on the arrow next to the Category: field. Review information about a function by selecting it. This information appears in the box to the left of the function list. Add a function to the expression by double-clicking on it or selecting the function and clicking on the arrow above the Functions box. You can also type in any SAS function. The functions displayed are a subset of all SAS functions.

By default, the column name is CompN, where N is the lowest number that produces a unique name. Replace the default column name by typing in one of your choosing.

The Attributes button displays the Column Attributes dialog, in which you can specify the name, label, and other attributes for your computed column. If you want to create a column with character values, use this dialog to set the variable type to character. Numeric is the default variable type.

Click on the Verify button to make sure your expression is valid. Function parameters are not verified, and the variable type is not taken into account.

If you have already used the Compute dialog to add a column to the current data table, click on the Recall button to fill the expression box and the Column Attributes dialog with the most recent expression and attributes.

Previous | Next | Top of Page