<?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: Compare two large datasets and see which observations are missing in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-large-datasets-and-see-which-observations-are/m-p/773551#M245758</link>
    <description>&lt;P&gt;This is what I do in such cases:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=one;
by name;
run;

proc sort data=two;
by name;
run;

data
  common
  only_one
  only_two
;
merge
  one (in=o)
  two (in=t)
;
by name;
if o and t
then output common;
else if o
then output only_one;
else output only_two;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 12 Oct 2021 07:09:31 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-10-12T07:09:31Z</dc:date>
    <item>
      <title>Compare two large datasets and see which observations are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-large-datasets-and-see-which-observations-are/m-p/773550#M245757</link>
      <description>&lt;P&gt;I have two large datasets, where variables are different but shares similar id (or name in this example), how do I find out which obs are common and not?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data one;&lt;/P&gt;
&lt;P&gt;length name $30;&lt;BR /&gt;input name;&lt;BR /&gt;datalines;&lt;BR /&gt;mary&lt;BR /&gt;peter&lt;BR /&gt;john&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data two;&lt;/P&gt;
&lt;P&gt;length name $30;&lt;BR /&gt;input name;&lt;BR /&gt;datalines;&lt;BR /&gt;mary&lt;BR /&gt;peter&lt;BR /&gt;luke&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 07:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-two-large-datasets-and-see-which-observations-are/m-p/773550#M245757</guid>
      <dc:creator>ywon111</dc:creator>
      <dc:date>2021-10-12T07:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two large datasets and see which observations are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-large-datasets-and-see-which-observations-are/m-p/773551#M245758</link>
      <description>&lt;P&gt;This is what I do in such cases:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=one;
by name;
run;

proc sort data=two;
by name;
run;

data
  common
  only_one
  only_two
;
merge
  one (in=o)
  two (in=t)
;
by name;
if o and t
then output common;
else if o
then output only_one;
else output only_two;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Oct 2021 07:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-two-large-datasets-and-see-which-observations-are/m-p/773551#M245758</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-12T07:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two large datasets and see which observations are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-large-datasets-and-see-which-observations-are/m-p/773553#M245759</link>
      <description>&lt;P&gt;PS to speed up the process, sort to new datasets and keep only the key variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort
  data=one (keep=name)
  out=one_s
;
by name;
run;

proc sort
  data=two (keep=name)
  out=two_s
;
by name;
run;

data
  common
  only_one
  only_two
;
merge
  one_s (in=o)
  two_s (in=t)
;
by name;
if o and t
then output common;
else if o
then output only_one;
else output only_two;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 07:13:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-two-large-datasets-and-see-which-observations-are/m-p/773553#M245759</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-12T07:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: Compare two large datasets and see which observations are missing</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-two-large-datasets-and-see-which-observations-are/m-p/773608#M245786</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

data one;
length name $30;
input name;
datalines;
mary
peter
john
;
run;

 

data two;
length name $30;
input name;
datalines;
mary
peter
luke
;
run;


proc sql;
create table common_in_both as
select name from one
intersect
select name from two;

create table in_one_but_not_in_two as
select name from one
except
select name from two;

create table in_two_but_not_in_one as
select name from two
except
select name from one;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Oct 2021 12:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-two-large-datasets-and-see-which-observations-are/m-p/773608#M245786</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-10-12T12:20:15Z</dc:date>
    </item>
  </channel>
</rss>

