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
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.
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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.