Help using Base SAS procedures

left join with more tables

Accepted Solution Solved
Reply
Super Contributor
Super Contributor
Posts: 440
Accepted Solution

left join with more tables


hello

i have 4 tables and i need to join them. The 1st table has about 1M records and the other 3 about 20M each but i only need all the records from the 1st with all the coresponding ones  from the  other 3 tables which means left  join on the 1st table would do the job,right?

But how do i do left join with more then   2  tables? Smiley Happy


Accepted Solutions
Solution
‎07-14-2015 09:32 PM
Respected Advisor
Posts: 4,654

Re: left join with more tables

The basic structure is like this:

select a.*, b.x, c.y, d.z

from a left join

  b on a.id=b.id left join

  c on a.id=c.id left join

  d on a.id=d.id

Keep referring to the first table for the joins.

PG

PG

View solution in original post


All Replies
Contributor
Posts: 26

Re: left join with more tables


Here is a link to the question asked for MySQL http://stackoverflow.com/questions/7980052/how-to-do-left-join-with-more-than-2-tables

the proc sql syntax should be very similar.

Solution
‎07-14-2015 09:32 PM
Respected Advisor
Posts: 4,654

Re: left join with more tables

The basic structure is like this:

select a.*, b.x, c.y, d.z

from a left join

  b on a.id=b.id left join

  c on a.id=c.id left join

  d on a.id=d.id

Keep referring to the first table for the joins.

PG

PG
Super Contributor
Super Contributor
Posts: 440

Re: left join with more tables


thanks. This is really siimple

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 290 views
  • 5 likes
  • 3 in conversation