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.

Operations<br />

Example<br />

END CASE 509<br />

• When an END CASE command is encountered, the program suspends execution of the rest<br />

of the commands before the END INPUT PROGRAM command and passes control to the<br />

commands after the input program. After these commands are executed for the new case,<br />

control returns to the input program. The program continues building cases by processing<br />

the commands immediately after the most recent END CASE command. Use a loop to<br />

build cases from the same set of transformation and data definition commands.<br />

• When multiple END CASE commands are specified, the program follows the flow of the<br />

input program and builds a case whenever it encounters an END CASE command, using<br />

the set of commands executed since the last END CASE.<br />

• Unless LEAVE is specified, all variables are reinitialized each time the input program is<br />

resumed.<br />

• When transformations such as COMPUTE, definitions such as VARIABLE LABELS, and utilities<br />

such as PRINT are specified between the last END CASE command and END INPUT<br />

PROGRAM, they are executed while a case is being initialized, not when it is complete. This<br />

may produce undesirable results (see the example beginning on p. 514).<br />

* Restructuring a data file to make each data item a single case.<br />

INPUT PROGRAM.<br />

DATA LIST /#X1 TO #X3 (3(F1,1X)).<br />

VECTOR V=#X1 TO #X3.<br />

LOOP #I=1 TO 3.<br />

- COMPUTE X=V(#I).<br />

- END CASE.<br />

END LOOP.<br />

END INPUT PROGRAM.<br />

BEGIN DATA<br />

2 1 1<br />

3 5 1<br />

END DATA.<br />

FORMAT X(F1.0).<br />

PRINT / X.<br />

EXECUTE.<br />

• The input program encloses the commands that build cases from the input file. An input<br />

program is required because END CASE is used to create multiple cases from single input<br />

records.<br />

• DATA LIST defines three variables. In the format specification, the number 3 is a repetition<br />

factor that repeats the format in parentheses three times, once for each variable. The specified<br />

format is F1 and the 1X specification skips 1 column.<br />

• VECTOR creates the vector V with the original scratch variables as its three elements. The<br />

indexing expression on the LOOP command increments the variable #I three times to control<br />

the number of iterations per input case and to provide the index for the vector V.

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

Saved successfully!

Ooh no, something went wrong!