73 data _null_;
74 x = '111 abc 222';
75 t = tranwrd(x,"efg","abc");
76 put x= t=;
77 run;
x=111 abc 222 t=111 abc 222
Why tranwrd() did not replace the substring as coded ?
It is an inconsistency between TRANSLATE() and TRANWRD(). The order of "from" and "to" is reversed between the two.
Hi @Shmuel
Didn't you mean the following instead of tranwrd(x, "efg", "abc") ? -> tranwrd(x, "abc", "efg")
71 data _null_;
72 x='111 abc 222';
73 t=tranwrd(x, "abc", "efg");
74 put x=t=;
75 run;
x=111 abc 222 t=111 efg 222
It is an inconsistency between TRANSLATE() and TRANWRD(). The order of "from" and "to" is reversed between the two.
I misunderstood the word "target" in the next syntax found in sas9.2 doc.:
Syntax |
| TRANWRD(source,target,replacement) |
Thanks @Kurt_Bremser and @ed_sas_member for your quick answer.
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 save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.