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.

504 DO REPEAT—END REPEAT<br />

PRINT Subcommand<br />

The PRINT subcommand on END REPEAT displays the commands generated by the DO<br />

REPEAT—END REPEAT structure. PRINT can be used to verify the order in which<br />

commands are executed.<br />

Example<br />

DO REPEAT Q=Q1 TO Q5/ R=R1 TO R5.<br />

COMPUTE Q=0.<br />

COMPUTE R=1.<br />

END REPEAT PRINT.<br />

• The DO REPEAT—END REPEAT structure initializes one set of variables to 0 and another<br />

set to 1.<br />

• The output from the PRINT subcommand is shown in Figure 1. The generated commands<br />

are preceded by plus signs.<br />

• The COMPUTE commands are generated in such a way that variables are created in alternating<br />

order: Q1, R1, Q2, R2, and so forth. If you plan to use the TO keyword to refer to<br />

Q1 to Q5 later, you should use two separate DO REPEAT utilities; otherwise, Q1 to Q5 will<br />

include four of the five R variables. Alternatively, use the NUMERIC command to predetermine<br />

the order in which variables are added to the working file, or specify the replacement<br />

value lists as shown in the next example.<br />

Figure 1 Output from the PRINT subcommand<br />

2 0 DO REPEAT Q=Q1 TO Q5/ R=R1 TO R5<br />

3 0 COMPUTE Q=0<br />

4 0 COMPUTE R=1<br />

5 0 END REPEAT PRINT<br />

6 0 +COMPUTE Q1=0<br />

7 0 +COMPUTE R1=1<br />

8 0 +COMPUTE Q2=0<br />

9 0 +COMPUTE R2=1<br />

10 0 +COMPUTE Q3=0<br />

11 0 +COMPUTE R3=1<br />

12 0 +COMPUTE Q4=0<br />

13 0 +COMPUTE R4=1<br />

14 0 +COMPUTE Q5=0<br />

15 0 +COMPUTE R5=1<br />

Example<br />

DO REPEAT Q=Q1 TO Q5,R1 TO R5/ N=0,0,0,0,0,1,1,1,1,1.<br />

COMPUTE Q=N.<br />

END REPEAT PRINT.<br />

• In this example, a series of constants is specified as a stand-in value list for N. All the Q<br />

variables are initialized first, and then all the R variables, as shown in Figure 2.

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

Saved successfully!

Ooh no, something went wrong!