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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Flow of Control<br />

DO IF 495<br />

• If the logical expression on DO IF is true, the commands immediately following DO IF are<br />

executed up to the next ELSE IF, ELSE, or END IF command. Control then passes to the<br />

first statement following END IF.<br />

• If the expression on DO IF is false, control passes to the following ELSE IF command.<br />

Multiple ELSE IF commands are evaluated in the order in which they are specified until<br />

the logical expression on one of them is true. <strong>Command</strong>s following that ELSE IF<br />

command are executed up to the ELSE or END IF command, and control passes to the first<br />

statement following END IF.<br />

• If none of the expressions are true on the DO IF or any of the ELSE IF commands, the<br />

commands following ELSE are executed and control passes out of the structure. If there<br />

is no ELSE command, a case goes through the entire structure with no change.<br />

• Missing values returned by the logical expression on DO IF or on any ELSE IF cause<br />

control to pass to the END IF command at that point.<br />

Missing Values and Logical Operators<br />

Example<br />

When two or more relations are joined by logical operators AND and OR, the program<br />

always returns missing if all of the relations in the expression are missing. However, if any<br />

one of the relations can be determined, the program tries to return true or false according<br />

to the logical outcomes shown in Table 1. The asterisk indicates situations where the<br />

program can evaluate the outcome with incomplete information.<br />

Table 1 Logical outcome<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 />

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

DO IF (YRHIRED LT 87).<br />

RECODE RACE(1=5)(2=4)(4=2)(5=1).<br />

END IF.<br />

• The RECODE command recodes RACE for those individuals hired before 1987 (YRHIRED<br />

is less than 87). The RACE variable is not recoded for individuals hired in 1987 or later.<br />

• The RECODE command is skipped for any case with a missing value for YRHIRED.

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

Saved successfully!

Ooh no, something went wrong!