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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.