DATA Step, Macro, Functions and more

Removing Special Characters

Reply
Frequent Contributor
Posts: 95

Removing Special Characters

I'm using SAS to extract data from a database. Some of the fields I'm grabbing are text fields that have newline and carriage return characters embedded. I tried to use TRANWRD to remove these characters, but I may not be doing it correctly.

When I import this data into MS Excel, I see that the special characters appear as '\x0a\x0d'. SAS displays this as a pair of boxes.

What is the proper way to remove these newline and carriage return characters from a text field?
Frequent Contributor
Posts: 95

Re: Removing Special Characters

Looks like I answered my own question . . .

I can refer to them as '0D'x and '0A'x in the TRANSLATE function.
Respected Advisor
Posts: 4,173

Re: Removing Special Characters

TRANSLATE will work, COMPRESS would do the job as well.
If you're ever looking for more difficult replacements then get familiar with regular expressions (PRXCHANGE and the like).
Cheers
Patrick
Valued Guide
Posts: 2,177

Re: Removing Special Characters

should be careful with this kind of data.

why do these special values occur?

Possibly they mean something.

Check with someone who knows that data source, or the service provider

good luck

PeterC
Ask a Question
Discussion stats
  • 3 replies
  • 1319 views
  • 0 likes
  • 3 in conversation