DATA Step, Macro, Functions and more

Removing Special Characters

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,736

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).
Valued Guide
Posts: 2,191

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

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation