In SPSS, how can I restructure data?

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.

Restructuring data

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 Research Analytics. Research Analytics is located on the IU Bloomington campus at Woodburn Hall 200; staff are available for consultation Monday-Friday 9am-noon and by appointment.

This is document bbqj in the Knowledge Base.
Last modified on 2015-06-29 00:00:00.

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.

Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.