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

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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.

View solution in original post

4 REPLIES 4
Reeza
Super User

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.

lai302120
Calcite | Level 5

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
;

 

 

lai302120
Calcite | Level 5

ahh nevermind. the code is working out...my datasets timed out so they weren't being read in.

 

thanks for the help!

Reeza
Super User

They belong in a WHERE most likely, not on the join condition.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1250 views
  • 0 likes
  • 2 in conversation