Help using Base SAS procedures

SQL Inner Join with and without "Inner Join" phrase?

Accepted Solution Solved
Reply
Super Contributor
Posts: 338
Accepted Solution

SQL Inner Join with and without "Inner Join" phrase?

Hi SAS Forum,

I took the attahced two data sets from "SUGI 27 Paper 70-27 An Introduction to SAS PROC SQL by

Harrington, T. J. (Acknowledged thankfully).

  • I first ran the proc SQL inner join with "inner join" phrase.
  • Then ran without "inner join" phrase.
  • Then compared the two output files using "proc compare".
  • Results show both produced identical results.

Question:

For the given small two data sets, both appraoches produced identical results with "inner join" phrase or without it.

Can I however generalize this conclusion for other situaitions invovling large data sets?

Thanks

Mirisage

Attachment

Accepted Solutions
Solution
‎08-20-2013 11:20 AM
Contributor
Posts: 45

Re: SQL Inner Join with and without "Inner Join" phrase?

My understanding was that the  difference between using the inner join phrase and other methodology what that of efficiency, not output. I think it is that the inner join phrase uses a more elegant method than just a "where a.id=b.id" subsetting clause, as it does not simply construct a cartesian product and weed out all of the irrelevant matches.

View solution in original post


All Replies
Solution
‎08-20-2013 11:20 AM
Contributor
Posts: 45

Re: SQL Inner Join with and without "Inner Join" phrase?

My understanding was that the  difference between using the inner join phrase and other methodology what that of efficiency, not output. I think it is that the inner join phrase uses a more elegant method than just a "where a.id=b.id" subsetting clause, as it does not simply construct a cartesian product and weed out all of the irrelevant matches.

Respected Advisor
Posts: 4,920

Re: SQL Inner Join with and without "Inner Join" phrase?

The constructs

select ... from A, B where A.var=B.var

and

select ... from A inner join B on A.var=B.var

are perfectly equivalent. However, in the second case you can replace the word inner by left or right, and by cross or natural if you also remove the on clause.

PG

PG
Super Contributor
Posts: 338

Re: SQL Inner Join with and without "Inner Join" phrase?

Hi Murray_Court and PGStats,

Many thanks to both of you for this help.

Regards

Mirisage

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 264 views
  • 3 likes
  • 3 in conversation