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.

Example<br />

* Repeating groups in varying locations.<br />

REPEATING DATA 1395<br />

INPUT PROGRAM.<br />

DATA LIST FILE=VEHICLE / SEQNUM 2-4 NUMPERS 6-7 NUMVEH 9-10.<br />

+ DO IF (SEQNUM LE 100).<br />

+ COMPUTE FIRST=12.<br />

+ ELSE.<br />

+ COMPUTE FIRST=15.<br />

+ END IF.<br />

REPEATING DATA STARTS=FIRST /OCCURS=NUMVEH<br />

/DATA=MAKE 1-8 (A) MODEL 9 (A) NUMCYL 10.<br />

END INPUT PROGRAM.<br />

• This example assumes that each input case is recorded on a single record and that there<br />

are no continuation records. Repeating groups begin in column 12 for all records with<br />

sequence numbers 1 through 100 and in column 15 for all records with sequence numbers<br />

greater than 100.<br />

• The sequence number for each record is defined as variable SEQNUM on the DATA LIST<br />

command. The DO IF—END IF structure creates the variable FIRST with value 12 for<br />

records with sequence numbers through 100 and value 15 for records with sequence<br />

numbers greater than 100.<br />

• Variable FIRST is specified on the STARTS subcommand.<br />

OCCURS Subcommand<br />

OCCURS specifies the number of repeating groups for each input case. OCCURS is required<br />

and specifies a number if the number of groups is the same for all input cases or a variable if<br />

the number of groups varies across input cases. The variable must be defined on a DATA LIST<br />

command or created with transformation commands.<br />

Example<br />

INPUT PROGRAM.<br />

DATA LIST / SEQNUM 2-4 NUMPERS 6-7 NUMVEH 9-10.<br />

REPEATING DATA STARTS=12 /OCCURS=NUMVEH<br />

/DATA=MAKE 1-8 (A) MODEL 9 (A) NUMCYL 10.<br />

END INPUT PROGRAM.<br />

BEGIN DATA<br />

1001 02 02 FORD T8PONTIAC C6<br />

1002 04 01 CHEVY C4<br />

1003 02 03 CADILAC C8FORD<br />

END DATA.<br />

LIST.<br />

T6VW C4<br />

• Data for each input case are recorded on a single record; there are no continuation records.<br />

• The value for variable NUMVEH in columns 9 and 10 indicates the number of repeating<br />

groups on each record. One output case is built in the working data file for each occurrence<br />

of a repeating group.

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

Saved successfully!

Ooh no, something went wrong!