How to: |
Available Languages: reporting
The EDIT function extracts characters from or adds characters to an alphanumeric string. It can extract a substring from different parts of the parent string, and can also insert characters from a parent string into another substring. For example, it can extract the first two characters and the last two characters of a string to form a single substring.
EDIT works by comparing the characters in a mask to the characters in a source field. When it encounters a nine in the mask, EDIT copies the corresponding character from the source field to the new field. When it encounters a dollar sign in the mask, EDIT ignores the corresponding character in the source field. When it encounters any other character in the mask, EDIT copies that character to the corresponding position in the new field. EDIT does not require an outfield argument because the result is obviously alphanumeric and its size is determined from the mask value.
EDIT can also convert the format of a field. For information on converting a field with EDIT, see EDIT: Converting the Format of a Field.
EDIT(fieldname, 'mask');
where:
Alphanumeric
Is the source string from which characters will be extracted. It should be at least as long as the mask.
Alphanumeric
Is a character string enclosed in single quotation marks or a field containing the character string enclosed in single quotation marks. The length of the mask, excluding any characters other than nine and $, determines the length of the output field.
EDIT extracts the first initial from the FIRST_NAME field and stores the result in FIRST_INIT. EDIT also adds dashes to the EMP_ID field and stores the result in EMPIDEDIT. The mask used to extract the first initial is stored in the virtual field named MASK1:
DEFINE FILE EMPLOYEE MASK1/A10 = '9$$$$$$$$$' END TABLE FILE EMPLOYEE PRINT LAST_NAME AND COMPUTE FIRST_INIT/A1 = EDIT(FIRST_NAME, MASK1); EMPIDEDIT/A11 = EDIT(EMP_ID, '999-99-9999'); WHERE DEPARTMENT EQ 'MIS'; END
The output is:
LAST_NAME FIRST_INIT EMPIDEDIT --------- ---------- --------- SMITH M 112-84-7612 JONES D 117-59-3129 MCCOY J 219-98-4371 BLACKWOOD R 326-17-9357 GREENSPAN M 543-72-9165 CROSS B 818-69-2173
WebFOCUS |