<?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 Basic Proc compare help! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Basic-Proc-compare-help/m-p/455628#M115291</link>
    <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two data sets with an identifier variable. I would like to know which ID variables are not in the base set: So my data is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA cars1;
 INPUT make $ group ID;
CARDS;
AMC   1 123
AMC     1 123
AMC    1 123
Buick   1 456
Buick   1 456

;
RUN;  

DATA cars2;
 INPUT make $   group ID;
CARDS;
AMC   1 123
AMC     1 123
AMC    1 123
Buick   1 456
Buick   1 456
Toyota   2 789
Honda   1 780
;
RUN; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would like to have proc compare tell me that ID 780 and 789 are not in Cars 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally,&amp;nbsp;would I be able to use a where statement to restrict the comparison to only group 1?&amp;nbsp;For example, I want to know which ID is not in the cars2 dataset restricted on only data that is part of group 1. The result would be 780.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Apr 2018 14:51:40 GMT</pubDate>
    <dc:creator>hwangnyc</dc:creator>
    <dc:date>2018-04-19T14:51:40Z</dc:date>
    <item>
      <title>Basic Proc compare help!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Proc-compare-help/m-p/455628#M115291</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two data sets with an identifier variable. I would like to know which ID variables are not in the base set: So my data is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA cars1;
 INPUT make $ group ID;
CARDS;
AMC   1 123
AMC     1 123
AMC    1 123
Buick   1 456
Buick   1 456

;
RUN;  

DATA cars2;
 INPUT make $   group ID;
CARDS;
AMC   1 123
AMC     1 123
AMC    1 123
Buick   1 456
Buick   1 456
Toyota   2 789
Honda   1 780
;
RUN; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would like to have proc compare tell me that ID 780 and 789 are not in Cars 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally,&amp;nbsp;would I be able to use a where statement to restrict the comparison to only group 1?&amp;nbsp;For example, I want to know which ID is not in the cars2 dataset restricted on only data that is part of group 1. The result would be 780.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 14:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Proc-compare-help/m-p/455628#M115291</guid>
      <dc:creator>hwangnyc</dc:creator>
      <dc:date>2018-04-19T14:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Proc compare help!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Proc-compare-help/m-p/455634#M115294</link>
      <description>&lt;P&gt;PROC COMPARE is very efficient to check are two tables identical and if negative&lt;/P&gt;
&lt;P&gt;which variables in which observations are not equal, displaying theeir values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To do what you want is very easy by sql:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sq;
    create table diff as  /* &amp;lt;&amp;lt;&amp;lt; optional &amp;gt;&amp;gt;&amp;gt; */
    select distinct ID from table_2 
    where ID not in (select distinct ID from table_1);
quit;
   &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Apr 2018 14:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Proc-compare-help/m-p/455634#M115294</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-04-19T14:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Basic Proc compare help!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-Proc-compare-help/m-p/455658#M115308</link>
      <description>&lt;P&gt;use following code instead of PROC COMPARE.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sort data=CARS1; by ID; Run;
Proc sort data=CARS2; by ID; Run;

data Difference;
merge CARS1(in=A) CARS2(in=B);
by ID MAKE Group;
length inds $ 40;
if A and not B then do;
inds='CARS1';
output;
end;
if not A and B then do;
inds='CARS2';
output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Apr 2018 16:18:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-Proc-compare-help/m-p/455658#M115308</guid>
      <dc:creator>emrancaan</dc:creator>
      <dc:date>2018-04-19T16:18:48Z</dc:date>
    </item>
  </channel>
</rss>

