- Welcome
- Important notice
- About the author
- About this site
- Site guide + Search box
- Dedications
- Acknowledgments
- My personal pantheon (of the great and the good in survey research)
- Recent and planned activities
- Textbooks for Research Methods and Data Analysis
- 1: Survey Analysis Workshop (SPSS)
- 1a: Statistical concepts and methods
- 1b: Teaching with Survey Data
- 1c: Developing research projects using survey data
- 1d: Workshop and presentations for ASSESS (SPSS users in Europe)
- 2: Survey Research Practice
- 2a: Survey Research Methodology, Practice and Training
- 2b: Major survey series
- 3: Subjective Social Indicators (Quality of Life)
- 4: Survey Unit, Social Science Research Council (UK)
- 5a: Polytechnic of North London (1976-1992)
- 5b: Survey Research Unit (1978-1992)
- Village life in Normandy
- Contact
- Origins of the British Crime Survey
- British Crime Survey
2.3: Data transformations
[Page last updated: 14 January 2020]
Selecting variables for analysis, changing the names of variables, changing the values of variables. Creating new variables from existing ones. Selecting cases for analysis as a transition from analysing one variable to analysing two or more variables.
We have now reached the stage where you are about to experience a change of gear, moving from one variable to two variables and then three (or more). Some of the exercises in Block 3 for 2- and 3-way CROSSTABS (zero order and 1st order tables) involve some quite complex recoding of variables (qualifications obtained by education or training, combinations of income from various sources) to generate derived variables with two to five categories suitable for beginners to tabulate.
Doing this yourselves from raw data files would be quite daunting (and possibly unsuccessful). For the more adventurous of you, I am working on supplementary exercises to do this in syntax yourselves.
To make things easier I have uploaded a few entire surveys in SPSS *.sav format. These files include some derived variables, but we shall be modifying them or creating others. We shall be working with complete data sets from major surveys and need to download some raw data *.txt files and some SPSS *.sav files from this site. The simplest solution is to download and save them to a memory stick or a CD on your own computer.
2.3.0 Preliminary file downloads shows you how to do this. Later versions of SPSS can now open and work on files immediately they are downloaded from this site. From now on, tutorials will use selected *.txt raw data files and (extracts from) SPSS *.sav and occasional *.sps files.
The first set of files we shall be using are:
Raw data files
bsa86.txt British Social Attitudes 1986 (3.3 mb)
bsa89.txt British Social Attitudes 1989 (excluding Northern Ireland) (3.9 mb)
myclass.txt Cumulative raw data set (6 kb)
SPSS saved files
bsa86.sav British Social Attitudes 1986 (2.0 mb)
newbsa89.sav British Social Attitudes 1989 (excluding Northern Ireland) (3.2 mb)
fifthx.sav Fifth Form Survey (67 kb)
myclass.sav Initial cumulative data from pre-course questionnaire (6 kb)
qlgb75.sav Quality of Life in Britain 1975 (185 kb)
As we progress through the course, we may also be using files from later waves of the British Social Attitudes survey, or from other major surveys such as the NORC General Social Survey (University of Chicago, USA) and the European Social Survey.
Screen messages during data transformations is a specimen work-through to create two new variables, agedecade and agegroup from existing variable age in myclass.sav (my version of the initial data from the pre-course questionnaire). After these transformations, the new variables are set to SPSS defaults which some of you may be tempted to edit in your Data Editor using the GUI. The work-through demonstrates some of the unexpected problems you may encounter, how to get round them, and suggests alternatives using syntax.
2.3.1.1 Data transformations is an Introductory tutorial.
The following work-through exercises are beta versions using data from the main 1986 BSA survey.
2.3.1.2a1 Select and rename variables
Exercise using SPSS command GET. . . /KEEP to select variables from the main 1986 BSA survey,
change the variable names and edit variable properties.
2.3.1.2a2 Recode into new variable
Exercise to create a new variable using RECODE ... INTO
The following homework exercises are beta versions using data from the main 1989 BSA survey.
2.3.1.2b1 Select, rename and recode homework
Homework exercise using SPSS command GET. . . /KEEP to select variables from the main 1989
BSA survey, change the variable names and edit variable properties.
2.3.1.2b2 Select, rename and recode specimen answer
Specimen answer for homework exercise to create a new variable using RECODE ... INTO
Includes a bit of housekeeping to avoid clutter
2.3.1.3 Conditional frequencies exercise
Research question: What is the distribution of respondents' personal gross income from paid work? What
shape does the distribution have? What is the distribution for women only? What is the distribution for men
only? Are there any differences?
2.3.1.4 Specimen answers for exercise 2.3.1.3 (Conditional frequencies)
This is the final draft of a very extended and detailed exercise: it's quite long (26 pages) but manageable. It uses data from the 1986 British Social Attitudes survey as an exemplar in preparation for moving from
analysing one variable to analysing two or more variables.
[Brand new homework beta versions added 2July 2013]
2.3.1.5 Conditional frequencies homework [BSA89]
Repeats exercise 2.3.1.3 on the same variables from the 1989 British Social Attitudes survey.
[Specimen answers for 2.3.1.5]
2.3.1.6.1 Specimen answer for conditional frequencies homework [Tasks 1 and 2]
(also creates SPSS files 2.3.1.6.1.sps and 2.3.1.6.1.sav)
2.3.1.6.2 Specimen answer for conditional frequencies homework [Tasks 3 and 4]
(also creates 2.3.1.6.2.sps)
See also: 3.4 Conditional data transformations and 3.5 Derived variables COUNT and COMPUTE
Forward to page: Block 3: Analysing two variables ( and sometimes three)
Back to page: Block 2: Analysing one variable
Back to page: Summary guide to SPSS tutorials
Selecting variables for analysis, changing the names of variables, changing the values of variables. Creating new variables from existing ones. Selecting cases for analysis as a transition from analysing one variable to analysing two or more variables.
We have now reached the stage where you are about to experience a change of gear, moving from one variable to two variables and then three (or more). Some of the exercises in Block 3 for 2- and 3-way CROSSTABS (zero order and 1st order tables) involve some quite complex recoding of variables (qualifications obtained by education or training, combinations of income from various sources) to generate derived variables with two to five categories suitable for beginners to tabulate.
Doing this yourselves from raw data files would be quite daunting (and possibly unsuccessful). For the more adventurous of you, I am working on supplementary exercises to do this in syntax yourselves.
To make things easier I have uploaded a few entire surveys in SPSS *.sav format. These files include some derived variables, but we shall be modifying them or creating others. We shall be working with complete data sets from major surveys and need to download some raw data *.txt files and some SPSS *.sav files from this site. The simplest solution is to download and save them to a memory stick or a CD on your own computer.
2.3.0 Preliminary file downloads shows you how to do this. Later versions of SPSS can now open and work on files immediately they are downloaded from this site. From now on, tutorials will use selected *.txt raw data files and (extracts from) SPSS *.sav and occasional *.sps files.
The first set of files we shall be using are:
Raw data files
bsa86.txt British Social Attitudes 1986 (3.3 mb)
bsa89.txt British Social Attitudes 1989 (excluding Northern Ireland) (3.9 mb)
myclass.txt Cumulative raw data set (6 kb)
SPSS saved files
bsa86.sav British Social Attitudes 1986 (2.0 mb)
newbsa89.sav British Social Attitudes 1989 (excluding Northern Ireland) (3.2 mb)
fifthx.sav Fifth Form Survey (67 kb)
myclass.sav Initial cumulative data from pre-course questionnaire (6 kb)
qlgb75.sav Quality of Life in Britain 1975 (185 kb)
As we progress through the course, we may also be using files from later waves of the British Social Attitudes survey, or from other major surveys such as the NORC General Social Survey (University of Chicago, USA) and the European Social Survey.
Screen messages during data transformations is a specimen work-through to create two new variables, agedecade and agegroup from existing variable age in myclass.sav (my version of the initial data from the pre-course questionnaire). After these transformations, the new variables are set to SPSS defaults which some of you may be tempted to edit in your Data Editor using the GUI. The work-through demonstrates some of the unexpected problems you may encounter, how to get round them, and suggests alternatives using syntax.
2.3.1.1 Data transformations is an Introductory tutorial.
The following work-through exercises are beta versions using data from the main 1986 BSA survey.
2.3.1.2a1 Select and rename variables
Exercise using SPSS command GET. . . /KEEP to select variables from the main 1986 BSA survey,
change the variable names and edit variable properties.
2.3.1.2a2 Recode into new variable
Exercise to create a new variable using RECODE ... INTO
The following homework exercises are beta versions using data from the main 1989 BSA survey.
2.3.1.2b1 Select, rename and recode homework
Homework exercise using SPSS command GET. . . /KEEP to select variables from the main 1989
BSA survey, change the variable names and edit variable properties.
2.3.1.2b2 Select, rename and recode specimen answer
Specimen answer for homework exercise to create a new variable using RECODE ... INTO
Includes a bit of housekeeping to avoid clutter
2.3.1.3 Conditional frequencies exercise
Research question: What is the distribution of respondents' personal gross income from paid work? What
shape does the distribution have? What is the distribution for women only? What is the distribution for men
only? Are there any differences?
2.3.1.4 Specimen answers for exercise 2.3.1.3 (Conditional frequencies)
This is the final draft of a very extended and detailed exercise: it's quite long (26 pages) but manageable. It uses data from the 1986 British Social Attitudes survey as an exemplar in preparation for moving from
analysing one variable to analysing two or more variables.
[Brand new homework beta versions added 2July 2013]
2.3.1.5 Conditional frequencies homework [BSA89]
Repeats exercise 2.3.1.3 on the same variables from the 1989 British Social Attitudes survey.
[Specimen answers for 2.3.1.5]
2.3.1.6.1 Specimen answer for conditional frequencies homework [Tasks 1 and 2]
(also creates SPSS files 2.3.1.6.1.sps and 2.3.1.6.1.sav)
2.3.1.6.2 Specimen answer for conditional frequencies homework [Tasks 3 and 4]
(also creates 2.3.1.6.2.sps)
See also: 3.4 Conditional data transformations and 3.5 Derived variables COUNT and COMPUTE
Forward to page: Block 3: Analysing two variables ( and sometimes three)
Back to page: Block 2: Analysing one variable
Back to page: Summary guide to SPSS tutorials