Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Statscraft 0.61.0, release v0.61.0

SELECT IF

Keep only the cases where a condition holds.

Syntax

SELECT IF condition.

The command keeps the cases where the condition is true and drops the others, also those where it is missing. The cases are gone for every later command; after TEMPORARY the selection holds only for the next procedure. FILTER hides cases without deleting them. Like other transformations, it runs when the next procedure or EXECUTE reads the data.

Example

GET FILE='survey.sav'.
SELECT IF (region = 3).
FREQUENCIES satisfaction.
GET FILE='survey.sav'.
SELECT IF (age >= 30 AND age < 60 AND NOT MISSING(spend)).
DESCRIPTIVES age spend.

The example reads the sample data file survey.sav, an invented customer survey; save it in the folder you run the syntax from.

Example output

Descriptive Statistics

VariableLabelNMeanStd DevMinimumMaximum
ageAge in years20544.767.873059
spendMonthly spend in euros20538.2812.8113.6394.52
Valid N (listwise)205
Missing N (listwise)0

statscraft help SELECT IF prints the same text in the terminal. All commands