<?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 code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Compare-code/m-p/802127#M315755</link>
    <description>&lt;P&gt;If you just need to detect missing keys:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=a;
by subject;
run;

proc sort data=b;
by subject;
run;

data
  both
  only_a
  only_b
;
merge
  a (in=in_a)
  b (in=in_b)
;
by subject;
if in_a and in_b
then output both;
else if in_a
then output only_a;
else output only_b;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need more than that, look at &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1nwxbchh5hpu1n1h28kmici2awd.htm" target="_blank" rel="noopener"&gt;PROC COMPARE&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Tue, 15 Mar 2022 07:49:39 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-03-15T07:49:39Z</dc:date>
    <item>
      <title>Compare code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-code/m-p/802125#M315753</link>
      <description>&lt;P&gt;How to compare to Two datasets and output the difference by using subject variable which is present in both domains using proc freq .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset A;&lt;/P&gt;&lt;P&gt;subject&amp;nbsp;&lt;/P&gt;&lt;P&gt;123&lt;/P&gt;&lt;P&gt;232&lt;/P&gt;&lt;P&gt;234&lt;/P&gt;&lt;P&gt;120&lt;/P&gt;&lt;P&gt;001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATASET B&lt;/P&gt;&lt;P&gt;subject&amp;nbsp;&lt;/P&gt;&lt;P&gt;123&lt;/P&gt;&lt;P&gt;232&lt;/P&gt;&lt;P&gt;234&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 07:24:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-code/m-p/802125#M315753</guid>
      <dc:creator>Aayushi_17</dc:creator>
      <dc:date>2022-03-15T07:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compare code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-code/m-p/802127#M315755</link>
      <description>&lt;P&gt;If you just need to detect missing keys:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=a;
by subject;
run;

proc sort data=b;
by subject;
run;

data
  both
  only_a
  only_b
;
merge
  a (in=in_a)
  b (in=in_b)
;
by subject;
if in_a and in_b
then output both;
else if in_a
then output only_a;
else output only_b;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you need more than that, look at &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1nwxbchh5hpu1n1h28kmici2awd.htm" target="_blank" rel="noopener"&gt;PROC COMPARE&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 07:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-code/m-p/802127#M315755</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-15T07:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Compare code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Compare-code/m-p/802231#M315806</link>
      <description>&lt;P&gt;Why are you specifically stating the Proc Freq must be used? Proc freq takes a single data set as input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Compare is designed to compare data sets and can use BY processing to compare records based on values of common variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your requirement of "output the difference by using subject variable" is not particularly clear as to the expected result.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 14:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Compare-code/m-p/802231#M315806</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-15T14:51:47Z</dc:date>
    </item>
  </channel>
</rss>

