Differences between revisions 1 and 4 (spanning 3 versions)
Revision 1 as of 2023-05-31 17:31:53
Size: 1581
Comment:
Revision 4 as of 2023-06-10 13:26:06
Size: 1907
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

SPSS supports the following '''logic structures''' for programming.
Line 25: Line 27:

Parentheses are used to control the order of operations between multiple relations.
Line 66: Line 70:
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 takes effect immediately and does not read data will be executed unconditionally. This includes [[SPSS/ValueLabels|VALUE LABELS]], [[SPSS/MissingValues|MISSING VALUES]], [[SPSS/VariableLabel|VARIABLE LABEL]], and [[SPSS/Weight|WEIGHT]].
Line 68: Line 72:
Any command that does not require an active dataset will be executed unconditionally. This includes `DISPLAY`, `HOST`, `INSERT`, `OMS`, and `SET`. Any command that does not require an active dataset will be executed unconditionally. This includes [[SPSS/Display|DISPLAY]], [[SPSS/Host|HOST]], [[SPSS/Insert|INSERT]], [[SPSS/OutputManagementSystem|OMS]], and [[SPSS/Set|SET]].
Line 70: Line 74:
The `GET` command is executed unconditionally. The [[SPSS/Get|GET]] command is executed unconditionally.

SPSS Logic

SPSS supports the following logic structures for programming.


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)