SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Batman
Quartz | Level 8

I have two values with same apparent text but different hex values

 

State=ALABAMA 414C4142414D4109
State=ALABAMA 414C4142414D4120

 

Is there a way to equalize the hex values so they can be merged?

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

If I recall, 09 is the hex code for a tab character.  There's a small possibility that I'm wrong about that, but the fix is the same no matter what the different characters contain:

state = compress(state, '0920'x);

Remove the offending characters, and let SAS pad the values with trailing blanks. 

 

I will investigate a little further, because you won't want to remove embedded blanks from NEW YORK, etc.

 

Confirmed that 09 is a tab, so begin there by removing just the tab characters:

 

state = compress(state, '09'x);

 

View solution in original post

3 REPLIES 3
Astounding
PROC Star

If I recall, 09 is the hex code for a tab character.  There's a small possibility that I'm wrong about that, but the fix is the same no matter what the different characters contain:

state = compress(state, '0920'x);

Remove the offending characters, and let SAS pad the values with trailing blanks. 

 

I will investigate a little further, because you won't want to remove embedded blanks from NEW YORK, etc.

 

Confirmed that 09 is a tab, so begin there by removing just the tab characters:

 

state = compress(state, '09'x);

 

Batman
Quartz | Level 8
Yes, thanks, I want to keep the space between states with two words.
ErikLund_Jensen
Rhodochrosite | Level 12

Hi @Batman 

x20 is the space character. A text variable has a fixed length in SAS and is padded with space characters, so the value will always end with x20x20x20... up to the variable length. So just compress the TAB character out as suggested by @Astounding, and everything will be fine.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 922 views
  • 0 likes
  • 3 in conversation