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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

Example<br />

* Select cases with an input program.<br />

INPUT PROGRAM—END INPUT PROGRAM 779<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 when reaching 1881<br />

END FILE.<br />

END IF.<br />

END INPUT PROGRAM.<br />

LIST.<br />

• The input program is defined between the INPUT PROGRAM and END INPUT PROGRAM<br />

commands.<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 causes<br />

the end of the file is not included in the working file generated by the input program.<br />

• As an alternative to this input program, you can use N OF CASES to select cases if you<br />

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

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

* Skip the first n records in a file.<br />

INPUT PROGRAM.<br />

NUMERIC #INIT.<br />

DO IF NOT (#INIT).<br />

+ LOOP #I = 1 TO 5.<br />

+ DATA LIST NOTABLE/. /* No data - just skip record<br />

+ END LOOP.<br />

+ COMPUTE #INIT = 1.<br />

END IF.<br />

DATA LIST NOTABLE/ X 1.<br />

END INPUT PROGRAM.<br />

BEGIN DATA<br />

A /* The first 5 records are skipped<br />

B<br />

C<br />

D<br />

E<br />

1<br />

2<br />

3<br />

4<br />

5<br />

END DATA.<br />

LIST.

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

Saved successfully!

Ooh no, something went wrong!