PROC SQL Joins on Multiple Tables

Suppose you need to join multiple tables by a primary key using PROC SQL.
PROC SQL : Multiple Tables

The sample data for three tables are shown below. The primary key in these tables is the variable "ID". We need to join these tables.

Create Sample Data
data temp;
input id x1 x2;
1 25 37
2 35 47
3 44 97
data temp2;
input id var1 var2;
2 65 37
3 85 47
5 34 97

data temp3;
input id xx1 xx2;
3 55 37
5 25 47
4 64 97

proc sql noprint;
create table test as
select a.ID, b.*, c.* from
temp a left join temp2 b
on =
left join temp3 c
on =;
Output : Joined Table

Proc SQL Tutorials : 15 Proc SQL Tutorials

SAS Tutorials : 100 Free SAS Tutorials

About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 7 years of experience in data science and predictive modeling. During his tenure, he has worked with global clients in various domains like banking, Telecom, HR and Health Insurance.

While I love having friends who agree, I only learn from those who don't.

Let's Get Connected: Email | LinkedIn

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*
Related Posts:
1 Response to "PROC SQL Joins on Multiple Tables"

Next → ← Prev