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-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
  • 984 views
  • 0 likes
  • 2 in conversation