ARCHIVED: Restructure data in SPSS
You can analyze repeated measures data using various approaches, such as repeated measures ANOVA/GLM (the multilevel model) or the linear mixed model. Each of these approaches requires a different way of setting up the data in SPSS. Below are two different ways to set up repeated measures data, namely, the long format and the wide format.
The long format uses multiple rows for each observation or participant:
ID WEIGHT CALORIES TIME 1 200 3500 1 1 190 3300 2 1 180 3100 3 2 160 3000 1 2 150 2900 2 2 140 2800 3
The wide format uses one row for each observation or participant:
ID weight1 weight2 weight3 calories1 calories2 calories3 1 200 190 180 3500 3300 3100 2 160 150 140 3000 2900 2800
This example data contains two participants measured on two outcome variables (weight and calories), under three different time points.
You can convert data structures by using the point-and-click function in SPSS.
To restructure data from wide format into long format in SPSS, using the sample data above:
- From the tab, select .
- In the "Restructure" window, select , and then click .
- Under "How many variable groups do you want to restructure?", select the correct number (in the example here, there are two variables, weight and calories). Click .
- Under "Case Group Identification", select
ID
in the relevant box.
. Enter - Under "Variables to be transposed", select
trans1
by typingWEIGHT
; in the box underneath, typeweight1, weight2, and weight3
. Then, select for "target variable", and replacetrans2
by typingCALORIES
; in the box underneath, typecalories1, calories2, and calories3
. Click .
for "target variable", and replace - Under "How many index variables do you want to create?", select . Click .
- Under "Edit the index variable name and label", type
TIME
to replaceindex1
. Click . - Under "Variables to Cases: Options", select the options you need. Click .
- Under "Finish", select the options you need. Click .
To restructure data from long format into wide format:
- From the tab, select .
- In the "Restructure" window, select , and then click .
- For "Identifier variable", enter
ID
. For "Index Variable" (variable that identifies each measure), enterTIME
. Click . - Under "Sorting data", select . Click .
If you have questions about using statistical and mathematical software at Indiana University, contact the UITS Research Applications and Deep Learning team.
This is document bbqj in the Knowledge Base.
Last modified on 2023-05-09 14:43:00.