TRANSLATE text {TO {UPPER|LOWER} CASE}
| {USING pattern}.
1. ... TO {UPPER|LOWER} CASE
2. ... USING pattern
This statement converts the case or single characters of the character-type data object
text. The statement CASE can be used for the
conversion to upper/lower case; USING can be used for
the conversion according to a pattern. The variable text must be character-type.
There are two obsolete variants of this statement:
... TO {UPPER|LOWER} CASE
If you specify UPPER, all lower-case letters of the data object text are converted to upper case. If you specify LOWER, all upper-case letters are converted to lower case.
The conversion of the upper/lower case depends on the text environment. Problems may occur if the language of the text environment differs from the language in which the data to be processed is entered. Data loss will occur if a conversion between the source and target language has not been defined. To avoid this type of inconsistency, you must appropriately set the text environment using the SET LOCALE statement prior to the conversion.
After the conversion, the variable text contains "CAREFUL WITH THAT AXE, EUGENE".
DATA text TYPE string.
text = `Careful with that Axe, Eugene`.
TRANSLATE text TO UPPER CASE.
... USING pattern
If you specify USING, the characters in text are converted according to the rule specified in pattern. pattern must be a character-type data object whose contents are interpreted as a sequence of character pairs. text is searched for the first character of each pair, starting with the first pair, and each location found is replaced with the second character of the pair. The search is case-sensitive. If pattern contains a character multiple times as the first character of a pair, only the first pair is taken into account. A character in text that has already been replaced cannot be replaced again in the same TRANSLATE statement. Therefore, if the second character of a pair in pattern appears as the first character of a subsequent pair, the second pair affects only the original characters in text.
Trailing blanks in data objects text and pattern are taken into account for data objects. If pattern contains an uneven number of characters, the last character is ignored. If pattern is a blank string, no replacements take place.
Converts the characters "A" to "B", "a" to "b", and vice versa. text contains "Abracadabra" after the conversion.
DATA text TYPE string.
text = `Barbcbdbarb`.
TRANSLATE text USING 'ABBAabba'.