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;

Best Online Course : Practical SQL Guide for Beginners

Proc SQL Tutorials : 15 Proc SQL Tutorials

SAS Tutorials : 100 Free SAS Tutorials

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

1 Response to "SAS : Join on Multiple Columns"

Next → ← Prev