The SPSS EnvironmentThe Data View WindowUsing SPSS SyntaxData Creation in SPSSImporting Data into SPSSCreating and Deleting CasesCreating and Deleting VariablesVariable TypesDate-Time Variables in SPSSDefining VariablesRecoding VariablesAutomatic RecodeComputing VariablesSorting DataSplitting DataWeighting Cases
DescriptivesCompare MeansExploreFrequencies Part I (Continuous Data)Frequencies Part II (Categorical Data)Crosstabs
Pearson Correlation (bivariate)One Sample t TestIndependent Samples t Test
This is the "Sorting Data" page of the "SPSS Tutorials" guide.
Alternate Page for Screenreader Users
Skip to Page Navigation
Skip to Page Content
*To search for student contact information, login to FlashLine and choose the "Directory" icon in the FlashLine masthead (blue bar).

SPSS Tutorials   Tags: spss, statistics, tutorials  

This LibGuide contains written and illustrated tutorials for the statistical software SPSS.
Last Updated: Sep 12, 2014 URL: http://libguides.library.kent.edu/SPSS Print Guide RSS UpdatesEmail Alerts

Sorting Data Print Page
  Search: 
 
 

Sorting Data

Sorting data allows us to re-organize the data in ascending or descending order with respect to a specific variable. Some procedures in SPSS require that your data be sorted in a certain way before the procedure will execute. There are two options for sorting data:

  1. Sort Cases (i.e., row sort)
  2. Sort Variables (i.e., column sort)

We cover how to perform each sorting option below.

 

Sort Cases

Sorting cases will rearrange the rows based on a given variable (or variables). The values for the selected variables can be sorted in ascending or descending order.

You can quickly sort your data with respect to a single variable by right-clicking on the variable name and selecting "Sort Ascending" or "Sort Descending."

If you want to sort your data with respect to two or more variables, or if you want to have the sorted data written to a new file, click Data > Sort Cases.


The Sort Cases window opens and you can proceed with the following steps:

1. Decide which variables you would like to use as the criteria for sorting cases. The variables in your dataset will appear on the left-hand side of the window.

2. Move your selected variable(s) to the right Sort by area by using the arrow button in the center (or by double-clicking on the variable name). In this example, the variable School_Class was selected.

3. In the Sort Order area, cases can be sorted in “Ascending” or “Descending” order. Click the radio button that corresponds to your choice. In this example, the variable School_Class will be sorted in ascending order, and an “(A)” appears to the right of the variable name to indicate this sorting choice. (This means that values will be ordered from smallest to largest.) Alternatively, descending order is indicated by a “(D)” next to the selected variable (and will order the values from largest to smallest).

4. You can also sort cases according to more than one variable. The variable Enrollment_Date has also been selected, and will also be sorted in ascending order. 

5. If you wish to save your newly sorted data to a new file, select the Save file with sorted data check box in the Save Sorted Data area. Then click File to specify a name and location for the new dataset file.

When you are finished, click OK.

You can check that your cases were sorted correctly by visually inspecting the data in Data View. In this example, cases have been sorted first according to the School_Class variable, and then according to the Enrollment_Date variable. (That is, all of the "1"'s (freshmen) are listed first, and then they organized from earliest date of enrollment to latest date of enrollment with respect to the other freshmen.)

 

Sort Variables

Sorting variables will rearrange the order of the variables (columns) in your data. Variables can be sorted on only one attribute: Name, Type, Width, Decimals, Label, Values, Missing, Columns, Align, Measure, or a custom attribute. Variables can be sorted in ascending or descending order with respect to the selected attribute.

To sort variables, follow these steps:

1. Click Data > Sort Variables.

2. The Sort Variables window opens.

3. The Variable View Columns list includes the attributes of variables that may be used to sort variables, including: name, type, width, decimals, label, values, missing, columns, align, measure. Select an attribute by clicking it in the list, which will highlight your selection. Note that you can only select one variable attribute. In this example, “Name” has been selected, which means that variables will be sorted according to their names.

4. In the Sort Order area, variables can be sorted in “Ascending” or “Descending” order. Click the radio button that corresponds to your choice. In this example, variables will be sorted in ascending order.

5. You may also choose to save the current (pre-sorted) variable order in a new attribute by selecting the Attribute name check box and typing a name into the text field. Custom attributes are simply user-defined characteristics of variables that can be used to sort variables.

When you are finished, click OK.

Now your variables will be sorted according to the attribute you selected. In this example, the variables are sorted in ascending order according to their names (i.e., alphabetically).

 

Description

Loading  Loading...

Tip