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

POINT 1221<br />

an infinite loop in which the same record is read again and again, either the value of the<br />

variable specified on KEY must change from case to case or the POINT command must be<br />

set up to execute only once.<br />

• If the file contains a record whose key exactly matches the value of the KEY variable, the<br />

next execution of DATA LIST will read that record, the second execution of DATA LIST will<br />

read the next record, and so on.<br />

• If an exact match is not found, the results depend on the operating system. On IBM implementations,<br />

reading will begin or resume at the record that has the next higher key. If the<br />

value of the key is shorter than the file key, the value of the key variable is logically<br />

extended with the lowest character in the collating sequence. For example, if the value of<br />

the key variable is the single letter M, retrieval would begin or resume at the first record<br />

that had a key (regardless of length) beginning with the letter M or a character higher in<br />

the collating sequence.<br />

• POINT does not report on whether the file contains a record that exactly matches the specified<br />

key. The only way to check for missing records is to display the data read by the subsequent<br />

DATA LIST command using LIST.<br />

* Select a subset of records from a keyed file.<br />

FILE HANDLE<br />

INPUT PROGRAM.<br />

DRIVERS/ file specifications.<br />

STRING #FRSTAGE(A2).<br />

DO IF #FRSTAGE = ’ ’. /* First case check<br />

+ COMPUTE #FRSTAGE = ’26’. /* Initial key<br />

+ POINT FILE=DRIVERS /KEY=#FRSTAGE.<br />

END IF.<br />

DATA LIST FILE=DRIVERS NOTABLE/<br />

AGE 19-20(A) SEX 21(A) TICKETS 12-13.<br />

DO IF<br />

+ END FILE.<br />

END IF.<br />

AGE > ’30’.<br />

END INPUT PROGRAM.<br />

LIST.<br />

• This example illustrates how to execute POINT for only the first case. The file contains<br />

information about traffic violations, and it uses the individual’s age as the key. Ages<br />

between 26 and 30 are selected.<br />

• FILE HANDLE specifies the file handle DRIVERS.<br />

• The INPUT PROGRAM and END INPUT PROGRAM commands begin and end the block of<br />

commands that build cases. POINT must appear in an input program.<br />

• STRING declares the string variable #FRSTAGE, whose value will be used as the key on<br />

the POINT command. Since #FRSTAGE is a string variable, it is initialized as blanks.<br />

• The first DO IF—END IF structure is executed only if no records have been read; that is,<br />

when #FRSTAGE is blank. When #FRSTAGE is blank, COMPUTE resets #FRSTAGE to 26,<br />

which is the initial value. POINT is executed, and it causes the first execution of DATA LIST<br />

to read a record whose key is at least 26. Since the value of #FRSTAGE is now 26, the DO<br />

IF—END IF structure is not executed again.

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

Saved successfully!

Ooh no, something went wrong!