SPSS Tutorials

BASICS REGRESSION T-TEST CHI-SQUARE TEST ANOVA

SPSS FILTER – What and Why?

FILTER is an SPSS command for deactivating cases. Inactive cases are excluded from analysis and some data modifications (most notably AGGREGATE). Note that the status bar informs you whether a filter variable is in effect or not. SPSS Filter OnNotice “Filter On” in the status bar.

SPSS Filter - Basic Usage

Any regular variable can be specified as a filter variable.By “regular variable” we mean all variables that are not a scratch variable or a system variable. When a filter variable is in effect, all cases having either a

  1. Zero value or
  2. a system missing value or
  3. a user missing value

on the filter variable are (temporarily) deactivated. Similarly to WEIGHT and SPLIT FILE, FILTER has three main commands:

  1. FILTER BY [...]. switches a filter variable on. If a filter is already in effect, it can be used to set a different variable as the active filter.
  2. SHOW FILTER. shows which variable is the active filter variable.
  3. FILTER OFF. switches the filter variable off. After doing so, all cases in the data are active.

How Do I Get a Filter Variable?

Ideally, a filter variable has a value of 1 for cases you want to be visible and 0 for cases you want to deactivate. Such a variable may already exist in your data but you usually have to create it yourself. Keep in mind that it's just a normal variable. A great way for doing so is using Compute A = B = C. If you're not comfortable with that, use IF or RECODE. We recommend using a short variable name that indicates its role as a filter, for example filt_.... Add a variable label describing which cases it should select. It's fine to have multiple filter variables in your data but you can use only one at the time as the active filter.

SPSS Filter - Caveats

SPSS FilterStrikethrough when filter in effect. Note the absence for the case with a user missing value.

SPSS Filter Syntax Example

*1. Create some test data.
    
data list free/v1.
begin data
0 '' 9999 -100 -.001 .001 100
end data.

*2. Display three decimals to show difference small values and zero.

formats v1(f4.3).

*3. Specify user missing value.

missing values v1(9999).

*4. Filter.

filter by v1.

*5. Inspect which variable is used as filter.

show filter.

*6. Aggregate affected by filter.

aggregate outfile * mode addvariables
/case_count = n.

*7. Switch filter off.

filter off.

Previous tutorial: Comparing Metric Variables

Next tutorial: SPSS SELECT IF – A Quick Tutorial

Let me know what you think!

*Required field. Your comment will show up after approval from a moderator.

This tutorial has 6 comments