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.

Example<br />

DO IF 497<br />

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

COMPUTE BONUS = 0.<br />

ELSE.<br />

IF (DEPT87 EQ 1) BONUS = .12*SALARY87.<br />

IF (DEPT87 EQ 2) BONUS = .14*SALARY87.<br />

IF (DEPT87 EQ 3) BONUS = .1*SALARY87.<br />

IF (DEPT87 EQ 4) BONUS = .08*SALARY87.<br />

END IF.<br />

• If an individual was hired after 1987 (YRHIRED is greater than 87), BONUS is set to 0 and<br />

control passes out of the structure. Otherwise, control passes to the IF commands<br />

following ELSE.<br />

• Each IF command evaluates every case. The value of BONUS is transformed only when<br />

the case meets the criteria specified on IF. Compare this structure with ELSE IF in the<br />

second example on p. 498, which performs the same task more efficiently.<br />

Example<br />

* Test for listwise deletion of missing values.<br />

DATA LIST / V1 TO V6 1-6.<br />

BEGIN DATA<br />

123456<br />

56<br />

1 3456<br />

123456<br />

123456<br />

END DATA.<br />

DO IF NMISS(V1 TO V6)=0.<br />

+ COMPUTE SELECT=’V’.<br />

ELSE<br />

+ COMPUTE SELECT=’M’.<br />

END IF.<br />

FREQUENCIES VAR=SELECT.<br />

• If there are no missing values for any of the variables V1 to V6, COMPUTE sets the value<br />

of SELECT equal to V (for valid). Otherwise, COMPUTE sets the value of SELECT equal<br />

to M (for missing).<br />

• FREQUENCIES generates a frequency table for SELECT. The table gives a count of how<br />

many cases have missing values for one or more variables, and how many cases have<br />

valid values for all variables. <strong>Command</strong>s in this example can be used to determine how<br />

many cases are dropped from an analysis that uses listwise deletion of missing values.<br />

See pp. 257 and 740 for alternative ways to check listwise deletion of missing values.<br />

ELSE IF <strong>Command</strong><br />

ELSE IF executes one or more transformations when the logical expression on DO IF is not<br />

true.<br />

• Multiple ELSE IF commands are allowed within the DO IF—END IF structure.

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

Saved successfully!

Ooh no, something went wrong!