<?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 how to return all mismatched records in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-how-to-return-all-mismatched-records/m-p/740336#M29045</link>
    <description>&lt;P&gt;If I have the following two datasets:&lt;/P&gt;&lt;P&gt;data set ONE:&lt;/P&gt;&lt;P&gt;ID X&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; a&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; .&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; c&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data set TWO:&lt;/P&gt;&lt;P&gt;ID Y&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; a&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; b&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; d&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; e&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the output I am looking for:&lt;/P&gt;&lt;P&gt;ID X &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; . &amp;nbsp; b&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; c &amp;nbsp; .&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; . &amp;nbsp; d&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; a &amp;nbsp;e&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do this in PROC SQL?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 May 2021 01:28:21 GMT</pubDate>
    <dc:creator>cosmid</dc:creator>
    <dc:date>2021-05-11T01:28:21Z</dc:date>
    <item>
      <title>PROC SQL how to return all mismatched records</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-how-to-return-all-mismatched-records/m-p/740336#M29045</link>
      <description>&lt;P&gt;If I have the following two datasets:&lt;/P&gt;&lt;P&gt;data set ONE:&lt;/P&gt;&lt;P&gt;ID X&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; a&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; .&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; c&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data set TWO:&lt;/P&gt;&lt;P&gt;ID Y&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; a&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; b&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; d&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; e&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the output I am looking for:&lt;/P&gt;&lt;P&gt;ID X &amp;nbsp;Y&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; . &amp;nbsp; b&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; c &amp;nbsp; .&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; . &amp;nbsp; d&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; a &amp;nbsp;e&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to do this in PROC SQL?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 01:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-how-to-return-all-mismatched-records/m-p/740336#M29045</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-05-11T01:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL how to return all mismatched records</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-how-to-return-all-mismatched-records/m-p/740342#M29048</link>
      <description>&lt;P&gt;So if X &amp;amp; Y are the same you delete the record? In that case this would work, assuming your input data is sorted by ID.&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;merge one two;&lt;BR /&gt;by ID;&lt;BR /&gt;if x = y then delete;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as&lt;/P&gt;
&lt;P&gt;select coalesce(t1.ID, t2.ID) as ID, X, Y&lt;/P&gt;
&lt;P&gt;from ONE as t1&lt;/P&gt;
&lt;P&gt;full join TWO as t2&lt;/P&gt;
&lt;P&gt;on t1.id = t2.id&lt;/P&gt;
&lt;P&gt;where x ne y;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Tue, 11 May 2021 02:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-how-to-return-all-mismatched-records/m-p/740342#M29048</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-11T02:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL how to return all mismatched records</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-how-to-return-all-mismatched-records/m-p/740442#M29060</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ONE;
input ID X $;
cards;
1   a
2   .
3   c
6   a
;
 

data TWO;
input ID Y $;
cards;
1   a
2   b
5   d
6   e
;


proc sql;
create table want as
select coalesce(a.id,b.id) as id,x,y
 from 
 (select * from one except select * from two) as a
 full join
 (select * from two except select * from one) as b
 on a.id=b.id;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 May 2021 12:27:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-how-to-return-all-mismatched-records/m-p/740442#M29060</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-11T12:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL how to return all mismatched records</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-how-to-return-all-mismatched-records/m-p/740518#M29076</link>
      <description>Wow, that datastep is so clean compared to a Proc SQL. I needed Proc SQL for my case because with Proc SQL it will not print anything to the output window if the dataset is empty.&lt;BR /&gt;&lt;BR /&gt;Thank you for the help!&lt;BR /&gt;&lt;BR /&gt;And I really need to read more about coalesce and full joins!</description>
      <pubDate>Tue, 11 May 2021 15:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-how-to-return-all-mismatched-records/m-p/740518#M29076</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-05-11T15:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL how to return all mismatched records</title>
      <link>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-how-to-return-all-mismatched-records/m-p/740519#M29077</link>
      <description>Thank you Ksharp! both your code and Reeza's worked. I would have accepted both as a solution but it only allowed me to pick one so I just picked one that replied earlier hopefully you are okay with it. I really appreciate your help on this! I learned from both of your codes! Thanks again!</description>
      <pubDate>Tue, 11 May 2021 15:26:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/PROC-SQL-how-to-return-all-mismatched-records/m-p/740519#M29077</guid>
      <dc:creator>cosmid</dc:creator>
      <dc:date>2021-05-11T15:26:44Z</dc:date>
    </item>
  </channel>
</rss>

