How to: |
Given a starting position, length, source string, and insertion string, OVERLAY replaces the number of characters defined by length in the source string with the insertion string, starting from the starting position.
OVERLAY(src, ins, start, len)
where:
Alphanumeric
Is the source string whose characters will be replaced.
Alphanumeric
Is the insertion string with the replacement characters.
Numeric
Is the starting position for the replacement in the source string.
Numeric
Is the number of characters to replace in the source string with the entire insertion string.
The following request replaces the first three characters in the last name with the first four characters of the first name.
TABLE FILE EMPLOYEE PRINT COMPUTE FIRST4/A4 = LEFT(FIRST_NAME,4); NEWNAME/A20 = OVERLAY(LAST_NAME, FIRST4, 1, 3); BY LAST_NAME BY FIRST_NAME ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * GRID=OFF,$ ENDSTYLE END
The output is shown in the following image.