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.

Defining Complex Files 1715<br />

• DATA defines variables that are repeated. Since #NUM is 3 in the first and third<br />

records, the program reads three sets of STUDENT and SCORE variables in these<br />

records. STUDENT and SCORE are read twice in record 2.<br />

• END INPUT PROGRAM signals the end of data definition.<br />

• Data appear between BEGIN DATA and END DATA.<br />

• Figure C.11 shows the output from LIST.<br />

Figure C.11 LIST output<br />

CLASS STUDENT SCORE<br />

101 182 12<br />

101 134 53<br />

101 199 30<br />

102 99 112<br />

103 15 87<br />

If your data file does not have a variable indicating the number of repeating data groups<br />

per record, you can use the LOOP and REREAD commands to read the data, as in:<br />

INPUT PROGRAM.<br />

DATA LIST / CLASS 3-5 #ALL 6-29 (A).<br />

LEAVE CLASS.<br />

LOOP #I = 1 TO 17 BY 8 IF SUBSTR(#ALL, #I, 8) NE ’’.<br />

- REREAD COLUMN = #I + 5.<br />

- DATA LIST / STUDENT 1-4 SCORE 5-8.<br />

- END CASE.<br />

END LOOP.<br />

END INPUT PROGRAM.<br />

BEGIN DATA<br />

101 182 12 134 53 199 30<br />

102 99 112 200 150<br />

103 15 87<br />

END DATA.<br />

LIST.<br />

• INPUT PROGRAM signals the beginning of data definition.<br />

• DATA LIST reads CLASS and #ALL, a temporary string variable that contains all of<br />

the repeating data groups for a classroom record. The column specifications for #ALL<br />

(6 through 29) are wide enough to accommodate the classroom record with the most<br />

repeating data groups (record 1).<br />

• LOOP and END LOOP define an index loop. As the loop iterates, the program successively<br />

reads eight-character segments of #ALL, each of which contains a repeating<br />

data group or an empty field. The program reads the first eight characters of #ALL in<br />

the first iteration, the second eight characters in the second iteration, and so forth.

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

Saved successfully!

Ooh no, something went wrong!