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.

Options<br />

LOOP—END LOOP 831<br />

Missing Values. You can prevent cases with missing values for any of the variables used in<br />

the loop structure from entering the loop (see “Missing Values” on p. 837).<br />

Creating Data. A loop structure within an input program can be used to generate data (see<br />

“Creating Data” on p. 838).<br />

Defining Complex File Structures. A loop structure within an input program can be used to define<br />

complex files that cannot be handled by standard file definition facilities (see pp. 509,<br />

510, and 512 for examples).<br />

Basic Specification<br />

The basic specification is LOOP followed by at least one transformation command. The structure<br />

must end with the END LOOP command. <strong>Command</strong>s within the loop are executed until<br />

the cutoff is reached.<br />

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

• If LOOP and END LOOP are specified before a working data file exists, they must be specified<br />

within an input program.<br />

• If both an indexing and an IF clause are used on LOOP, the indexing clause must be first.<br />

• Loop structures can be nested within other loop structures or within DO IF structures, and<br />

vice versa.<br />

Operations<br />

Example<br />

• The LOOP command defines the beginning of a loop structure and the END LOOP command<br />

defines its end. The END LOOP command returns control to LOOP unless the cutoff<br />

has been reached. When the cutoff has been reached, control passes to the command immediately<br />

following END LOOP.<br />

• When specified within a loop structure, definition commands (such as MISSING VALUES<br />

and VARIABLE LABELS) and utility commands (such as SET and SHOW) are invoked only<br />

once, when they are encountered for the first time within the loop.<br />

SET MXLOOPS=10.<br />

LOOP. /*Loop with no limit other than MXLOOPS<br />

COMPUTE X=X+1.<br />

END LOOP.<br />

• This and the following examples assume that a working data file and all of the variables<br />

mentioned in the loop exist.

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

Saved successfully!

Ooh no, something went wrong!