BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AMIN_DA
Fluorite | Level 6

Hi All,

I would like to check if 2 addresses are equal. I am using Compare function but for the ones I assume they are equal instead of 0 I get a number.

here is my example:

Add1Add2
11 JANE ST11 JANE ST

 

compare(Add1,Add2) but instread of 0 it SAS EG gives me 5. I checked in Excel and Excel resut is these 2 are equal.

 

Would you please help out with this issu?

1 ACCEPTED SOLUTION

Accepted Solutions
AMIN_DA
Fluorite | Level 6

Thank you Reeza for replying quickly.

I changed the format to $hex32. and I see they are different as below in the 9th postion from left and some other letters as well inside the string.

Add1Add2
11 JANE ST11 JANE ST
3131204A616E652053742020202020203131204A414E45205354202020202020

 

I have not with HEX format before and not sure if I've got your advice right and also I dont know how to recognise if it is because of space or not. So could you please let me know how I can remove potential space inside the text if there is any solution?

Regards,

View solution in original post

3 REPLIES 3
Reeza
Super User

Please provide a reproducible sample so that we replicate your issue. 

 

If you can't replicate it, it's an issue with your data. Try looking at the data with a HEX format to see if its different. 

You may have spaces in one and a different invisible character in others. 

 

Here's an example of how to use the HEX format to see the difference

 

data class;
set sashelp.class;

put name $hex32.;
run;

 

 

AMIN_DA
Fluorite | Level 6

Thank you Reeza for replying quickly.

I changed the format to $hex32. and I see they are different as below in the 9th postion from left and some other letters as well inside the string.

Add1Add2
11 JANE ST11 JANE ST
3131204A616E652053742020202020203131204A414E45205354202020202020

 

I have not with HEX format before and not sure if I've got your advice right and also I dont know how to recognise if it is because of space or not. So could you please let me know how I can remove potential space inside the text if there is any solution?

Regards,

AMIN_DA
Fluorite | Level 6

it was fixed by COMPARE(TRIM(UPCASE(Add1 )), TRIM(UPCASE( Add2)))

thanks again Reeza

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3552 views
  • 0 likes
  • 2 in conversation