SAS : Join on Multiple Columns

Suppose you need to join two data sets (tables) based on multiple variables (columns) in SAS.

Step I : Creating two data sets (tables)
data def;
input a b $ d;
123 X 5
441 D 2

data abc;
input a b $ c;
123 A 5
123 B 6
123 X 8
441 C 2
441 D 5
Task : Suppose you need to join these two data sets (tables) based on variables a and b.

Step II : SQL Joins / Data Step Merge Statements
proc sql noprint;
create table xyz as
select * from
def x left join abc y
on x.a = y.a and x.b = y.b;
data xyz1;
merge def(in=x) abc(in=Y);
by a b;
if x;

Spread the Word!
Related Posts
About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and Human Resource.

1 Response to "SAS : Join on Multiple Columns"

Next → ← Prev

Looks like you are using an ad blocker!

To continue reading you need to turnoff adblocker and refresh the page. We rely on advertising to help fund our site. Please whitelist us if you enjoy our content.