ARCHIVED: Restructure data in SPSS

This content has been archived, and is no longer maintained by Indiana University. Information here may no longer be accurate, and links may no longer be available or reliable.

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:

  1. From the Data tab, select Restructure.
  2. In the "Restructure" window, select Restructure selected variables into cases, and then click next.
  3. 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 next.
  4. Under "Case Group Identification", select Use selected variable. Enter ID in the relevant box.
  5. Under "Variables to be transposed", select trans1 for "target variable", and replace trans1 by typing WEIGHT; in the box underneath, type weight1, weight2, and weight3. Then, select trans2 for "target variable", and replace trans2 by typing CALORIES; in the box underneath, type calories1, calories2, and calories3. Click next.
  6. Under "How many index variables do you want to create?", select one. Click next.
  7. Under "Edit the index variable name and label", type TIME to replace index1. Click next.
  8. Under "Variables to Cases: Options", select the options you need. Click next.
  9. Under "Finish", select the options you need. Click Finish.

To restructure data from long format into wide format:

  1. From the Data tab, select Restructure.
  2. In the "Restructure" window, select Restructure selected cases into variables, and then click next.
  3. For "Identifier variable", enter ID. For "Index Variable" (variable that identifies each measure), enter TIME. Click next.
  4. Under "Sorting data", select Yes. Click Finish.

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.