Proc Sql 3 Tables Left Join Help Needed

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Proc Sql 3 Tables Left Join Help Needed

Hi everyone,

I am just learning to code and need assistance on how to join 3 tables. I think there should be a parenthesis somewhere but cant figure it out. Thank you!

proc sql;

create table aero.affiliate_orders as

select a.ordernumber,

        a.Affiliate,

        a.Revenue,

        b.Publisher_category,

        c.new_customer

from    

    aero.clc a

left join

    aero.affiliate_cat b

left join

    aero.new_repeat_master_customer c

ON a.ordernumber=c.order_number and

    a.affiliate = b.company_name

where a.sourcetype="Affiliate"

;quit;


Accepted Solutions
Solution
‎04-01-2014 03:07 AM
Contributor
Posts: 74

Re: Proc Sql 3 Tables Left Join Help Needed

proc sql;

create table aero.affiliate_orders as

select a.ordernumber,

        a.Affiliate,

        a.Revenue,

        b.Publisher_category,

        c.new_customer

from  aero.clc a

left join   aero.affiliate_cat b

     on    a.affiliate = b.company_name

left join  aero.new_repeat_master_customer c

     on a.ordernumber=c.order_number

where a.sourcetype="Affiliate"

;quit;

View solution in original post


All Replies
Super Contributor
Posts: 644

Re: Proc Sql 3 Tables Left Join Help Needed

Try using a separate ON clause after each left join, rather than a single combined clause after the second join.

Richard

Super User
Posts: 17,819

Re: Proc Sql 3 Tables Left Join Help Needed

Why do you think you need parenthesis?

Solution
‎04-01-2014 03:07 AM
Contributor
Posts: 74

Re: Proc Sql 3 Tables Left Join Help Needed

proc sql;

create table aero.affiliate_orders as

select a.ordernumber,

        a.Affiliate,

        a.Revenue,

        b.Publisher_category,

        c.new_customer

from  aero.clc a

left join   aero.affiliate_cat b

     on    a.affiliate = b.company_name

left join  aero.new_repeat_master_customer c

     on a.ordernumber=c.order_number

where a.sourcetype="Affiliate"

;quit;

Occasional Contributor
Posts: 5

Re: Proc Sql 3 Tables Left Join Help Needed

Thanks!

☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 220 views
  • 1 like
  • 4 in conversation