BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Shmuel
Garnet | Level 18
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 ?

1 ACCEPTED SOLUTION
3 REPLIES 3
ed_sas_member
Meteorite | Level 14

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

 

Shmuel
Garnet | Level 18

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 913 views
  • 1 like
  • 3 in conversation