<?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 Removing duplicates by satisfying a frequency condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-duplicates-by-satisfying-a-frequency-condition/m-p/454349#M114835</link>
    <description>&lt;P&gt;I have a data set which is much larger than my example below. I want to be able to remove the 'Person' duplicates by the 'type' variable. In particular, if they have the same 'Type', then can keep either. However, if they have different values for 'Type', i want to keep the record with the higher frequency. In this case it would be one with Type=2 (as there is 2 of them compared to only one record where Type=1). How would I go about doing this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Person&lt;/TD&gt;&lt;TD&gt;Type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Mon, 16 Apr 2018 06:38:32 GMT</pubDate>
    <dc:creator>BenBrady</dc:creator>
    <dc:date>2018-04-16T06:38:32Z</dc:date>
    <item>
      <title>Removing duplicates by satisfying a frequency condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-duplicates-by-satisfying-a-frequency-condition/m-p/454349#M114835</link>
      <description>&lt;P&gt;I have a data set which is much larger than my example below. I want to be able to remove the 'Person' duplicates by the 'type' variable. In particular, if they have the same 'Type', then can keep either. However, if they have different values for 'Type', i want to keep the record with the higher frequency. In this case it would be one with Type=2 (as there is 2 of them compared to only one record where Type=1). How would I go about doing this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Person&lt;/TD&gt;&lt;TD&gt;Type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 16 Apr 2018 06:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-duplicates-by-satisfying-a-frequency-condition/m-p/454349#M114835</guid>
      <dc:creator>BenBrady</dc:creator>
      <dc:date>2018-04-16T06:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Removing duplicates by satisfying a frequency condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-duplicates-by-satisfying-a-frequency-condition/m-p/454357#M114837</link>
      <description>&lt;P&gt;like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Person$ Type;
datalines;
A 2
A 2
A 1
B 3
B 3
;

proc sort data=have;
    by descending Person descending Type;
run;

data want;
    set have;
    by descending Person descending Type;
    if first.Person;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Apr 2018 06:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-duplicates-by-satisfying-a-frequency-condition/m-p/454357#M114837</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-04-16T06:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: Removing duplicates by satisfying a frequency condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-duplicates-by-satisfying-a-frequency-condition/m-p/454368#M114841</link>
      <description>&lt;P&gt;Here is one way to do it, using SQL:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table want as select * from
   (select * from
     (select *,count(*) as n from have
      group  by person,type
     )
   group by person
   having n=max(n)
   )
  group by person
  having type=min(type);

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Apr 2018 08:02:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-duplicates-by-satisfying-a-frequency-condition/m-p/454368#M114841</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-04-16T08:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Removing duplicates by satisfying a frequency condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-duplicates-by-satisfying-a-frequency-condition/m-p/454386#M114846</link>
      <description>&lt;P&gt;Try this.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want1 as
select *, count(*) as n from have group by person, type order by person, calculated n desc;
run;

data want;
set want1;
by person descending n;
if first.person;
drop n;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Apr 2018 10:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-duplicates-by-satisfying-a-frequency-condition/m-p/454386#M114846</guid>
      <dc:creator>shantanupl1</dc:creator>
      <dc:date>2018-04-16T10:08:59Z</dc:date>
    </item>
  </channel>
</rss>

