Hi all,
I'm trying to join 3 tables in on proc sql statement and i can't seem to figure out how to do so...
the code below is what i have:
proc sql;
create table test as
select a.store, b.name, c.type
from data1 a
inner join data2 b
on a.id = b.id
left join data3 c
on b.id2=c.id2
and
<exclusion statements>...
;
quit;
is there something wrong with my code?
thanks for your help!
Nothing wrong with your code, which means there's something wrong in the logic.
Things to check - join types inner vs left vs right
And your exclusion criteria. You can run it without and then with to see if that helps.
Nothing wrong with your code, which means there's something wrong in the logic.
Things to check - join types inner vs left vs right
And your exclusion criteria. You can run it without and then with to see if that helps.
Thanks, Reeza.
I ran the code with the exclusion statements and the dataset created seemed to have ignored all the exclusion criteria i wrote.
do you have any ideas as to why this might happen?
exclusion statements:
....
and b.sls_typ ^= '05'
and ( (b.xtnd_prc > 0.01) or (b.xtnd_prc < -0.01) )
and b.trans_dt >= '03JAN2016'd/*&beg_dt1*/
and b.trans_dt <= '04JAN2016'd/*&end_dt1*/
and a.ADDR_ID ^= .
order by a.ADDR_ID
;
ahh nevermind. the code is working out...my datasets timed out so they weren't being read in.
thanks for the help!
They belong in a WHERE most likely, not on the join condition.
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.
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.