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.

REREAD 1435<br />

• When the updated base is built, the program returns to the first DATA LIST command in<br />

the input program and reads the next ID from the UPDATE file. If the UPDATE file is<br />

exhausted (#EOF=1), the loop keeps reading records from the master file until it reaches<br />

the end of the file.<br />

• The same task can be accomplished using MATCH FILES. With MATCH FILES, the raw data<br />

must be read and saved as SPSS-format data files first.<br />

COLUMN Subcommand<br />

COLUMN specifies a beginning column for the REREAD command to read data. The default<br />

is column 1. You can specify a numeric expression for the column.<br />

Example<br />

INPUT PROGRAM.<br />

DATA LIST /KIND 10-14 (A).<br />

COMPUTE #COL=1.<br />

IF (KIND EQ ’CHEVY’) #COL=13.<br />

DO IF (KIND EQ ’CHEVY’ OR KIND EQ ’FORD’).<br />

REREAD COLUMN #COL.<br />

DATA LIST /PRICE 3-6 (DOLLAR,2) QUANTITY 7-9.<br />

END CASE.<br />

END IF.<br />

END INPUT PROGRAM.<br />

BEGIN DATA<br />

111295100FORD CHAPMAN AUTO SALES<br />

121199005VW MIDWEST VOLKSWAGEN SALES<br />

11 395025FORD BETTER USED CARS<br />

11 CHEVY 195005 HUFFMAN SALES & SERVICE<br />

11 VW 595020 MIDWEST VOLKSWAGEN SALES<br />

11 CHEVY 295015 SAM’S AUTO REPAIR<br />

12 CHEVY 210 20 LONGFELLOW CHEVROLET<br />

9555032 VW HYDE PARK IMPORTS<br />

END DATA.<br />

LIST.<br />

• The task in this example is to read PRICE and QUANTITY for Chevrolets and Fords only.<br />

A scratch variable is created to indicate the starting column positions for PRICE and<br />

QUANTITY, and a single DATA LIST command is used to read data for both types of<br />

automobiles.<br />

• Scratch variable #COL is set to 13 for Chevrolets and 1 for all other automobiles. For<br />

Fords, the data begin in column 1. Variable PRICE is read from columns 3–6 and<br />

QUANTITY is read from columns 7–9. When the record is a Chevrolet, the data begins<br />

in column 13. Variable PRICE is read from columns 15–18 (15 is 3, 16 is 4, and so<br />

forth), and QUANTITY is read from columns 19–21.

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

Saved successfully!

Ooh no, something went wrong!