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;
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;
Try using a separate ON clause after each left join, rather than a single combined clause after the second join.
Richard
Why do you think you need parenthesis?
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;
Thanks!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.