BookmarkSubscribeRSS Feed
buddha_d
Pyrite | Level 9

Dear SAS community,

         I am trying to compare two columns which are almost same as shown below. If you look at the data carefully the sender is same as receiver (except that some of the rows have middle name etc). I have to code in a way where I can get the last record where the sender and receiver names don't match at all. This is the sample data of real time data. Please help me to find a solution. I tried using like operator and contains operator but of no use. 

Thanks in advance 

DATA have ;
INPUT sender $13. receiver$33.;
CARDS;
DON A ABROGS FOR FURTHER CREDIT: DON A ABROGS
ANTHONY BOGGS INFAVOR OF ANTHONY L BOGGS
TIM D BRUNS TIMOTHY BRUNS
KEN V PAYE KENNETH V PAYE
ERICA PARIS ERICA N PARIS
JEFF WOOD JEFFORY WOOD
NICK PATEL CREDIT TO: 345678 (NICK PATEL)
JOEL NELSON TAMMY WOODWARDS
;
RUN;

 I tried the following code and didn't get what I wanted. I need to see the last record (joel nelson and tammy woodwards) record as a result

proc sql;
	create table want as 
	select *
	from have 
	where compress(receiver) like '%'||compress(sender)||'%' 
		 
	; quit; 

3 REPLIES 3
buddha_d
Pyrite | Level 9
DATA have ;
INPUT sender $13. receiver$33.;
CARDS;
DON A ABROGS  FOR FURTHER CREDIT: DON A ABROGS
ANTHONY BOGGS INFAVOR OF ANTHONY L BOGGS
TIM D BRUNS   TIMOTHY BRUNS 
KEN V PAYE    KENNETH V PAYE
ERICA PARIS   ERICA N PARIS
JEFF WOOD     JEFFORY WOOD
NICK PATEL    CREDIT TO: 345678 (NICK PATEL)
JOEL NELSON   TAMMY WOODWARDS
;
RUN;

sorry for unformatted data posting previously

Ksharp
Super User
Check fuzz match functions like :
SPEDIS()
COMPLEV()
COMPGEN()
buddha_d
Pyrite | Level 9

Thanks Ksharp !! I will give it a try.

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

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