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 />

Example<br />

*Select cases.<br />

INPUT PROGRAM.<br />

DATA LIST FILE=PRICES /YEAR 1-4 QUARTER 6 PRICE 8-12(2).<br />

DO IF (YEAR GE 1881). /*Stop reading before 1881<br />

END FILE.<br />

END IF.<br />

END INPUT PROGRAM.<br />

END FILE 517<br />

LIST.<br />

• This example assumes that data records are entered chronologically by year. The DO IF—<br />

END IF structure specifies an end of file when the first case with a value of 1881 or later<br />

for YEAR is reached.<br />

• LIST executes the input program and lists cases in the working data file. The case that<br />

causes the end of the file is not included in the working data file.<br />

• As an alternative to an input program with END FILE, you can use N OF CASES to select<br />

cases if you know the exact number of cases. Another alternative is to use SELECT IF to<br />

select cases before 1881, but then the program would unnecessarily read the entire input<br />

file.<br />

Select cases but retain the case that causes end-of-file processing.<br />

INPUT PROGRAM.<br />

DATA LIST FILE=PRICES /YEAR 1-4 QUARTER 6 PRICE 8-12(2).<br />

DO IF (YEAR GE 1881). /*Stop reading before 1881 (or at end of file)<br />

END CASE. /*Create case 1881<br />

END FILE.<br />

ELSE.<br />

END CASE. /*Create all other cases<br />

END IF.<br />

END INPUT PROGRAM.<br />

LIST.<br />

• The first END CASE command forces the program to retain the case that causes end-offile<br />

processing.<br />

• The second END CASE indicates the end of case for all other cases and passes them out of<br />

the input program one at a time. It is required because the first END CASE command<br />

causes the program to abandon default end-of-case processing (see END CASE).

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

Saved successfully!

Ooh no, something went wrong!