Replaces all occurrences of a substring in a character string.
Category: | Character |
Restriction: | I18N Level 2 functions are designed for use with SBCS, DBCS, and MBCS (UTF8). |
specifies a character constant, variable, or expression that you want to translate.
specifies a character constant, variable, or expression that is searched for in source.
Requirement | The length for target must be greater than zero. |
specifies a character constant, variable, or expression that replaces target. When the replacement string has a length of zero, TRANWRD uses a single blank instead.
data list; input salelist $; length target $10 replacement $3; target='FISH'; replacement='NIP'; salelist=tranwrd(salelist,target,replacement); put salelist; datalines; CATFISH ;
'FISH '
in SALELIST.
Because the search fails, this line is written to the SAS log:CATFISH
data _null_; string1='*' || tranwrd('abcxabc', 'abc', trimn('')) || '*'; put string1=; string2='*' || tranwrd('abcxabc', 'abc', '') || '*'; put string2=; run;