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.

Figure 2 Output from the PRINT subcommand<br />

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

3 0 COMPUTE Q=N<br />

4 0 END REPEAT PRINT<br />

5 0 +COMPUTE Q1=0<br />

6 0 +COMPUTE Q2=0<br />

7 0 +COMPUTE Q3=0<br />

8 0 +COMPUTE Q4=0<br />

9 0 +COMPUTE Q5=0<br />

10 0 +COMPUTE R1=1<br />

11 0 +COMPUTE R2=1<br />

12 0 +COMPUTE R3=1<br />

13 0 +COMPUTE R4=1<br />

14 0 +COMPUTE R5=1<br />

Example<br />

DO REPEAT—END REPEAT 505<br />

DO REPEAT R=REGION1 TO REGION5/ X=1 TO 5.<br />

COMPUTE R=REGION EQ X.<br />

END REPEAT PRINT.<br />

• In this example, stand-in variable R represents the variable list REGION1 to REGION5.<br />

Stand-in variable X represents the value list 1 to 5.<br />

• The DO REPEAT—END REPEAT structure creates dummy variables REGION1 to REGION5<br />

that equal 0 or 1 for each of 5 regions, depending on whether variable REGION equals the<br />

current value of stand-in variable X.<br />

• PRINT on END REPEAT causes the program to display the commands generated by the<br />

structure, as shown in Figure 3.<br />

Figure 3 <strong>Command</strong>s generated by DO REPEAT<br />

2 0 DO REPEAT R=REGION1 TO REGION5/ X=1 TO 5<br />

3 0 COMPUTE R=REGION EQ X<br />

4 0 END REPEAT PRINT<br />

5 0 +COMPUTE REGION1=REGION EQ 1<br />

6 0 +COMPUTE REGION2=REGION EQ 2<br />

7 0 +COMPUTE REGION3=REGION EQ 3<br />

8 0 +COMPUTE REGION4=REGION EQ 4<br />

9 0 +COMPUTE REGION5=REGION EQ 5

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

Saved successfully!

Ooh no, something went wrong!