<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic PROC SQL: JOIN versus WHERE Syntax in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-JOIN-versus-WHERE-Syntax/m-p/932381#M366787</link>
    <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a couple of questions with respect to the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result table seems to be identical in terms of observations.&lt;/P&gt;&lt;P&gt;Does this also hold, when one or both of the tables have duplicat key values?&lt;/P&gt;&lt;P&gt;Also, with regards to the sort order and performance, respectivley: is it advantageous to use one over the other?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A similar question was asked with regards to EG code generation back in 2011:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-Vs-Where/td-p/28293" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-Vs-Where/td-p/28293&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&amp;nbsp;&lt;/P&gt;&lt;P&gt;FK21&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jun 2024 09:35:24 GMT</pubDate>
    <dc:creator>FK21</dc:creator>
    <dc:date>2024-06-14T09:35:24Z</dc:date>
    <item>
      <title>PROC SQL: JOIN versus WHERE Syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-JOIN-versus-WHERE-Syntax/m-p/932381#M366787</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a couple of questions with respect to the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The result table seems to be identical in terms of observations.&lt;/P&gt;&lt;P&gt;Does this also hold, when one or both of the tables have duplicat key values?&lt;/P&gt;&lt;P&gt;Also, with regards to the sort order and performance, respectivley: is it advantageous to use one over the other?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A similar question was asked with regards to EG code generation back in 2011:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-Vs-Where/td-p/28293" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Enterprise-Guide/Join-Vs-Where/td-p/28293&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&amp;nbsp;&lt;/P&gt;&lt;P&gt;FK21&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 09:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-JOIN-versus-WHERE-Syntax/m-p/932381#M366787</guid>
      <dc:creator>FK21</dc:creator>
      <dc:date>2024-06-14T09:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: JOIN versus WHERE Syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-JOIN-versus-WHERE-Syntax/m-p/932390#M366793</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;If there is a performance difference is best determined through tests with sufficiently large datasets.&lt;/P&gt;
&lt;P&gt;You can use the _METHOD and _TREE options of the PROC SQL statement to see how the query is handled internally.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2024 10:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-JOIN-versus-WHERE-Syntax/m-p/932390#M366793</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2024-06-14T10:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: JOIN versus WHERE Syntax</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-JOIN-versus-WHERE-Syntax/m-p/932391#M366794</link>
      <description>Thank you, Kurt for your quick and clean answer!</description>
      <pubDate>Fri, 14 Jun 2024 11:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-JOIN-versus-WHERE-Syntax/m-p/932391#M366794</guid>
      <dc:creator>FK21</dc:creator>
      <dc:date>2024-06-14T11:34:30Z</dc:date>
    </item>
  </channel>
</rss>

