IBM Support

Using OR in a conditional statement.

Troubleshooting


Problem

I am using SPSS/Statistics and am trying to construct a conditional statement for a variable. I think I need to use an OR within the statement but SPSS keeps ignoring it when I run the select if. How do I use an OR to get what I want?

Resolving The Problem

To use OR successfully, first go to Data->Select Cases->If condition is satisfied. Click over the variable you want to include in the conditional statement followed by an equal sign and the condition. Then press the pipe symbol in the keypad which looks like this, '|'. This pipe stands for OR. You could also type in OR in the box. Next click over the variable name again followed by an equals sign and the second condition. Press continue and then OK.

If you wanted to select only cases for the variable SEX that equaled 1 OR 2, it would look like the example below in SPSS Command Syntax:

FILTER OFF.
USE ALL.
SELECT IF(SEX = 1 | SEX = 2).
EXECUTE .

Remember using an OR in your condition will allow for more cases to be included. The use of AND will restrict the condition.

[{"Product":{"code":"SSLVMB","label":"IBM SPSS Statistics"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Not Applicable","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"19.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Historical Number

25468

Document Information

More support for:
IBM SPSS Statistics

Software version:
19.0

Document number:
418859

Modified date:
16 April 2020

UID

swg21477399

Manage My Notification Subscriptions