DATA Step, Macro, Functions and more

i tryed to remove two spl character at a time using tranwrd

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

i tryed to remove two spl character at a time using tranwrd

Hi i am trying remove spl char at a time . but it's not work proparly .

 

exp;

 


data exp;
a='i will try to removie spl char @ and another spl $';
a1=tranwrd(a,'@$' , '' );
run;

i want a1 varibel with out spl char;


Accepted Solutions
Solution
‎03-20-2017 09:04 AM
Respected Advisor
Posts: 3,799

Re: i tryed to remove two spl character at a time using tranwrd

To REMOVE characters use COMPRESS funtion.   TRANWRD is the wrong funtion for your problem.

View solution in original post


All Replies
Solution
‎03-20-2017 09:04 AM
Respected Advisor
Posts: 3,799

Re: i tryed to remove two spl character at a time using tranwrd

To REMOVE characters use COMPRESS funtion.   TRANWRD is the wrong funtion for your problem.

Super User
Posts: 11,343

Re: i tryed to remove two spl character at a time using tranwrd

Or translate may be what you were thinking of.

data exp;
   a='i will try to removie spl char @ and another spl $';
   a1=translate (a,'','@$' );
run;
Respected Advisor
Posts: 3,799

Re: i tryed to remove two spl character at a time using tranwrd

[ Edited ]

ballardw wrote:

Or translate may be what you were thinking of.

data exp;
   a='i will try to removie spl char @ and another spl $';
   a1=translate (a,'','@$' );
run;

 

Translate doesn't remove the characters you are replacing with blanks.

Super User
Posts: 11,343

Re: i tryed to remove two spl character at a time using tranwrd

Posted in reply to data_null__

Understood @data_null__ but since the OP started with one of the translate functions I was hoping to point him to the slightly more correct option.

 

And since there was not actual desired output posted ...

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 140 views
  • 0 likes
  • 3 in conversation