DATA Step, Macro, Functions and more

replace a string exactly

Accepted Solution Solved
Reply
Regular Contributor
Posts: 241
Accepted Solution

replace a string exactly

data  have;
x="aaabbbbccccdddd--abc--def";
run;

data need;
set have;
x2=compress(x,"abc");
*I want x should be "aaabbbbccccdddd----def";
run;

How to remove string  "abc" exactly from the old string?

 

Thanks!


Accepted Solutions
Solution
‎06-20-2017 02:46 PM
Regular Contributor
Posts: 241

Re: replace a string exactly

Posted in reply to GeorgeSAS

data need;

set have;

x2=TRANWRD(x,"abc",'');

*I want x should be "aaabbbbccccdddd----def";

run;

View solution in original post


All Replies
Solution
‎06-20-2017 02:46 PM
Regular Contributor
Posts: 241

Re: replace a string exactly

Posted in reply to GeorgeSAS

data need;

set have;

x2=TRANWRD(x,"abc",'');

*I want x should be "aaabbbbccccdddd----def";

run;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 103 views
  • 0 likes
  • 1 in conversation