Title: ‘Recoding’ variables
Course: UGQuants (SSPS) > Section: Univariate Analysis

‘Recoding’ variables

In quantitative research, coding is the term usually given to the process by which categories are represented by numerical values. To think about it another way, it is the process by which we attach values to value labels, for example Male = 2; Labour party = 1, etc. Recoding, then, refers to the process by which we restructure and re-label the values (or categories) of a particular variable. We could also describe this process as ‘regrouping’ a variable. We may do this, e.g., because we want to perform a certain kind of analysis, or because we want to make our data simpler to interpret, or indeed we sometimes want to combine data from two or more variables within a new variable.

Any type of variable may be recoded, although when we have a variable that already has only two possible values, our only option is to change the numerical codes for these values (which we may choose to do, e.g., when creating dummy variables), rather than changing the way data is presented more fundamentally. This highlights the fact that when we recode one variable, we cannot increase the number of values represented: we almost invariably reduce the number of values.

Sometimes in recoding we also change the level of measurement of the variable. For example, it is quite common to restructure a ratio variable such as age in years into an ordinal variable representing a series of ordered age groups. In this way we transform a variable with a very large number of potential values into one with a much more limited number of values. This is almost invariably an informed rather than random process, where factors such as the following need to be taken into consideration:

 | Are there any precedents that we might want to follow: e.g., for age, are there standard categories that researchers often use in constructing age groups?
 | How are the data distributed? For example, we might decide to restructure our data into a number of groups with approximately the same number of cases, in which instance knowing the values for the quartiles and percentiles would be useful. Or we might want to divide the data into regular intervals based on the overall range of the data, perhaps taking into consideration any outliers.
 | Are there other analytical or theoretical factors to be considered, perhaps relating to the further analysis we might wish to perform? For example, we might decide to divide our data differently on the basis of age depending on whether we are investigating attitudes to homosexuality or use of online social media.

Alternatively, we might use a recode to reduce the number of categories in an ordinal or nominal variable. For example, if we have an ordinal variable that represents people’s level of satisfaction on some issue on a 5 point scale from ‘very satisfied’ to ‘very dissatisfied’, we might choose to divide the data depending on whether people are broadly satisfied or dissatisfied, ignoring the degree of their (dis)satisfaction. Or we might want to reduce the complexity of a nominal variable with quite a large number of categories, for example based on people’s ethnicity or sector of employment. Sometimes we want to perform a recode to distinguish just one category in the original variable from all the others, and thus create a new simple two-category variable: e.g. to express whether an individual has a university degree or not. This can be expressed as a special type of variable – a dummy variable – in which the category of interest (e.g. having a degree) is given the value 1 and other values are grouped together and given the value 0.

The advantages of recoding data are, generally, that it simplifies the data and/or enables different types of analysis than were possible with the original variable. The disadvantages tend to be that it provides less detail about our data and (sometimes at least) makes impossible certain types of analysis that were possible with the original variable. However, when we recode we generally retain the original variable as well as creating the new one, so in effect we can ‘have our cake and eat it’.

One type of recoding that is often an exception to the ‘simplification’ rule is when we choose to combine variables to create a new, more complex variable. For example, imagine a survey has series of questions related to homosexuality. We might decide that we want to combine the responses to some or all of these questions for each case in order to give us a more general single measure of someone’s overall attitude to homosexuality.

Video on computing and recoding variables

Recoding with statistical software

In SPSS, you find this under:

Transform > Recode into different variable

1. You add the Input variable from the right to the central field

2. You give the output variable (the variable you are creating) a brief name and a descriptive label that will clearly tell anyone who reads it what the variable measures

3. You click 'change'

4. You click 'old and new values' --> this will open a new window

5. Make sure you know exactly how you want to recode your variable.

On the left, you tell SPSS what value or what range of values you would like to transform into a single value
On the right, you tell SPSS the numerical value that the newly created category takes.

E.g.: You want to turn all ages from 18-24 into a single category.

You select 'range' on the left and put in the values 18 and 24.

On the right, you give this for example the value '1'.

You press 'add'.

You continue with the next range of values (e.g. turning all respondents aged 25-44 into category '2').

If you want to, e.g. combine all people aged 75 and over into one category, you can do this by selecting 'value through Highest'.

6. Once you've defined all new categories/values, you can click 'continue' to close this window and 'ok' (to start the transformation straight away) or 'paste' (to copy the code into a syntax window - this will allow you to check it once more and rectify possible errors without having to go through the whole procedure once more).

7. Make sure you label your categories properly (go to the variable view and open the values window of the variable). You will not remember if category 2 was ages 25-44 or 25-49 six months later...