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

I have the following two data sets that looks like:

 

IDXYZ
4242329
5423136
6504342
7433121
8504428
9424930

and 

IDW
160
278
393
443
598
697
783
851
983
1042
1163
1295
1346
1472

I want to merge these for only complete information. I.e. I want to keep all of the ID's for the first data set and create a new column W which comes from the second data set. My desired result looks like this:

IDXYZW
424232943
542313698
650434297
743312183
850442851
942493083

How can I achieve this result?

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

please try the below code

 

proc sort data=tableA;
by id;
run;

proc sort data=tableB;
by id;
run;

data want;
merge tableA(in=a) tableB(in=b);
by id;
if a;
run;
Thanks,
Jag

View solution in original post

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

please try the below code

 

proc sort data=tableA;
by id;
run;

proc sort data=tableB;
by id;
run;

data want;
merge tableA(in=a) tableB(in=b);
by id;
if a;
run;
Thanks,
Jag
sasprogramming
Quartz | Level 8

That works thanks!

Is this what is called an 'inner join'? If so how would I modify the code for an 'outer join'?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 512 views
  • 1 like
  • 3 in conversation