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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.