SCAN: PROC(IN_STRING,N,DELIMITERS) RETURNS(CHAR(*) VARYING); /* PROCEDURE SCANS IN_STRING FOR N-TH WORD USING DELIMITER SET. UNLIKE THE SAS SCAN FUNCTION DELIMITERS APPEARING TOGETHER ARE TREATED AS SEPARATE DELIMITERS. AUTHOR: AL JAWORSKI DATE: MARCH 2, 1981 */ %INCLUDE LOP; DCL (IN_STRING,DELIMITERS) CHAR(*) VARYING; DCL TMP_STRING CHAR(LENGTH(IN_STRING)) VARYING BASED(P); DCL TOKEN CHAR(LENGTH(IN_STRING)) VARYING BASED(Q); DCL (P,Q) POINTER; DCL (I,N) FIXED BINARY(31); DCL BREAK CHAR(1) VARYING; IF N<=0|IN_STRING='' THEN RETURN(''); ALLOC TMP_STRING SET(P); TMP_STRING=IN_STRING; ALLOC TOKEN SET(Q); DO I=1 TO N; TOKEN=LOP(TMP_STRING,DELIMITERS,BREAK); END; RETURN(TOKEN); END SCAN;