<?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: How do i use proc sql to get matched/unmatched records from two datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/336844#M76405</link>
    <description>&lt;P&gt;Yes. This worked. I was joining using only id and hence wasnt getting the solution as I wanted.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Mar 2017 05:25:51 GMT</pubDate>
    <dc:creator>vsharipriya</dc:creator>
    <dc:date>2017-03-01T05:25:51Z</dc:date>
    <item>
      <title>How do i use proc sql to get matched/unmatched records from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/336132#M76174</link>
      <description>&lt;P&gt;I have two datasets:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;/P&gt;&lt;P&gt;input id acctype$ catalogtype$ amount;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 credit issued&amp;nbsp;10&lt;BR /&gt;1 credit&amp;nbsp;refund 5&lt;BR /&gt;1 credit&amp;nbsp;cancelled&amp;nbsp;20&lt;BR /&gt;2 debit&amp;nbsp;issued 20&lt;BR /&gt;2 debit&amp;nbsp;refund 20&lt;BR /&gt;3 cash&amp;nbsp;issued 20&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data two;&lt;/P&gt;&lt;P&gt;input id acctype$ catalogtype$ amount;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1 credit issued&amp;nbsp;10&lt;BR /&gt;1 credit&amp;nbsp;refund 10&lt;BR /&gt;1 credit&amp;nbsp;cancelled 10&lt;BR /&gt;2 debit&amp;nbsp;issued 20&lt;BR /&gt;2 debit&amp;nbsp;refund 10&lt;BR /&gt;4 cash refund&amp;nbsp;10&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want a output that should get matched records from left table, and non matching records from right table like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 credit issued 10 matched&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1 &lt;/SPAN&gt;&lt;SPAN&gt;credit&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;refund 5 &amp;nbsp; not-matched&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1 &lt;/SPAN&gt;&lt;SPAN&gt;credit&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;cancelled&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;not-matched&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2 &lt;/SPAN&gt;&lt;SPAN&gt;debit&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;issued&lt;/SPAN&gt;&lt;SPAN&gt; 20 matched&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2 &lt;/SPAN&gt;&lt;SPAN&gt;debit&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;refund&lt;/SPAN&gt;&lt;SPAN&gt; 20 not-matched&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3 &lt;/SPAN&gt;&lt;SPAN&gt;cash&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;issued 20 not-matched&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want this specifically using proc sql, please. I tried left outer join and union all of both datasets but not able to get solution.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2017 09:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/336132#M76174</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2017-02-27T09:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do i use proc sql to get matched/unmatched records from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/336134#M76176</link>
      <description>&lt;PRE&gt;proc sql;
   create table WANT as 
  select  A.*,
          case when B.ID is not null then "Matched" else "UnMatched" end as RES
  from    ONE A
  left join TWO B
  on      A.ID=B.ID
  and     A.ACCTYPE=B.ACCTYPE
  and     A.CATALOGTYPE=B.CATALOGTYPE
  and     A.AMOUNT=B.AMOUNT;
quit;&lt;/PRE&gt;
&lt;P&gt;Not tested, but that should work.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2017 09:43:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/336134#M76176</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-27T09:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do i use proc sql to get matched/unmatched records from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/336844#M76405</link>
      <description>&lt;P&gt;Yes. This worked. I was joining using only id and hence wasnt getting the solution as I wanted.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 05:25:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/336844#M76405</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2017-03-01T05:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do i use proc sql to get matched/unmatched records from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/336845#M76406</link>
      <description>Try this please&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table WANT as&lt;BR /&gt;select A.*,&lt;BR /&gt;case when B.ID is not null then "Matched" else "UnMatched" end as RES&lt;BR /&gt;from ONE A&lt;BR /&gt;left join TWO B&lt;BR /&gt;on A.ID=B.ID;&lt;BR /&gt;quit;</description>
      <pubDate>Wed, 01 Mar 2017 05:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/336845#M76406</guid>
      <dc:creator>Yavuz</dc:creator>
      <dc:date>2017-03-01T05:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do i use proc sql to get matched/unmatched records from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/336848#M76408</link>
      <description>Thanks for the solution. But as i said, joining with just the id did not do my job.Had to join on all the fields like previous solution. Because I want to look at all the fields to match on amount</description>
      <pubDate>Wed, 01 Mar 2017 05:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/336848#M76408</guid>
      <dc:creator>vsharipriya</dc:creator>
      <dc:date>2017-03-01T05:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do i use proc sql to get matched/unmatched records from two datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/337096#M76499</link>
      <description>Sorry. I suggest that create a new variable as newvar and join them:&lt;BR /&gt;&lt;BR /&gt;Data one1;&lt;BR /&gt;Set one;&lt;BR /&gt;Newvar=put(id,10.)||acctype||catalogtype||put(amount,2.);&lt;BR /&gt;&lt;BR /&gt;Data two1;&lt;BR /&gt;Set two;&lt;BR /&gt;Newvar=put(id,10.)||acctype||catalogtype||put(amount,2.);</description>
      <pubDate>Wed, 01 Mar 2017 18:31:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-use-proc-sql-to-get-matched-unmatched-records-from-two/m-p/337096#M76499</guid>
      <dc:creator>Yavuz</dc:creator>
      <dc:date>2017-03-01T18:31:47Z</dc:date>
    </item>
  </channel>
</rss>

