Skip to content

5.2.3 Inverting negatively coded variables ​

Data entry errors are not the only reason for wanting to recode data. The sample file hotel.sav comprises data gathered from a customer satisfaction survey of clients at a particular hotel. The following commands load the file and display its variables and associated data:

PSPP> get file='/usr/local/share/pspp/examples/hotel.sav'.
PSPP> display dictionary.

It yields the following output:

NamePositionLabelMeasurement LevelRoleWidthAlignmentPrint FormatWrite Format
v11I am satisfied with the level of serviceOrdinalInput8RightF8.0F8.0
v22The value for money was goodOrdinalInput8RightF8.0F8.0
v33The staff were slow in respondingOrdinalInput8RightF8.0F8.0
v44My concerns were dealt with in an efficient mannerOrdinalInput8RightF8.0F8.0
v55There was too much noise in the roomsOrdinalInput8RightF8.0F8.0
Variable ValueLabel
I am satisfied with the level of service1Strongly Disagree
2Disagree
3No Opinion
4Agree
5Strongly Agree
The value for money was good1Strongly Disagree
2Disagree
3No Opinion
4Agree
5Strongly Agree
The staff were slow in responding1Strongly Disagree
2Disagree
3No Opinion
4Agree
5Strongly Agree
My concerns were dealt with in an efficient manner1Strongly Disagree
2Disagree
3No Opinion
4Agree
5Strongly Agree
There was too much noise in the rooms1Strongly Disagree
2Disagree
3No Opinion
4Agree
5Strongly Agree

The output shows that all of the variables v1 through v5 are measured on a 5 point Likert scale, with 1 meaning “Strongly disagree” and 5 meaning “Strongly agree”. However, some of the questions are positively worded (v1 , v2 , v4) and others are negatively worded (v3 , v5). To perform meaningful analysis, we need to recode the variables so that they all measure in the same direction. We could use the RECODE command, with syntax such as:

recode v3 (1 = 5) (2 = 4) (4 = 2) (5 = 1).

However an easier and more elegant way uses the COMPUTE command (see COMPUTE). Since the variables are Likert variables in the range (1 … 5), subtracting their value from 6 has the effect of inverting them:

compute var = 6 - var.

The following section uses this technique to recode the variables v3 and v5. After applying COMPUTE for both variables, all subsequent commands will use the inverted values.

基于 GNU PSPP 2.0.1 手册与入门教程整理