This SPSS tutorial explains how to filter data using Select Cases Function.
SPSS Select Cases (filter data)
In Excel, you can apply Autofilter and enter criteria to select data what you want. SPSS has similar function but it is called “Select Cases“. In this tutorial, we will talk about the options are available to facilitate data filtering.
Navigate to Data > Select Cases
There are several options in this Select Cases box. We will talk about each option in the below section.
SPSS Select Cases – If condition is satisfied
This option allows you to select data based on criteria.
Select the first option If condition is satisfied > click on If… button
For example, if we only want to use data where Salary is larger than 20000, then we type the followings in the text box
Type Salary > 20000
Press Continue button > Press OK button to exit the Select Cases dialog box
You can also use AND OR operator in the Text Box, for example
Salary>20000 AND Allowance=0 (0 can represent Null data)
Now you can see row 6 and row 8 (salary = 9545) have a slash on the row number. The slash means those rows are excluded in the dataset.
When you run statistics report, you will only find the population size N is only 6.
SPSS Select Cases – Random sample of cases
This option allows you to randomly select rows in the data.
Select the second option Random sample of cases > click on Sample… button
The first option is to filter a certain percentage of cases. But note that it is only “Approximately”, the number of cases filtered could vary significantly.
Lets say we enter 50% in the box. Go back to Data View and you can see only 3 cases out of 8 cases are filtered.
Go back to the previous screen and select the second option. Enter 4 cases from the first 7 cases. Click on Continue button and go back to Data View.
Now you can see 4 random rows from row 1 to 7 remain.
SPSS Select Cases – Based on time or case range
This option allows you to filter specific row number range.
Select the third option Based on time or case range > click on Range button
Enter 2 and 6 as follows
Go back to Data View, now you can see only row 2 to row 6 are left.
SPSS Select Cases – Use filter variable
This option is to manually select which row of data to include or exclude.
First, in Variable View, create a field called filterA
In the Select Cases Option, select the forth option Use filter variable and then move filterA to the box
Go back to Data View. Now you can enter “1” in filterA column to indicate you want to include that row of data, enter 0 (or Null input) to exclude data.