BookmarkSubscribeRSS Feed
anilgvdbm
Quartz | Level 8

Hi All,

 

I have 7 datasets and I need to extract the common records from all 7 datasets and I wrote a Proc SQL query.

 

Please correct me where i did wrong in the below code.

 

 

proc sql;
create table match as
select *
from success as a full join ringtm as b
on a.mobile_num=b.mobile_num
full join Hung_Up as c
on b.mobile_num=c.mobile_num
full join ub1 as d
on c.mobile_num = d.mobile_num
full join ntwk as e
on d.mobile_num = e.mobile_num
full join ivd as f
on e.mobile_num =f.mobile_num
full join other_error as g
on f.mobile_num =g.mobile_num
where a.mobile_num and b.mobile_num
and c.mobile_num and d.mobile_num and e.mobile_num
and f.mobile_num and g.mobile_num ;
quit;

 

Regards,

Anil

 

2 REPLIES 2
HB
Barite | Level 11 HB
Barite | Level 11

If you have seven circles ad you only want to select those records where all seven circle overlap, you want an inner join.  

 

 

proc sql;
create table match as
   select * 
   from success a
   inner join ringtm b on a.mobile_num=b.mobile_num
   inner join Hung_Up c on a.mobile_num=c.mobile_num
   inner join ub1 d on on a.mobile_num = d.mobile_num
   inner join ntwk e on a.mobile_num = e.mobile_num
   inner join ivd f on a.mobile_num = f.mobile_num
   inner join other_error g on a.mobile_num = g.mobile_num;
quit;

 

 

novinosrin
Tourmaline | Level 20

@anilgvdbm  

 

You mentioned "I need to extract the common records from all 7 datasets"

 

Try using intersect aka set operators

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 661 views
  • 2 likes
  • 3 in conversation