data _null_;
string1='*' || tranwrd('abcxabc', 'abc', trimn('')) || '*';
put string1=;
string2='*' || tranwrd('abcxabc', 'abc', '') || '*';
put string2=;
run;
string1=* x *
string2=* x *
Hi,
From SAS documentation,
The TRANWRD function replaces all occurrences of a given substring within a character string. The TRANWRD function does not remove trailing blanks in the target string and the replacement string.
TRANWRD uses a single blank instead when the replacement string has a length of zero.
Try using compress to remove all the blank spaces,if you want.
data _null_;
string1='*' || compress(tranwrd('abcxabc', 'abc', trimn(''))) || '*';
put string1=;
string2='*' || compress('abcxabc', 'abc', '') || '*';
put string2=;
run;
Thanks,
Shiva
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.