Most of the time you want to analyze an entire data set. Sometimes, however, you
want to analyze only part of your data. Maybe you are interested only in the
unmarried respondents in your data set, or you need to exclude people
with incomes over $1,000,000, or even choose a random sample of your
respondents. We are going to dive deeper into how to select subsets of your data
in SPSS.
Sometimes you only need a portion of your data set for analysis. If you wanted
to do simple comparisons, you could use the Split File command, but we have even
more control for choosing our data by using Selection commands. Selection
allows you to analyze only a specific subgroup of your participants, usually by
identifying how they should be chosen using a formula. So, for instance, you
could select cases only over age 21, or cases over age 21 and married, or cases
over 21 and married and in the control group. Your criteria can include age
ranges, time or date ranges, case numbers, logical expressions, or functions. You can
even select a random sample of cases. For this example we are using the demo.sav
dataset that comes with SPSS. To find out how to open this dataset check the links
in the description.
We will begin by running some simple descriptive statistics. For all of the
cases in the data set, go to Analyze -> Descriptive Statistics -> Descriptives.
A little later, I'm going to use our familiar variables Age and Income
in some formulas, so we will start this example using another scale variable:
Years at Current Address, for each of these examples. Click OK and we have a
simple summary of our variable, including the number of scores. Let's use selection
commands to select specific cases. The procedure for selection will begin the
same way each time. From the menus choose Data -> Select Cases. This will open the
Select Cases dialog box. In this first example, we will select cases based upon
a conditional expression. A conditional expression sets conditions. It says
"select only cases that meet THIS criteria." For example, "select only cases
with incomes over $50,000" or "select only cases that are younger than 21" or "select
only cases who are married." This option says "select if condition is satisfied."
Click IF in the select cases dialog box. We can now select from among the
existing variables for those that fit our criteria. So we select cases whose
incomes are greater than 50, and if that is all that we want, we can click
Continue and OK. Let's check the numbers. Use the dialog recall button to bring
back the Descriptives dialog box. Our settings remain the same as before so
click OK. We can see the descriptive statistics
that apply only to our selected cases. Obviously, we have fewer cases because
we're considering only the ones that meet our income criteria. So now we can
do a t-test or a correlation and that analysis would include only these
selected cases.
SPSS gives us plenty of options for defining our selection criteria. We can
select cases using relational operators, in which we specify something about the
value of the variable, such as age less than or equal to 21. An arithmetic
operator adds a computation such as adding an employee's age to their years
of employment to create a variable about their qualification for retirement
benefits. Logical operators link two or more conditional expressions, such as
selecting anyone who is either under 21 OR unmarried using the pipe operator.
Or selecting someone who meets both of two criteria, such as income greater than 50
and who is retired. Finally, a function could allow us to
compute BMI and then to select only people whose BMI is under 30. So how does
this work? When you set up a selection criteria, such as income greater than 50,
SPSS examines each case for the criteria. So if the income is greater than 50, SPSS
returns a value of TRUE. If the income is not greater than 50, SPSS returns the
value FALSE. If there's no information in that variable, SPSS returns the value
MISSING. It continues to check every case in this same way. After that, SPSS ignores
all of the FALSE and MISSING cases and then selects only the cases that are
TRUE for further analysis. This decision-making is recorded in a new
variable called a "Filter."
Well that leaves the question "what do we do with all of those cases that we did
not select?" The safest option is just to create a filter that excludes the
unselected cases. Choose "filter out unselected cases." SPSS generates a filter
named "Filter_$" with a value of 1 for selected cases and a
value of 0 for unselected cases. Unselected cases are not included in the
analysis when this filter is active, but those cases still remain in your dataset.
In Data View, you can see that the unselected cases are marked in the data
editor with a diagonal line through its row number. You can use a filter to throw
out the unselected cases. Perhaps your research only concerns women. You select
only the females in your data set and you choose "delete unselected cases."
Anyone who is not female is then deleted from the dataset. Now, be sure that this
is REALLY what you want to do, because if you save this data set, you cannot
recover the deleted data. Another option is to export only your selected cases
into a new dataset, leaving the original dataset untouched. Suppose that you are
working with some other students on a massive data set and your job is to
analyze only the people who are married. You select only the married cases and
you choose "copy selected cases to a new dataset." You get a new SPSS dataset
containing only the married cases, but leaving your original dataset unaffected.
When you are done using a filter you have some options to quit using it.
Number one, you can turn off all filters by going to Data -> Select Cases and either
choosing "select all cases" and clicking OK, or simply clicking Reset. With syntax,
you can type "USE ALL." "EXECUTE." Number two, if you have multiple
filters, you can choose which one to apply by going to Data -> Select Cases and
then choose "use filter variable" and move the filter into the box. Click OK
And number three, if you know that you will not need the filter again you can
delete the filter from the variables list.