BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
FK21
Obsidian | Level 7

Hi Folks,

 

I have a couple of questions with respect to the following code:

 

data class1(drop=in2) class2 (drop=in1);
set sashelp.class (keep=name) ;
in1  = "left";
in2 = "right";
run;


PROC SQL;
create table work.join_syntax as 
select coalesce(cl1.name , cl2.name) as name, in1, in2
from work.class1 as cl1 inner join work.class2 as cl2
on cl1.name = cl2.name
;

create table work.where_syntax as 
select coalesce(cl1.name , cl2.name) as name, in1, in2
from work.class1 as cl1 , work.class2 as cl2
where cl1.name = cl2.name
;

quit;

 

The result table seems to be identical in terms of observations.

Does this also hold, when one or both of the tables have duplicat key values?

Also, with regards to the sort order and performance, respectivley: is it advantageous to use one over the other?

 

A similar question was asked with regards to EG code generation back in 2011:
https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-Vs-Where/td-p/28293

 

Cheers, 

FK21

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Semantically, the codes do the same and will produce the same result; multiple observations for a key value will also result in the same cartesian products.

If there is a performance difference is best determined through tests with sufficiently large datasets.

You can use the _METHOD and _TREE options of the PROC SQL statement to see how the query is handled internally.

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

Semantically, the codes do the same and will produce the same result; multiple observations for a key value will also result in the same cartesian products.

If there is a performance difference is best determined through tests with sufficiently large datasets.

You can use the _METHOD and _TREE options of the PROC SQL statement to see how the query is handled internally.

FK21
Obsidian | Level 7
Thank you, Kurt for your quick and clean answer!

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 697 views
  • 0 likes
  • 2 in conversation