<?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: Match tables A and Table B and bring back data that does not match in table B in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507107#M136043</link>
    <description>&lt;P&gt;My apologies, when I checked the tables they have millions of lines and I noticed that sometimes the name is the same but date1 is different, therefore I would class this as a mismatch (date 2 is not an issue this does not matter), your code seems a little complicated when trying to do it this way, I don't really understand it&lt;/P&gt;</description>
    <pubDate>Wed, 24 Oct 2018 11:10:32 GMT</pubDate>
    <dc:creator>zdassu</dc:creator>
    <dc:date>2018-10-24T11:10:32Z</dc:date>
    <item>
      <title>Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507094#M136036</link>
      <description>&lt;P&gt;Hi I have two&amp;nbsp;tables, table A and Table B, I want to match these&amp;nbsp;tables and I want to bring back everything where the&amp;nbsp;data&amp;nbsp;in Table B&amp;nbsp;does not match table A by the name field. See sample data below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TableA&lt;/P&gt;&lt;P&gt;name&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date2&lt;/P&gt;&lt;P&gt;7328914&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/10/2008&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31/12/2099&lt;/P&gt;&lt;P&gt;7338572&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 27/07/2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31/12/2099&lt;/P&gt;&lt;P&gt;7400000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/10/2010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31/12/2099&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TableB&lt;/P&gt;&lt;P&gt;name&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date2&lt;/P&gt;&lt;P&gt;7328914&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/10/2008&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31/12/2099&lt;/P&gt;&lt;P&gt;7338572&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;27/07/2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31/12/2099&lt;/P&gt;&lt;P&gt;7400000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/10/2010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31/12/2099&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 10:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507094#M136036</guid>
      <dc:creator>zdassu</dc:creator>
      <dc:date>2018-10-24T10:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507096#M136038</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=table_a;
by name;
run;

proc sort
  data=table_b (keep=name)
  out=exclude
  nodupkey
;
by name;
run;

data want;
merge
  table_a (in=a)
  exclude (in=b)
;
by name;
if a and not b;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The nodupkey is there to prevent unwanted observations if table_b has more obs for a given name than table_a.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 10:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507096#M136038</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-24T10:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507098#M136039</link>
      <description>&lt;P&gt;Thanks for your replay, what would I do if I want to bring everything back that does not match in table B&lt;/P&gt;&lt;P&gt;By Name and Date1&lt;/P&gt;&lt;P&gt;for example&lt;/P&gt;&lt;P&gt;Table A Name = Table B Name&lt;/P&gt;&lt;P&gt;And Table A Date1 = Table B Date1&lt;/P&gt;&lt;P&gt;Bring back everything that does not match&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 11:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507098#M136039</guid>
      <dc:creator>zdassu</dc:creator>
      <dc:date>2018-10-24T11:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507101#M136041</link>
      <description>&lt;P&gt;You could do something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
input name$ (date1 date2)(:ddmmyy10.);
format date: ddmmyy10.;
datalines;
7328914 01/10/2008 31/12/2099
7338572 27/07/2015 31/12/2099
7400000 01/10/2010 31/12/2099
;

data B;
input name$ (date1 date2)(:ddmmyy10.);
format date: ddmmyy10.;
datalines;
7328914 01/10/2008 31/12/2099
7338572 27/07/2015 31/12/2099
7400000 01/10/2010 31/12/2099
;

data want;
   if 0 then set B;
   if _N_=1 then do;
      declare hash h(dataset:"B", multidata:"Y");
      h.definekey("name", "date1");
      h.definedata(all:"Y");
      h.definedone();
   end; 
   set A;
   if h.check()&amp;gt;0 then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Oct 2018 11:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507101#M136041</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-24T11:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507102#M136042</link>
      <description>&lt;P&gt;Quote from your original post:&lt;/P&gt;
&lt;P&gt;"where the&amp;nbsp;data&amp;nbsp;in Table B&amp;nbsp;does not match table A by the &lt;STRONG&gt;name&lt;/STRONG&gt; field"&lt;/P&gt;
&lt;P&gt;(emphasis by me)&lt;/P&gt;
&lt;P&gt;My code does exactly that.&lt;/P&gt;
&lt;P&gt;Please make up your mind what you really want.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 11:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507102#M136042</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-24T11:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507107#M136043</link>
      <description>&lt;P&gt;My apologies, when I checked the tables they have millions of lines and I noticed that sometimes the name is the same but date1 is different, therefore I would class this as a mismatch (date 2 is not an issue this does not matter), your code seems a little complicated when trying to do it this way, I don't really understand it&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 11:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507107#M136043</guid>
      <dc:creator>zdassu</dc:creator>
      <dc:date>2018-10-24T11:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507108#M136044</link>
      <description>&lt;P&gt;In that case, you need to use both variables in the by statements:&lt;/P&gt;
&lt;P&gt;(stealing the example data from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt;)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table_A;
input name$ (date1 date2)(:ddmmyy10.);
format date: ddmmyy10.;
datalines;
7328914 01/10/2008 31/12/2099
7338572 27/07/2015 31/12/2099
7400000 01/10/2010 31/12/2099
7400000 03/10/2010 31/12/2099
;
run;

data table_B;
input name$ (date1 date2)(:ddmmyy10.);
format date: ddmmyy10.;
datalines;
7328914 01/10/2008 31/12/2099
7338572 27/07/2015 31/12/2099
7400000 01/10/2010 31/12/2099
7400000 02/10/2010 31/12/2099
;
run;

/* sort both datasets by the important variables */
proc sort data=table_a;
by name date1;
run;

proc sort
  data=table_b (keep=name date1)
  out=exclude
  nodupkey
;
by name date1;
run;

/* now, a simple merge by the same variables */
data want;
merge
  table_a (in=a) /* creates automatic boolean variable a that indicates an observation from table_a was read */
  exclude (in=b) /* same for the exclude table */
;
by name date1;
if a and not b; /* take only observations from table_a for which no match was found in exclude dataset */
/* this is called a "subsetting if" */
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since your example data had only perfect matches, I put in some extra lines to verify the function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the hash solution suggested by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; will also work (and probably be faster), but be limited by available memory. The sort/data step solution is limited by disk space only.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 11:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507108#M136044</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-24T11:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507112#M136046</link>
      <description>&lt;P&gt;Maybe:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table want as 
  select * from tablea except select * from tableb
  union all
  select * from tableb except select * from tablea;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Oct 2018 12:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507112#M136046</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-24T12:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507144#M136058</link>
      <description>&lt;P&gt;Here's a simple approach, assuming both of your data sets are already sorted by NAME:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge a  b (rename=(date1=date1b date2=date2b));
by name;
if (date1 ne date1b) or (date2 ne date2b);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Oct 2018 13:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507144#M136058</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-10-24T13:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507180#M136068</link>
      <description>&lt;P&gt;Thanks for your help much appreciated&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507180#M136068</guid>
      <dc:creator>zdassu</dc:creator>
      <dc:date>2018-10-24T14:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507181#M136069</link>
      <description>&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507181#M136069</guid>
      <dc:creator>zdassu</dc:creator>
      <dc:date>2018-10-24T14:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507182#M136070</link>
      <description>Thanks</description>
      <pubDate>Wed, 24 Oct 2018 14:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507182#M136070</guid>
      <dc:creator>zdassu</dc:creator>
      <dc:date>2018-10-24T14:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Match tables A and Table B and bring back data that does not match in table B</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507254#M136125</link>
      <description>&lt;P&gt;HI&amp;nbsp; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/59173"&gt;@zdassu&lt;/a&gt;&amp;nbsp;Just a nit and FWIW if you play with hashes&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; h&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;check&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will not fetch the accurate records although will not produce any error. Assuming it's a typo, correcting to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; h&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;check&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; output&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;if check() ne 0 then output;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;or&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; h&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;check&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;if h.check() ne 0;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;rc= h&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;check&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;);&lt;BR /&gt;if rc=0;&lt;BR /&gt;if rc ne 0;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The return code based on object notation method always results in a non zero value when it fails, since it's non zero it's not ideal for inequality comparison operation unless the return code is of course reset to some value knowing that we are gonna use that for inequality comparisons. One of the tricky things is that any hash object would have a non-scalar value however return code being though being scalar in the PDV resulting from a object do notation operation is not particularly useful until some gymnastics is done.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The scalar vs non scalar in hashes is so similar to arrays but occurs at meta-level as opposed to giving much clarity. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 17:51:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Match-tables-A-and-Table-B-and-bring-back-data-that-does-not/m-p/507254#M136125</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-24T17:51:28Z</dc:date>
    </item>
  </channel>
</rss>

