Examples (POINT command)
Basic Example
FILE HANDLE DRIVERS/ file specifications.
POINT FILE=DRIVERS /KEY=#FRSTAGE.
-
FILE HANDLE
defines the handle for the data file to be read byPOINT
. The handle is specified on theFILE
subcommand onPOINT
. -
KEY
onPOINT
specifies the key variable. The key variable must be a string, and it must already exist as the result of a priorDATA LIST
,KEYED DATA LIST
, or transformation command.
Selecting a Subset of Records from a Keyed File
FILE HANDLE DRIVERS/ file specifications.
INPUT PROGRAM.
STRING #FRSTAGE(A2).
DO IF #FRSTAGE = ' '. /* First case check
+ COMPUTE #FRSTAGE = '26'. /* Initial key
+ POINT FILE=DRIVERS /KEY=#FRSTAGE.
END IF.
DATA LIST FILE=DRIVERS NOTABLE/
AGE 19-20(A) SEX 21(A) TICKETS 12-13.
DO IF AGE > '30'.
+ END FILE.
END IF.
END INPUT PROGRAM.
LIST.
- This example illustrates how to execute
POINT
for only the first case. The file contains information about traffic violations, and it uses the individual's age as the key. Ages between 26 and 30 are selected. -
FILE HANDLE
specifies the file handleDRIVERS
. - The
INPUT PROGRAM
andEND INPUT PROGRAM
commands begin and end the block of commands that build cases.POINT
must appear in an input program. -
STRING
declares the string variable #FRSTAGE, whose value will be used as the key on thePOINT
command. Because #FRSTAGE is a string variable, it is initialized as blanks. - The first
DO IF-END IF
structure is executed only if no records have been read (that is, when #FRSTAGE is blank). When #FRSTAGE is blank,COMPUTE
resets #FRSTAGE to 26, which is the initial value.POINT
is executed, and it causes the first execution ofDATA LIST
to read a record whose key is at least 26. Because the value of #FRSTAGE is now 26, theDO IF-END IF
structure is not executed again. -
DATA LIST
reads the variables AGE, SEX, and TICKETS from the file DRIVERS. - The second
DO IF—END IF
structure executes anEND FILE
command as soon as a record is read that contains a driver's age that is greater than 30. The program does not add this last case to the working file when it ends the file (seeEND FILE
).