Skip to Main Content

Getting Started with SPSS

Sorting Data

There are two ways to sort data in SPSS:

  1. Sort Cases
  2. Sort Variables

Sorting Cases

Sorting cases allow users to reorder the sequence of the cases based on the value of one or more variables.

WARNING: The original order will be lost once the cases of the dataset are sorted.

  • Quick sorting cases (only for sorting data based on a single variable)

In the Data View, right-click the name of the variable and select Sort Ascending or Sort Descending.

  • Sorting Cases (sorting data based on multiple variables)
  1. From the menu, choose Data > Sort Cases. The “Sort Cases” dialog box will appear.
  2. Add the variable(s) you want to sort the data by to the Sort by box by double-clicking the variable(s) in the left column.  If you select multiple variables, the order in which they appear on the Sort By list determines the order in which the cases are sorted. In this example, the data will first be sorted by age and then be sorted by household income within categories of age.

  1. Indicate the sorting order for each variable in the Sort By list by selecting “Ascending” or “Descending” in the Sort Order area.
  2. Optionally, you can save the sorted data in a new file by ticking Save file with sorted data. In this way, the original data order can be kept.
  3. Click OK to finish.

Sort Variables

Sorting variables allow users to reorder the variables based on the variable attribute (variable name, data type, width, etc.).

  • Quick sorting variables

In the Variable View, right-click the attribute column heading on which you want to sort the variables and select Sort Ascending or Sort Descending.

  • Sorting variables
  1. From the menu, choose Data > Sort Variables. The “Sort Variables” dialog box will appear.
  2. Select the attribute

  1. Indicate the sorting order for each variable in the Sort By list by selecting “Ascending” or “Descending” in the Sort Order area.
  2. Optionally, you can save the original (pre-sorted) variable order in a custom variable attribute.
  3. Click OK to finish.

McGill LibraryQuestions? Ask us!
Privacy notice