Often when you are doing your analysis you will find that it is helpful to create new variables, or to make changes to existing variables. This page details three of the transformation facilities provided by SPSS which enable you to do this, all of which are found under the Transform menu (note that even though the current data file is very small, the transformation examples work in exactly the same way as for a much larger file).
The transformations covered are as follows (note that two additional, specific examples that make use of some of these transformation types are also detailed in the Extras page of this module):
The examples covered make use of the data described in the Getting started page of this module. If you want to work through the examples provided and haven’t already downloaded this data, you can do so using the link below:
Before commencing the analysis, note that the default is for dialog boxes in SPSS to display any variable labels, rather than variable names. You may find this helpful, but if you would prefer to view the variable names instead then from the menu choose:
Sometimes you may wish to create a new variable or variables to add to your data file, either from scratch or using the data from an existing variable or variables. For example, in the sample data file you may wish to create a new variable which gives the difference between summer and winter household energy consumption for each survey participant. You can do this by choosing the following from the SPSS menu (either from the Data Editor or Output window):
Next:
If you then navigate to the Data View of the Data Editor window, you will see that a new ‘Consumption_difference’ variable has been added to the end of the data file, with the difference for each of the 10 cases determined using the numeric expression entered. You can then analyse this variable as you would any of the original variables.
Note that you can also move the new variable if wished, either in the Data View or in the Variable View , by dragging and dropping. For example, you could move the new variable to sit after the ‘Winter_consumption’ variable by selecting the variable name in the Data View , then holding down the left mouse key and dragging until it is in the required spot.
Sometimes you may wish to recode an existing categorical variable, most likely to reduce the number of categories by combining existing ones together. For example, in the sample data file you may wish to recode the ‘Consumption_reduction’ variable to reduce the number of categories from five to three (particularly as there are so few people in each category, and no-one in the ‘Strongly disagree’ category). You can do this by choosing the following from the SPSS menu (either from the Data Editor or Output window):
The second part of the process is to decide how the categories of the existing variable are going to map to categories of the new variable. Sometimes this can require quite a bit of thought and planning, but with so few categories in this example it is more straightforward. In particular, the existing categories lend themselves to being recoded into three new categories (‘Agree’, ‘Neutral’ and ‘Disagree’), as follows:
Existing category | New category |
---|---|
1 (Strongly disagree) | 1 (Disagree) |
2 (Disagree) | 1 (Disagree) |
3 (Neutral) | 2 (Neutral) |
4 (Agree) | 3 (Agree) |
5 (Strongly agree) | 3 (Agree) |
To specify this in SPSS, do the following in the Recode into Different Variables: Old and New Values dialogue box:
Next:
If you then navigate to the Data View of the Data Editor window, you will see that a new ‘Consumption_reduction_recoded’ variable has been added to the end of the data file (note that you can move it if wished, either in the Data View or in the Variable View , by dragging and dropping). The category values do not currently have any labels (e.g. ‘Disagree’, ‘Neutral’ and ‘Agree’), and you may need to change the variable Measure (from Nominal to Ordinal), but you can do both of these things as described in the Getting started page of this module.
Once you have finished setting up the variable, you can analyse it in the usual way. For example, you could run the Frequencies procedure (as described in the Descriptive statistics page of this module) on the new variable, which should result in the following table:
Sometimes it is helpful to transform a continuous variable into a categorical variable, as this provides additional analysis options. For example, in the sample data file you may wish to transform the continuous ‘Age’ variable into categories, perhaps in order to make some comparisons for different age groups.
While you can in fact do this using either of the procedures outlined above, the purpose-built procedure for this in SPSS is Visual Binning. You can make use of this by choosing the following from the SPSS menu (either from the Data Editor or Output window):
Next:
Next:
If you then navigate to the Data View of the Data Editor window, you will see that a new ‘Age_grouped’ variable has been added to the end of the data file (note that you can move it if wished, either in the Data View or in the Variable View , by dragging and dropping). You can analyse it in the usual way, for example you could run the Frequencies procedure (as described in the Descriptive statistics page of this module) on the new variable, which should result in the following table: