Computing Variables
Use the Compute dialog box to compute values for a variable based on numeric transformations of other variables.
- You can compute values for numeric or string (alphanumeric) variables.
- You can create new variables or replace the values of existing variables. For new variables, you can also specify the variable type and label.
- You can compute values selectively for subsets of data based on logical conditions.
- You can use a large variety of built-in functions, including arithmetic functions, statistical functions, distribution functions, and string functions.
To Compute Variables
- From the menus choose:
- Type the name of a single target variable. It can be an existing variable or a new variable to be added to the active dataset.
- To build an expression, either paste components into the Expression field or type directly in the Expression field.
- You can paste functions or commonly used system variables by selecting a group from the Function group list and double-clicking the function or variable in the Functions and Special Variables list (or select the function or variable and click the arrow adjacent to the Function group list). Fill in any parameters indicated by question marks (only applies to functions). The function group labeled All provides a listing of all available functions and system variables. A brief description of the currently selected function or variable is displayed in a reserved area in the dialog box.
- String constants must be enclosed in quotation marks or apostrophes.
- If values contain decimals, a period (.) must be used as the decimal indicator.
- For new string variables, you must also select Type & Label to specify the data type.
- In the Filter by field, you can type in a search term to filter the functions on. If you select Include description, your search also filters by function descriptions.