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.

940 MATRIX—END MATRIX<br />

• A logical expression on the IF clause of the END LOOP statement is evaluated as true.<br />

• A BREAK statement is executed within the loop structure (but outside of any nested loop<br />

structures).<br />

Index Clause on the LOOP Statement<br />

An index clause on a LOOP statement creates an index variable whose name is specified immediately<br />

after the keyword LOOP. The variable is assigned an initial value of n. Each time<br />

through the loop, the variable is tested against the terminal value m and incremented by the<br />

increment value k if k is specified, or by 1 if k is not specified. When the index variable is<br />

greater than m for positive increments or less than m for negative increments, control passes<br />

to the statement after the END LOOP statement.<br />

• Both the index clause and the IF clause are optional. If both are present, the index clause<br />

must appear first.<br />

• The index variable must be scalar with a valid matrix variable name.<br />

• The initial value, n, the terminal value, m, and the increment, k (if present), must be scalars<br />

or matrix expressions evaluating to scalars. Non-integer values are truncated to integers<br />

before use.<br />

• If the keyword BY and the increment k are absent, an increment of 1 is used.<br />

IF Clause on the LOOP Statement<br />

The logical expression is evaluated before each iteration of the loop structure. If it is false,<br />

the loop terminates and control passes to the statement after END LOOP.<br />

• The IF clause is optional. If both the index clause and the IF clause are present, the index<br />

clause must appear first.<br />

• As in the DO IF structure, the logical expression of the IF clause is evaluated as scalar, with<br />

positive values being treated as true and 0 or negative values, as false.<br />

IF Clause on the END LOOP Statement<br />

When an IF clause is present on an END LOOP statement, the logical expression is evaluated<br />

after each iteration of the loop structure. If it is true, the loop terminates and control passes<br />

to the statement following the END LOOP statement.<br />

• The IF clause is optional.<br />

• As in the LOOP statement, the logical expression of the IF clause is evaluated as scalar, with<br />

positive values being treated as true and 0 or negative values, as false.<br />

BREAK Statement<br />

The BREAK statement within a loop structure transfers control immediately to the statement<br />

following the (next) END LOOP statement. It is normally placed within a DO IF structure<br />

inside the LOOP structure to exit the loop when specified conditions are met.

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

Saved successfully!

Ooh no, something went wrong!