HerfstkleurenHelpdesk IBM SPSS Statistics 20

For students from Arnhem Business School
Home Codebook Data Data editing Analysis Graphs Settings Links Methods

Data editing Compute

With Compute you can create/define variables using formulas, arithmetic and manipulation of existing variables.
We will show how this procedure works by means of a few examples.

Example 1: Calculating the lenght of a time interval.

Description of the data file

In our file two moments in time are recorded for every case. They are the starting time and the end time of an interview. We are interested in how much time each interview took. We want for each respondent the duration of the interview and we also want an overview of the duration for the entire survey process.

Our data file looks like this in the Variable View:

Calculating the duration of the interview is simple. Just subtract the starting time from the end time. You can see how to do that in the screens below.


Specifying the compute operation

We need to specify a name for the new target variable.
Note that a space is not allowed in any variable name. Hence we have used an underscore in the name.
Alternatively you can keep the name short and elaborate through . In this example we decided not to use that option.

Finally click OK to create a new variable, which contains the calculated interview duration for each respondent.

Note: In the Variable View you can see the new variable. If you like you can add a variable label afterwards instead of during the compute procedure. We chose for "Duration of the interview in seconds.". We also changed the number of decimals to 0. 


Using the new variable

We have created a histogram showing the distribution of the new variable interview duration.

A first draft of this graph looks like this:

We see 40 interviews that took less than 1000 seconds, one interview needed between 1000 and 2000 seconds (1567 seconds to be precise) and there is one extreme outlier of 5742 seconds. Apparently something special happened during these two interviews.

Of course you want to check what exactly went on there. But these outliers don't belong in our histogram. If we filter them using Data, Select Cases, IF (Interview_duration < 1000) our new histogram gives an overview of the duration of all the "normal" interviews.

Note that the time is in seconds; hence an interview took on average about 5 minutes, which seems ok.


Example 2: Calculating the average trust in other people

Source of this example: The World Values Survey; see www.worldvaluessurvey.org.

Description of the data file

In the survey people are asked the following questions:

trust questions

We would like to calculate the average of the answers that a respondent gave in order to have one number as an indication of his or her overall trust in other people. How can we compute this new variable "Trust"?

average trust

up to example 2 Up to example 2

Specifying the compute operation

In the compute dialog box you have a whole range of functions at your disposal to assist in your calculations.
For our case the function Mean is what we need. So we select it and move it to the field for the expression to be computed.

compute mean

Next we specify the mean of which arguments we want. In our case it is the mean of the questions related to trust in various groups of people.

compute average trust Once the expression is completed we click on OK to execute it.
The result is a new variable, called Trust, that is calculated for each respondent.
We can use it for further analysis.

up to example 2 Up to example 2

Using the new variable

We have constructed an error bar for the average trust that males and females have in other people.
Remember that lower numbers indicate more trust in other people.

average trust by gender

We see a minute difference in average trust between males and females. But this is insignificant compared to the margin of error for the averages themselves.



Last modified 30-10-2012

Jos Seegers, 2009; English version by Gé Groenewegen.