BookmarkSubscribeRSS Feed
Sas_Act_114
Fluorite | Level 6

Hello all,

 

I am looking through a SAS program and there are several left joins written that has me scratching my head. To give a simple example, say there are three tables A, B, and C. The coding goes something like this:

 

Select *

From A Left Outer Join B

On A.ID1 = B.ID1

Left Outer Join C

On B.ID2 = C.ID2

 

This is the first time I have seen left joins set up this way. I don't know if the program is joining tables B and C and then joining that new table to A, or if it joins A and B first, and then joins C to the new combined A/B table. Any clarification on this is appreciated, thanks!

1 REPLY 1
PGStats
Opal | Level 21

In SAS/SQL these joins are performed left to right, i.e. A with B then the result joined with C. The order can be altered with parentheses.

 

Select *
From A Left Outer Join
(B Left Outer Join C On B.ID2 = C.ID2) as D
On A.ID1 = D.ID1;

PG

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 292 views
  • 1 like
  • 2 in conversation