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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

Register now

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
  • 1001 views
  • 1 like
  • 3 in conversation