Help using Base SAS procedures

Compress special characters

Accepted Solution Solved
Reply
Super Contributor
Posts: 268
Accepted Solution

Compress special characters

I'm trying to compress all special characters out of street addresses.  It won't allow me to compress #.  When  I take it out of the statement, it does allow me to compress the periods.  I have other characters such as commas and apostrophes I want to get rid of also.

street=upcase(compress(street,'.','#');


Accepted Solutions
Solution
‎10-27-2011 12:44 PM
Trusted Advisor
Posts: 2,113

Compress special characters

RTFM.  You have the syntax wrong.

street=upcase(compress(street,'.#');

View solution in original post


All Replies
Solution
‎10-27-2011 12:44 PM
Trusted Advisor
Posts: 2,113

Compress special characters

RTFM.  You have the syntax wrong.

street=upcase(compress(street,'.#');

Super User
Posts: 10,483

Compress special characters

Put all of the characters to compress within one set of quotes. The comma between them as you have is trying to interpret the # as a modifier.

street=upcase(compress(street,'.#');

Super Contributor
Posts: 268

Compress special characters

Excellent.  Thank you.

PROC Star
Posts: 7,360

Compress special characters

You might find it even easier if you just KEEP the characters you want.  e.g.,

n or N

adds digits, the underscore character, and English letters to the list of characters.

thus street=compress(street,,'kn) might accomplish everything you want

Super Contributor
Posts: 268

Compress special characters

Cool.  That's good to know.

☑ This topic is SOLVED.

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

Discussion stats
  • 5 replies
  • 593 views
  • 6 likes
  • 4 in conversation