27.03.2013 Views

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

NOT Logical Operator<br />

Transformation Expressions 51<br />

The NOT logical operator reverses the true/false outcome of the expression that immediately<br />

follows.<br />

• The NOT operator affects only the expression that immediately follows, unless a more<br />

complex logical expression is enclosed in parentheses.<br />

• The valid substitute for NOT varies from operating system to operating system. In<br />

general, the tilde (~) is valid for ASCII systems, while ¬ (or the symbol over number 6<br />

on the keyboard) is valid for IBM EBCDIC systems. See the SPSS Base User’s Guide<br />

for your version of SPSS.<br />

• NOT can be used to check whether a numeric variable has the value 0, 1, or any other<br />

value. For example, all scratch variables are initialized to 0. Therefore, NOT (#ID) returns<br />

false or missing when #ID has been assigned a value other than 0.<br />

AND and OR Logical Operators<br />

Two or more relations can be logically joined using the logical operators AND and OR.<br />

Logical operators combine relations according to the following rules:<br />

• The ampersand (&) symbol is a valid substitute for the logical operator AND. The vertical<br />

bar ( | ) is a valid substitute for the logical operator OR.<br />

• Only one logical operator can be used to combine two relations. However, multiple<br />

relations can be combined into a complex logical expression.<br />

• Regardless of the number of relations and logical operators used to build a logical<br />

expression, the result is either true, false, or indeterminate because of missing values.<br />

• Operators or expressions cannot be implied. For example, X EQ 1 OR 2 is illegal; you must<br />

specify X EQ 1 OR X EQ 2.<br />

• The ANY and RANGE functions can be used to simplify complex expressions.<br />

AND Both relations must be true for the complex expression to be true.<br />

OR If either relation is true, the complex expression is true.<br />

Table 5 lists the outcome for AND and OR combinations.<br />

Table 5 Outcome for AND and OR combinations<br />

Expression Outcome Expression Outcome<br />

true AND true = true true OR true = true<br />

true AND false = false true OR false = true<br />

false AND false = false false OR false = false<br />

true AND missing = missing true OR missing = true *<br />

missing AND missing = missing missing OR missing = missing<br />

* Expressions where SPSS can evaluate the outcome with incomplete information. See “Missing<br />

Values in Logical Expressions” below.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!