<?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 Re: proc sql question in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-question/m-p/71488#M20639</link>
    <description>Need to illustrate sth that merge statement is a little different with proc sql join.&lt;BR /&gt;
So.For your question.&lt;BR /&gt;
[pre]&lt;BR /&gt;
Assuming there are not duplicated observations for by variable (or key variable)&lt;BR /&gt;
&lt;BR /&gt;
if a = 1 /* Left Join */  &lt;BR /&gt;
is identified with left join in proc sql. Such as : proc sql;......from a left join b on ....&lt;BR /&gt;
&lt;BR /&gt;
if b = 1 /* Right Join */&lt;BR /&gt;
is identified with rightjoin in proc sql. Such as : proc sql;......from a right join b on ....&lt;BR /&gt;
&lt;BR /&gt;
if (a=1 and b=1) /* Inner join */&lt;BR /&gt;
is identified with inner join in proc sql. Such as : proc sql;......from a inner join b on ....&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
if (a=0 and b=1)  is identified with if b = 1&lt;BR /&gt;
if (a=1 and b=0)  is identified with if a=1&lt;BR /&gt;
Because in merge statement, there are only three type with in-variable&lt;BR /&gt;
a b&lt;BR /&gt;
1 0&lt;BR /&gt;
0 1&lt;BR /&gt;
1 1&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
So if a + b  is identified with all these three type &lt;BR /&gt;
So it is the same as &lt;BR /&gt;
data x;&lt;BR /&gt;
merge one(in=a) two(in=b);&lt;BR /&gt;
 by ...;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Hope you are clarified more.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
    <pubDate>Thu, 02 Jun 2011 01:26:47 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-06-02T01:26:47Z</dc:date>
    <item>
      <title>proc sql question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-question/m-p/71486#M20637</link>
      <description>Hi,&lt;BR /&gt;
I'm trying to compare and learn proc sql joins to data step merge. I know proc sql code for Left, Right and Inner join and its associated data merge code. &lt;BR /&gt;
I want to know how do we code the below data step logic in proc sql. Help on the ones that are not commented. &lt;BR /&gt;
&lt;BR /&gt;
data x;&lt;BR /&gt;
merge one(in=a) two(in=b);&lt;BR /&gt;
if a = 1  /* Left Join */&lt;BR /&gt;
if b = 1 /* Right Join */&lt;BR /&gt;
if (a=1 and b=1) /* Inner join */&lt;BR /&gt;
if (a=0 and b=1) &lt;BR /&gt;
if (a=1 and b=0) &lt;BR /&gt;
if a + b</description>
      <pubDate>Tue, 31 May 2011 20:05:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-question/m-p/71486#M20637</guid>
      <dc:creator>helloSAS</dc:creator>
      <dc:date>2011-05-31T20:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-question/m-p/71487#M20638</link>
      <description>Please see below.&lt;BR /&gt;
&amp;gt; Hi,&lt;BR /&gt;
&amp;gt; I'm trying to compare and learn proc sql joins to&lt;BR /&gt;
&amp;gt; data step merge. I know proc sql code for Left, Right&lt;BR /&gt;
&amp;gt; and Inner join and its associated data merge code. &lt;BR /&gt;
&amp;gt; I want to know how do we code the below data step&lt;BR /&gt;
&amp;gt; logic in proc sql. Help on the ones that are not&lt;BR /&gt;
&amp;gt; commented. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; data x;&lt;BR /&gt;
&amp;gt; merge one(in=a) two(in=b);&lt;BR /&gt;
&amp;gt; if a = 1  /* Left Join */&lt;BR /&gt;
&amp;gt; if b = 1 /* Right Join */&lt;BR /&gt;
&amp;gt; if (a=1 and b=1) /* Inner join */&lt;BR /&gt;
Operations, not quite joins if I understand what you are attempting.&lt;BR /&gt;
I think the first two here might be EXCEPT operations, order is important in EXCEPT so both are same type.&lt;BR /&gt;
&amp;gt; if (a=0 and b=1) &lt;BR /&gt;
&amp;gt; if (a=1 and b=0) &lt;BR /&gt;
If either set contributies this is a UNION operation, but you need to decide if you want OUTER (a=1 or b=1) or an EXCLUSIVE UNION (a=1 or b=1 but not a=1 and b=1)&lt;BR /&gt;
&amp;gt; if a + b</description>
      <pubDate>Tue, 31 May 2011 23:02:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-question/m-p/71487#M20638</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-05-31T23:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql question</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-question/m-p/71488#M20639</link>
      <description>Need to illustrate sth that merge statement is a little different with proc sql join.&lt;BR /&gt;
So.For your question.&lt;BR /&gt;
[pre]&lt;BR /&gt;
Assuming there are not duplicated observations for by variable (or key variable)&lt;BR /&gt;
&lt;BR /&gt;
if a = 1 /* Left Join */  &lt;BR /&gt;
is identified with left join in proc sql. Such as : proc sql;......from a left join b on ....&lt;BR /&gt;
&lt;BR /&gt;
if b = 1 /* Right Join */&lt;BR /&gt;
is identified with rightjoin in proc sql. Such as : proc sql;......from a right join b on ....&lt;BR /&gt;
&lt;BR /&gt;
if (a=1 and b=1) /* Inner join */&lt;BR /&gt;
is identified with inner join in proc sql. Such as : proc sql;......from a inner join b on ....&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
if (a=0 and b=1)  is identified with if b = 1&lt;BR /&gt;
if (a=1 and b=0)  is identified with if a=1&lt;BR /&gt;
Because in merge statement, there are only three type with in-variable&lt;BR /&gt;
a b&lt;BR /&gt;
1 0&lt;BR /&gt;
0 1&lt;BR /&gt;
1 1&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
So if a + b  is identified with all these three type &lt;BR /&gt;
So it is the same as &lt;BR /&gt;
data x;&lt;BR /&gt;
merge one(in=a) two(in=b);&lt;BR /&gt;
 by ...;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Hope you are clarified more.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 02 Jun 2011 01:26:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-question/m-p/71488#M20639</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-02T01:26:47Z</dc:date>
    </item>
  </channel>
</rss>

