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.

<strong>Syntax</strong> Rules<br />

SELECT IF 1479<br />

• Logical expressions can be simple logical variables or relations, or complex logical tests<br />

involving variables, constants, functions, relational operators, and logical operators. The<br />

logical expression can use any of the numeric or string functions allowed in COMPUTE<br />

transformations (see COMPUTE and see “Transformation Expressions” on p. 37 in<br />

Volume I).<br />

• Parentheses can be used to enclose the logical expression. Parentheses can also be used<br />

within the logical expression to specify the order of operations. Extra blanks or parentheses<br />

can be used to make the expression easier to read.<br />

• A relation can compare variables, constants, or more complicated arithmetic expressions.<br />

Relations cannot be abbreviated. For example, (A EQ 2 OR A EQ 5) is valid while<br />

(A EQ 2 OR 5) is not. Blanks (not commas) must be used to separate relational operators<br />

from the expressions being compared.<br />

• A relation cannot compare a string variable to a numeric value or variable, or vice versa.<br />

A relation cannot compare the result of the logical functions SYSMIS, MISSING, ANY, or<br />

RANGE to a number.<br />

• String values used in expressions must be specified in quotation marks and must include<br />

any leading or trailing blanks. Lowercase letters are considered distinct from uppercase<br />

letters.<br />

Operations<br />

• SELECT IF permanently selects cases. Cases not selected are dropped from the working<br />

data file.<br />

• The logical expression is evaluated as true, false, or missing. If a logical expression is<br />

true, the case is selected; if it is false or missing, the case is not selected.<br />

• Multiple SELECT IF commands issued prior to a procedure command must all be true for<br />

a case to be selected.<br />

• SELECT IF should be placed before other transformations for efficiency considerations.<br />

• Logical expressions are evaluated in the following order: first numeric functions, then exponentiation,<br />

then arithmetic operators, then relational operators, and last logical operators.<br />

Use parentheses to change the order of evaluation.<br />

• If N OF CASES is used with SELECT IF, the program reads as many records as required to<br />

build the specified n cases. It makes no difference whether the N OF CASES precedes or<br />

follows the SELECT IF.<br />

• System variable $CASENUM is the sequence number of a case in the working data file.<br />

Although it is syntactically correct to use $CASENUM on SELECT IF, it does not produce<br />

the expected results. To select a set of cases based on their sequence in a file, create your<br />

own sequence variable with the transformation language prior to selecting (see the<br />

example below).

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

Saved successfully!

Ooh no, something went wrong!