<?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: Conversion from Merge to PROC SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conversion-from-Merge-to-PROC-SQL/m-p/312935#M67929</link>
    <description>&lt;P&gt;Have a look into the EXCEPT operator&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/69049/HTML/default/viewer.htm#n0vo2lglyrnexwn14emi8m0jqvrj.htm&amp;nbsp;" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/sqlproc/69049/HTML/default/viewer.htm#n0vo2lglyrnexwn14emi8m0jqvrj.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 20 Nov 2016 22:16:27 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2016-11-20T22:16:27Z</dc:date>
    <item>
      <title>Conversion from Merge to PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conversion-from-Merge-to-PROC-SQL/m-p/312934#M67928</link>
      <description>&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.teenstudents;                              
  set sashelp.class;                                
  where age &amp;gt; 12;
run; 

data teenstudents2;
  set sashelp.class;
  where age &amp;gt; 14;
run;

data want;
  merge teenstudents(in=ts) teenstudents2(in=ts2);
  by name;
  keep name;
  if ts and not ts2;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;As you can see, I want all the names that are in teenstudents that are not in teenstudents2. The above merge works perfectly to accomplish that. But how do I do this in PROC SQL? I keep trying but I'm not getting the correct results. I left joined teenstudents with teenstudents2 on the condition that the names from each table do not equal each other, but I'm not getting the correct results...&lt;/P&gt;</description>
      <pubDate>Sun, 20 Nov 2016 22:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conversion-from-Merge-to-PROC-SQL/m-p/312934#M67928</guid>
      <dc:creator>JediApprentice</dc:creator>
      <dc:date>2016-11-20T22:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion from Merge to PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conversion-from-Merge-to-PROC-SQL/m-p/312935#M67929</link>
      <description>&lt;P&gt;Have a look into the EXCEPT operator&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/69049/HTML/default/viewer.htm#n0vo2lglyrnexwn14emi8m0jqvrj.htm&amp;nbsp;" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/sqlproc/69049/HTML/default/viewer.htm#n0vo2lglyrnexwn14emi8m0jqvrj.htm&amp;nbsp;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Nov 2016 22:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conversion-from-Merge-to-PROC-SQL/m-p/312935#M67929</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-20T22:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Conversion from Merge to PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conversion-from-Merge-to-PROC-SQL/m-p/312940#M67930</link>
      <description>&lt;P&gt;You can also use a left join and then filter the result to only pick-up records where the name from teenstudent2 is missing (=all records where there was no match to teenstudent2). Such an approach will return the same number of rows as long as the table relationship is not 1:M or M:M&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.teenstudents;                              
  set sashelp.class;                                
  where age &amp;gt; 12;
run; 

data teenstudents2;
  set sashelp.class;
  where age &amp;gt; 14;
run;

proc sql;
  select a.*
    from 
      teenstudents a
    left join
      teenstudents2 b
      on a.name=b.name
    having b.name is NULL
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 20 Nov 2016 22:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conversion-from-Merge-to-PROC-SQL/m-p/312940#M67930</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-11-20T22:44:24Z</dc:date>
    </item>
  </channel>
</rss>

