<?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: Deleted and take the difference in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474522#M30779</link>
    <description>sorry yeah i meant count of the cust_id</description>
    <pubDate>Fri, 29 Jun 2018 17:39:21 GMT</pubDate>
    <dc:creator>hk2013</dc:creator>
    <dc:date>2018-06-29T17:39:21Z</dc:date>
    <item>
      <title>Deleted and take the difference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474499#M30772</link>
      <description>&lt;P&gt;I have two data sets with IDs and Cust_id data_1 is my main data set its a snapshot of our customer list at the start of the year and i want to compare to data_2 which is updated monthly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data_2 might have new cust_id added over the time but I dont want to look at those.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data_1 : data at start of year&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; Cust_id&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 111&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 222&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 333&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;444&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 555&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 666&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 777&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 888&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;999&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1000&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1001&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1002&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data_2&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; Cust_id&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 111&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 222&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1110&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5786&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 555&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8989&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;0986&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;999&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Compare Data_1 to Data_2 and only keep cust_ids in data_2 that are also in Data_1 and than get the diff&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New_Data_2&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; Cust_id&amp;nbsp; difference&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 111&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 222&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 555&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;999&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;difference = count(data_1.Cust_id) -count(data_2.Cust_id)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 17:50:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474499#M30772</guid>
      <dc:creator>hk2013</dc:creator>
      <dc:date>2018-06-29T17:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Deleted and take the difference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474505#M30773</link>
      <description>&lt;P&gt;Are you sure you want sum() and not count()? Because I can't see where you'd get just 2 from those numbers.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 17:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474505#M30773</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-29T17:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Deleted and take the difference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474522#M30779</link>
      <description>sorry yeah i meant count of the cust_id</description>
      <pubDate>Fri, 29 Jun 2018 17:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474522#M30779</guid>
      <dc:creator>hk2013</dc:creator>
      <dc:date>2018-06-29T17:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Deleted and take the difference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474545#M30780</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input ID      Cust_id;
cards;
1          111
1          222
1          333
1         444
2          555
2          666
2          777
2          888
3         999
3        1000
3        1001
3        1002
;
data two;
input ID      Cust_id;
cards;
1          111
1          222
1          1110
1         5786
2          555
2          8989
2          0986
3         999
;
proc sql;
create table want as
select a.*,b.count-count(a.cust_id) as difference
from two a, (select *,count(cust_id) as count from one group by id) b
where a.cust_id=b.cust_id and a.id=b.id
group by a.id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jun 2018 18:23:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474545#M30780</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-29T18:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Deleted and take the difference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474557#M30781</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input ID      Cust_id;
cards;
1          111
1          222
1          333
1         444
2          555
2          666
2          777
2          888
3         999
3        1000
3        1001
3        1002
;
data two;
input ID      Cust_id;
cards;
1          111
1          222
1          1110
1         5786
2          555
2          8989
2          0986
3         999
;

data want;
if _n_=1 then do;
   dcl hash h(dataset:'two', multidata: 'y');
   h.definekey('id','cust_id');
    h.definedone();
end;
_c=0;
do _n=1 by 1 until(last.id);
set one;
by ID    Cust_id;
if h.check()=0 then  _c+1;
end;
do until(last.id);
set one;
by ID    Cust_id;
if h.check()=0 then do;count=_n-_c;output;end;
end;
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jun 2018 18:37:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474557#M30781</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-29T18:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: Deleted and take the difference</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474634#M30786</link>
      <description>&lt;P&gt;Can also be done this way with a left join:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select 
    one.*,
    sum(missing(two.cust_id)) as difference
from 
    one left join two on one.id=two.id and one.cust_id=two.cust_id
group by one.id
having not missing(two.cust_id);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 30 Jun 2018 04:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Deleted-and-take-the-difference/m-p/474634#M30786</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-06-30T04:54:50Z</dc:date>
    </item>
  </channel>
</rss>

