Differences between revisions 1 and 2
Revision 1 as of 2023-05-31 17:31:53
Size: 1581
Comment:
Revision 2 as of 2023-05-31 17:36:43
Size: 1668
Comment:
Deletions are marked like this. Additions are marked like this.
Line 25: Line 25:

Parentheses are used to control the order of operations between multiple relations.

SPSS Logic


Operators

The following logical operators are valid for logic control of SPSS commands.

Operator

EQ or =

NE or ~= or ¬= or <>

LT or <

LE or <=

GT or >

GE or >=

AND or &

OR or |

NOT

The OR operator short circuits.

Parentheses are used to control the order of operations between multiple relations.


Conditional Processing

Use DO IF structures for conditional processing of SPSS commands.

do if (foo = 1).
  compute bar = 1.
else if (foo = 2).
  compute bar = 2.
else.
  compute bar = 3.
end if.

If any variable referenced in a condition is a missing value, the case falls through the structure and no commands execute for it.

do if missing(foo).
  compute bar = 0.
else if (foo = 1).
  compute bar = 1.
else if (foo = 2).
  compute bar = 2.
else.
  compute bar = 3.
end if.

DO IF structures can be nested arbitrarily.

Limitations

Any command that requires an immediate data pass cannot be used in a DO IF structure. This includes most statistics and graphic commands.

Any command that takes effect immediately and does not read data will be executed unconditionally. This includes VALUE LABELS, MISSING VALUES, VARIABLE LABEL, and WEIGHT.

Any command that does not require an active dataset will be executed unconditionally. This includes DISPLAY, HOST, INSERT, OMS, and SET.

The GET command is executed unconditionally.


CategoryRicottone

SPSS/Logic (last edited 2023-06-12 15:41:48 by DominicRicottone)