remove special character from a specific variable

Accepted Solution Solved
Reply
Contributor
Posts: 65
Accepted Solution

remove special character from a specific variable

Hi everyone,
Is anyone can help me  to remove a special character from a variable regardless of its order in the variable.
here is the example:
what I have:
id                      Mesure
10/5201            0.012
10/6522            0.452
306/312            1.003
AC115/9            0.855

what I want (just delete the slash)
id                      Mesure
105201            0.012
106522            0.452
306312            1.003
AC1159            0.855

My database contains more than a million ids that contain special characters (/, -,*,.) that I just want to search for and remove them by keeping the other characters.
Thank you for your help.


Accepted Solutions
Solution
‎10-02-2017 10:12 AM
Super User
Super User
Posts: 8,177

Re: remove special character from a specific variable

No.  Read the documentation, all you need is:

id=compress(id, '/');

View solution in original post


All Replies
Trusted Advisor
Posts: 1,977

Re: remove special character from a specific variable

Contributor
Posts: 65

Re: remove special character from a specific variable

Posted in reply to PaigeMiller

As I understand I have to put this code:

 

data want;set have;

id=compress(id, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 'k');

run;

 

is this true?

Solution
‎10-02-2017 10:12 AM
Super User
Super User
Posts: 8,177

Re: remove special character from a specific variable

No.  Read the documentation, all you need is:

id=compress(id, '/');

Contributor
Posts: 65

Re: remove special character from a specific variable

Yes, it works well. tank you.

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 100 views
  • 2 likes
  • 3 in conversation