Computing New Variables
IBM SPSS Statistics offers more than 70 built-in functions to compute new variables based on your corporate logic. These include:
• Arithmetic functions
• Statistical functions
• Distribution functions
• Logical functions
• Date and time aggregation and extraction functions
• Missing-value functions
• Cross-case functions
• String functions
These functions are available from the “Compute Variable” dialog (as we’ll see below).
A simple example would be to compute a variable that is the difference between the values of two existing variables in your data pond.
Sample data provided in the SPSS statistics tutorial can be used to demonstrate:
A data pond of responses from an online survey contains a respondent’s current age and the number of years he or she worked at a current job. It does not, however, contain information for the respondent’s age at the time he or she started that job, so IBM SPSS Statistics can compute the difference between “current age” and” the number of years at the current job” (which should be the approximate age at which the respondent started that job).
To compute our new variable we use the “Compute Variable” dialog, so from the menus in the Data Editor window choose:
Transform > Compute Variable…
- For Target Variable, we need to name our new variable so we enter ”jobstart”
- Select Age in years [age] in the source variable list and click the arrow button to copy it to the Numeric Expression text box.
- Click the minus (–) button on the calculator pad in the dialog box.
- Select Years with current employer [employ] and click the arrow button to copy it to the expression.
Now we have our formula:
age – Years with current employer
Now click OK to compute the new variable.
The new variable is displayed in the Data Editor:
Our new variable if now part of our data and is ready for further analysis!