BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10
data have1;
 length loan_num $10
 	curr_phone $10
	;
	input loan_num curr_phone;
datalines;
2234110000 1111111111 
3400238190 9981111111 
2098766890 0 

;
run;

data have2;
 length loan_num $10
	phone1 $10 
	alt_phone $10
	bus_phone $10;
	input loan_num -- bus_phone;
datalines;
2234110000 1111111111 0 3333333333 
3400238190 3323333333 1098899999 0 
2098766890 0 2234444444 0  

;
run;

proc sql;
create table have3 as
select *,case when curr_phone in coalesce(phone1,alt_phone,bus_phone)
then 'Y' end as Phone_Match
from have1		a
left join have2	b
on a.loan_num=b.loan_num
;quit;

I am comparing two sets of data (have1 and have2)  When I combine the two in have3 I tried to use a coalesce to look for a match between curr_phone(have1) and   phone1,alt_phone or bus_phone.(have2)  If there is a match with any of the three I want to designate with a 'Y'.  When I try and use coalesce I get an error.  Would I need to use some type of scan of all three phone numbers or am I just using coalesce incorrectly?

1 REPLY 1
Reeza
Super User
WHICHC() function.

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore 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
  • 1 reply
  • 995 views
  • 0 likes
  • 2 in conversation