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

Hello helpers:)

 

I am trying to concatenate client's contact into one column and do not want it appears multiple times if the same number registered under home/work/mobile.

Client_Contact=catx(',',Home_Phone,Work_Phone,Mobile_Phone);

 

I googled and only found below solution. Just wondered if there is any other better way to achieve it?

 

Thanks in advance 🙂

 

https://stackoverflow.com/questions/42616892/sas-remove-duplicated-words-in-a-string

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

You could reset the values before concatenating?

H=ifc( Home_Phone   = Work_Phone   , ' ', Home_Phone  );

M=ifc( Home_Phone   = Mobile_Phone , ' ', Mobile_Phone);

W=ifc( Work_Phone   = Mobile_Phone , ' ', Work_Phone  );

Client_Contact=catx(',', H, M, W);

 

Otherwise, if you had many values in the list, using call sortx allows you to only compare to the next value in the list rather than compare to the rest of the whole list.

 

View solution in original post

3 REPLIES 3
Reeza
Super User
Those are the recommended ways and most of the answers from there are users who are on here and would provide very similar answers again anyway.
ChrisNZ
Tourmaline | Level 20

You could reset the values before concatenating?

H=ifc( Home_Phone   = Work_Phone   , ' ', Home_Phone  );

M=ifc( Home_Phone   = Mobile_Phone , ' ', Mobile_Phone);

W=ifc( Work_Phone   = Mobile_Phone , ' ', Work_Phone  );

Client_Contact=catx(',', H, M, W);

 

Otherwise, if you had many values in the list, using call sortx allows you to only compare to the next value in the list rather than compare to the rest of the whole list.

 

Suzy_Cat
Pyrite | Level 9

Perfect! This is what I want. 

 

Thanks a lot 🙂   @ChrisNZ 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1697 views
  • 4 likes
  • 3 in conversation