BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
val843
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
TarunKumar
Pyrite | Level 9

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

4 REPLIES 4
RichardinOz
Quartz | Level 8

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

Richard

Reeza
Super User

Why do you think you need parenthesis?

TarunKumar
Pyrite | Level 9

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;

val843
Calcite | Level 5

Thanks!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 4 replies
  • 621 views
  • 1 like
  • 4 in conversation