How to: |
Given a source character string, or an expression that can be converted to varchar (variable-length alphanumeric), and an integer number, LEFT returns that number of characters from the left end of the string.
LEFT(chr_exp, int_exp)
where:
Alphanumeric or an expression that can be converted to variable-length alphanumeric.
Is the source character string.
Integer
Is the number of characters to be returned.
The following request computes the length of the first name in the FULLNAME field and returns that number of characters to FIRST.
TABLE FILE WF_RETAIL_EMPLOYEE PRINT FULLNAME AND COMPUTE LEN/I5 = ARGLEN(54, GET_TOKEN(FULLNAME, ' ', 1), LEN); NOPRINT COMPUTE FIRST/A20 = LEFT(FULLNAME, LEN); WHERE RECORDLIMIT EQ 20 ON TABLE SET PAGE NOLEAD ON TABLE SET STYLE * GRID=OFF,$ ENDSTYLE END
The output is shown in the following image.