Examples (POINT command)
Basic Example
FILE HANDLE DRIVERS/ file specifications.
POINT FILE=DRIVERS /KEY=#FRSTAGE.
-
FILE HANDLEdefines the handle for the data file to be read byPOINT. The handle is specified on theFILEsubcommand onPOINT. -
KEYonPOINTspecifies 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
POINTfor 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 HANDLEspecifies the file handleDRIVERS. - The
INPUT PROGRAMandEND INPUT PROGRAMcommands begin and end the block of commands that build cases.POINTmust appear in an input program. -
STRINGdeclares the string variable #FRSTAGE, whose value will be used as the key on thePOINTcommand. Because #FRSTAGE is a string variable, it is initialized as blanks. - The first
DO IF-END IFstructure is executed only if no records have been read (that is, when #FRSTAGE is blank). When #FRSTAGE is blank,COMPUTEresets #FRSTAGE to 26, which is the initial value.POINTis executed, and it causes the first execution ofDATA LISTto read a record whose key is at least 26. Because the value of #FRSTAGE is now 26, theDO IF-END IFstructure is not executed again. -
DATA LISTreads the variables AGE, SEX, and TICKETS from the file DRIVERS. - The second
DO IF—END IFstructure executes anEND FILEcommand 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).