<?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: Keeping Partial Duplicates but Ignoring Missings in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592414#M169849</link>
    <description>&lt;P&gt;Yes, it can be done in SAS.&amp;nbsp; But first,&amp;nbsp;what if you have these two observations?&amp;nbsp; Their non-missing values match exactly, and each has one missing value.&amp;nbsp; Do you keep both, neither, one of them?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="height: 60px;" border="0" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;ID&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;VAR1_&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;VAR2_&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;VAR3_&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;VAR4_&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;date&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;3&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;.&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;1&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;3&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;4&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;9&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;15&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;3&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;2&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;1&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;.&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;4&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;9&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;15&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
    <pubDate>Sat, 28 Sep 2019 18:10:34 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2019-09-28T18:10:34Z</dc:date>
    <item>
      <title>Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592411#M169846</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a list of partial duplicates - observations that have the same values for ID, date, and time, but different values in all other variables. The only condition is that I want to ignore differences due to missing values. For example, let's say I have the dataset:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE cellspacing="0" cellpadding="0" border="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;VAR1_&lt;/TD&gt;&lt;TD&gt;VAR2_&lt;/TD&gt;&lt;TD&gt;VAR3_&lt;/TD&gt;&lt;TD&gt;VAR4_&lt;/TD&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;time&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Edit&lt;/STRONG&gt;&lt;/U&gt;: I just realized I framed this wrong. I'd ultimately want to keep only one of row 5 or 7 as they are partial duplicates to the other observations of ID=2, date=10, and time=20. However, I'd want to remove both rows with ID=3 as when one is absorbed by the other, it no longer has partial duplicates. Sorry for the confusion! &lt;img id="smileyembarrassed" class="emoticon emoticon-smileyembarrassed" src="https://communities.sas.com/i/smilies/16x16_smiley-embarrassed.png" alt="Smiley Embarassed" title="Smiley Embarassed" /&gt; :&lt;/P&gt;&lt;TABLE cellspacing="0" cellpadding="0" border="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;VAR1_&lt;/TD&gt;&lt;TD&gt;VAR2_&lt;/TD&gt;&lt;TD&gt;VAR3_&lt;/TD&gt;&lt;TD&gt;VAR4_&lt;/TD&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;time&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible in SAS? Is this not practical to code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below I have the SAS code to make the data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
input ID VAR1 VAR2 VAR3 VAR4 date time;
datalines;
1 1 1 1 2 9 15
1 2 . . 2 9 15
1 2 2 2 1 9 15
2 1 1 2 2 10 20
2 1 . 2 3 10 20
2 3 2 2 . 10 20
2 1 1 2 3 10 20
3 . 1 3 4 9 15
3 2 1 . 4 9 15
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 22:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592411#M169846</guid>
      <dc:creator>cardinull</dc:creator>
      <dc:date>2019-09-28T22:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592413#M169848</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292778"&gt;@cardinull&lt;/a&gt;&amp;nbsp; &amp;nbsp;I went with some guesses and trying to shame myself by attempting to be creative lol&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data dt;
input ID VAR1 VAR2 VAR3 VAR4 date time;
datalines;
1 1 1 1 2 9 15
1 2 . . 2 9 15
1 2 2 2 1 9 15
2 1 1 2 2 10 20
2 1 . 2 3 10 20
2 3 2 2 . 10 20
2 1 1 2 3 10 20
;
run;

data temp;
 update dt(obs=0) dt;
 by id;
 rownum+1;
 output;
run;

proc sql;
create table want as
select b.*
from
(select *
from temp
group by ID, VAR1, VAR2, VAR3, VAR4, date, time
having count(*)=1) a
left join 
(select *,monotonic() as rownum from dt) b
on a.rownum=b.rownum
order by b.rownum;
quit;&lt;/CODE&gt;&lt;/PRE&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;</description>
      <pubDate>Sat, 28 Sep 2019 18:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592413#M169848</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-28T18:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592414#M169849</link>
      <description>&lt;P&gt;Yes, it can be done in SAS.&amp;nbsp; But first,&amp;nbsp;what if you have these two observations?&amp;nbsp; Their non-missing values match exactly, and each has one missing value.&amp;nbsp; Do you keep both, neither, one of them?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="height: 60px;" border="0" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;ID&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;VAR1_&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;VAR2_&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;VAR3_&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;VAR4_&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;date&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;3&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;.&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;1&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;3&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;4&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;9&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;15&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 20px;"&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;3&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;2&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;1&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;.&lt;/TD&gt;
&lt;TD style="width: 44.37px; height: 20px;"&gt;4&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;9&lt;/TD&gt;
&lt;TD style="width: 40px; height: 20px;"&gt;15&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Sat, 28 Sep 2019 18:10:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592414#M169849</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-09-28T18:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592415#M169850</link>
      <description>&lt;P&gt;Thanks for a reply! I would keep neither.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 18:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592415#M169850</guid>
      <dc:creator>cardinull</dc:creator>
      <dc:date>2019-09-28T18:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592416#M169851</link>
      <description>&lt;P&gt;Lol! No shame! Being creative is the funnest part of figuring out SAS &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Although with my clarification of mkeintz's quesiton, idk if this would change anything lol!&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 18:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592416#M169851</guid>
      <dc:creator>cardinull</dc:creator>
      <dc:date>2019-09-28T18:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592419#M169854</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292778"&gt;@cardinull&lt;/a&gt;&amp;nbsp; Saturday lazy me will yet again go for another silly creative(just to show off) one using LOCF guesses. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Bear with me turning on some humor.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data dt;
input ID VAR1 VAR2 VAR3 VAR4 date time;
datalines;
1 1 1 1 2 9 15
1 2 . . 2 9 15
1 2 2 2 1 9 15
2 1 1 2 2 10 20
2 1 . 2 3 10 20
2 3 2 2 . 10 20
2 1 1 2 3 10 20
3	.	1	3	4	9	15
3	2	1	.	4	9	15
;
run;


data temp;
set dt;
array t var1--time;
call sortn(of t(*));
run;

data temp1;
 update temp(obs=0) temp;
 by id;
 rownum+1;
 if cmiss(of _all_)=0 then output;
run;

proc sql;
create table want as
select b.*
from
(select *
from temp1
group by ID, VAR1, VAR2, VAR3, VAR4, date, time
having count(*)=1) a
left join 
(select *,monotonic() as rownum from dt) b
on a.rownum=b.rownum
order by b.rownum;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I do have a linear clean approach in my mind, but I am sure that the giant seniors are most likely to offer a perfect solution&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;</description>
      <pubDate>Sat, 28 Sep 2019 19:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592419#M169854</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-28T19:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592421#M169855</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think you suggestion works for much more than the data presented.&amp;nbsp;&amp;nbsp; Current, in the data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1 1 1 1 2 9 15
1 2 . . 2 9 15
1 2 2 2 1 9 15
2 1 1 2 2 10 20
2 1 . 2 3 10 20
2 3 2 2 . 10 20
2 1 1 2 3 10 20
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;your program keeps all three records with ID=1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But add a 4th original record, as in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
input ID VAR1 VAR2 VAR3 VAR4 date time;
datalines;
1 1 1 1 2 9 15
1 2 . . 2 9 15
1 2 2 2 1 9 15
1 2 2 2 . 9 15     This is the extra record
2 1 1 2 2 10 20
2 1 . 2 3 10 20
2 3 2 2 . 10 20
2 1 1 2 3 10 20
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the additional record (#4) should be considered absorbed by the 3rd record, so WANT should be unchanged.&amp;nbsp;&amp;nbsp; But the result is that it actually REDUCES the number of ID=1 records, i.e. neither record 4 nor its "container" record 3 is kept.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;regards,&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 20:32:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592421#M169855</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-09-28T20:32:13Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592431#M169863</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Woops! Mark is right. I just updated my post/questions to account for that.... Sorry for the confusion... Long day &lt;img id="smileyembarrassed" class="emoticon emoticon-smileyembarrassed" src="https://communities.sas.com/i/smilies/16x16_smiley-embarrassed.png" alt="Smiley Embarassed" title="Smiley Embarassed" /&gt;&lt;/P&gt;&lt;P&gt;To add to Mark's case, I would want to keep one record if it still is a partial duplicate to other existing records. However, if only the two records exist for that combination of ID, date, and time, then I wouldn't keep those&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the case of the example by Mark, if we have data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
input ID VAR1 VAR2 VAR3 VAR4 date time;
datalines;
1 1 1 1 2 9 15
1 2 . . 2 9 15
1 2 2 2 1 9 15
1 2 2 2 . 9 15     This is the extra record by Mark
2 1 1 2 2 10 20
2 1 . 2 3 10 20
2 3 2 2 . 10 20
2 1 1 2 3 10 20
3 . 1 3 4 9 15
3 2 1 . 4 9 15
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Then I would want a result of this where one of row 3 or 4 is kept, one of row 5 or 7 is kept, and neither of rows 9 and 10 are kept:&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
input ID VAR1 VAR2 VAR3 VAR4 date time;
datalines;
1 1 1 1 2 9 15
1 2 . . 2 9 15
1 2 2 2 1 9 15
2 1 1 2 2 10 20
2 3 2 2 . 10 20
2 1 1 2 3 10 20
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for that &lt;img id="smileyembarrassed" class="emoticon emoticon-smileyembarrassed" src="https://communities.sas.com/i/smilies/16x16_smiley-embarrassed.png" alt="Smiley Embarassed" title="Smiley Embarassed" /&gt;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jameson&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 22:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592431#M169863</guid>
      <dc:creator>cardinull</dc:creator>
      <dc:date>2019-09-28T22:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592432#M169864</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp; Hmm Got it. I sit corrected. Also where have you been in a while? I was looking to PM you anyway to say hello?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292778"&gt;@cardinull&lt;/a&gt;&amp;nbsp; &amp;nbsp;Enough of fun earlier, this is more a sincere effort though I wish to test more effectively(&lt;STRONG&gt;&lt;EM&gt;feeling very lazy&lt;/EM&gt;&lt;/STRONG&gt;) but should get very close. I would appreciate you test and let us know where it is missing. If Mark is fresher this evening, He would of course charm you. But until then, you have something to play with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data dt;
input ID VAR1 VAR2 VAR3 VAR4 date time;
datalines;
1 1 1 1 2 9 15
1 2 . . 2 9 15
1 2 2 2 1 9 15
2 1 1 2 2 10 20
2 1 . 2 3 10 20
2 3 2 2 . 10 20
2 1 1 2 3 10 20
3	.	1	3	4	9	15
3	2	1	.	4	9	15
;
run;

data want;
if _n_=1 then do;
  dcl hash H () ;
  h.definekey  ("_cn") ;
  h.definedata ("_cn") ;
  h.definedone () ;
  dcl hiter hi('h');
end;
 do until(last.id);
  set dt;
  by id date time notsorted;
  array t var1-var4;
  _cn=cats(of t(*));
  _rc=h.add();
 end;
 do until(last.id);
  set dt end=z;
   by id date time notsorted;
   array temp(999999)$20 _temporary_;
   __cn=cats(of t(*));
   call missing(_cn);
   if __cn in temp then continue;
   do while(hi.next()=0);
   _c=.;
   if __cn ne _cn then do;
    do _n_=1 to length(__cn);
	 if char(_cn,_n_) ne '.' and  char(__cn,_n_) ne '.' then
	 if char(_cn,_n_) ne  char(__cn,_n_) then _c+1;
	end;
	if _c=. then do;n+1;temp(n)=_cn;temp(n+1)=__cn;end;
   end;
  end;
  if __cn not in temp then output;
  end;
 h.clear();
 call missing(of temp(*),n);
 drop _: n;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 22:03:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592432#M169864</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-28T22:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592434#M169866</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks a bunch. I'll try and play with this and keep you both updated :)!</description>
      <pubDate>Sat, 28 Sep 2019 22:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592434#M169866</guid>
      <dc:creator>cardinull</dc:creator>
      <dc:date>2019-09-28T22:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592436#M169867</link>
      <description>&lt;P&gt;Yes sorry, didn't even shower/lunch today, all day bed and music/laptop. lol VERY Very Lazy day. I hate it.My apologies for not being sincere earlier.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just removed the 2nd do until(last.id) to make it faster.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
input ID VAR1 VAR2 VAR3 VAR4 date time;
datalines;
1 1 1 1 2 9 15
1 2 . . 2 9 15
1 2 2 2 1 9 15
2 1 1 2 2 10 20
2 1 . 2 3 10 20
2 3 2 2 . 10 20
2 1 1 2 3 10 20
3	.	1	3	4	9	15
3	2	1	.	4	9	15
;
run;

data want;
if _n_=1 then do;
  dcl hash H () ;
  h.definekey  ("_cn") ;
  h.definedata ("_cn") ;
  h.definedone () ;
  dcl hiter hi('h');
end;
 do _iorc_=1 by 1 until(last.id);
  set dt;
  by id date time notsorted;
  array t var1-var4;
  _cn=cats(of t(*));
  _rc=h.add();
 end;
 do _iorc_=1 to _iorc_;
  set dt ;
   array temp(999999)$20 _temporary_;
   __cn=cats(of t(*));
   call missing(_cn);
   if __cn in temp then continue;
   do while(hi.next()=0);
   _c=.;
   if __cn ne _cn then do;
    do _n_=1 to length(__cn);
	 if char(_cn,_n_) ne '.' and  char(__cn,_n_) ne '.' then
	 if char(_cn,_n_) ne  char(__cn,_n_) then _c+1;
	end;
	if _c=. then do;n+1;temp(n)=_cn;temp(n+1)=__cn;end;
   end;
  end;
  if __cn not in temp then output;
  end;
 h.clear();
 call missing(of temp(*),n);
 drop _: n;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;EDIT:&lt;/P&gt;
&lt;P&gt;Oh well, shouldn't the BY GROUP be &lt;STRONG&gt;ID DATE TIME&lt;/STRONG&gt; with time being lowest(child group)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case you would change the BY id;&lt;/P&gt;
&lt;P&gt;to &lt;STRONG&gt;&lt;EM&gt;BY ID DATE TIME;&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;and so DO UNTIL(LAST.TIME);&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;I am a NUT.&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Sep 2019 22:13:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592436#M169867</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-28T22:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592452#M169875</link>
      <description>&lt;P&gt;You apparently want to exclude all records that can be construed as a "child" of another record.&amp;nbsp;&amp;nbsp; And by "child" I mean a record such that&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;all its non-missing values match the "parent"&amp;nbsp;record&lt;/LI&gt;
&lt;LI&gt;has at least one missing value for which the parent has a non-missing value.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case, if you have&amp;nbsp;a table of child records, you could then keep all of the original records EXCEPT for those child records.&amp;nbsp; So the real task is to take each original record, and generate all its child records.&amp;nbsp; Then do a proc SQL&amp;nbsp;(using the EXCEPT operator) or a data step with merge.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the SQL solution:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
  retain ID DATE TIME;
  input ID var1 var2 var3 var4 date time;
datalines;
1 1 1 1 2  9 15
1 2 . . 2  9 15
1 2 2 2 1  9 15
1 2 2 2 .  9 15   Extra record
2 1 1 2 2 10 20
2 1 . 2 3 10 20
2 3 2 2 . 10 20
2 1 1 2 3 10 20
run;


data child (drop=_: v i);
  set dt;
  length _strng $8; 
  _strng=catx('!',of var:);
  array var{4} var1-var4;
  array _v{4};
  do v=1 to 4; 
    _v{v}=var{v};
  end;

  do i=1 to 2**4 -1;
    call missing(of var:);
    if mod(i,2)&amp;gt;=1  then var{1}=_v{1};
	if mod(i,4)&amp;gt;=2  then var{2}=_v{2};
	if mod(i,8)&amp;gt;=4  then var{3}=_v{3};
	if mod(i,16)&amp;gt;=8 then var{4}=_v{4};
	if catx('!',of var:)^=_strng then output;
  end;
run;

proc sort data=child nodupkey;
  by id date time var: ;
run;

proc sql;
  create table want as
  select * from dt
  except select * from child;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now when the data sets are large, I suspect the SQL solution can be expensive because each record in the original dataset has to be compare to possible ALL the records in the child dataset, which is much larger.&amp;nbsp; So the DATA step approach might be better, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dt;
  retain ID DATE TIME;
  input ID var1 var2 var3 var4 date time;
datalines;
1 1 1 1 2  9 15
1 2 . . 2  9 15
1 2 2 2 1  9 15
1 2 2 2 .  9 15   Extra record
2 1 1 2 2 10 20
2 1 . 2 3 10 20
2 3 2 2 . 10 20
2 1 1 2 3 10 20
run;

proc sort data=dt out=have; by id date time var: ; run;

data child (drop=_: v i);
  set dt;
  length _strng $8; 
  _strng=catx('!',of var:);
  array var{4} var1-var4;
  array _v{4};
  do v=1 to 4; 
    _v{v}=var{v};
  end;

  do i=1 to 2**4 -1;
    call missing(of var:);
    if mod(i,2)&amp;gt;=1  then var{1}=_v{1};
	if mod(i,4)&amp;gt;=2  then var{2}=_v{2};
	if mod(i,8)&amp;gt;=4  then var{3}=_v{3};
	if mod(i,16)&amp;gt;=8 then var{4}=_v{4};
	if catx('!',of var:)^=_strng then output;
  end;
run;

proc sort data=child nodupkey;
  by id date time var: ;
run;

data want2;
merge have  child (in=inchild);
  by id date time var: ;
  if inchild=0;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Sun, 29 Sep 2019 02:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592452#M169875</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-09-29T02:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592881#M170059</link>
      <description>Thanks so much Mark! I was able to get something to work by tweaking this a bit :)!</description>
      <pubDate>Tue, 01 Oct 2019 00:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/592881#M170059</guid>
      <dc:creator>cardinull</dc:creator>
      <dc:date>2019-10-01T00:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/593596#M170377</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Mark, I'd suggest that it can be done much simpler (not to mention in a single step and a single pass) by using a hash table as a dynamic medium. Basically, what the program below does is adding an item to the table if the current record isn't a dupe relative to the current state of the table. Of course, below, the input is assumed sorted by [id,date,time].&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;                                                                                                                             
  input id date time v1-v4 ;                                                                                                            
  list ;                                                                                                                                
  cards ;                                                                                                                               
1   9  15  1  1  1  2                                                                                                                   
1   9  15  2  .  .  2                                                                                                                   
1   9  15  2  2  2  1                                                                                                                   
1   9  15  2  2  2  .                                                                                                                   
2  10  20  1  1  2  2                                                                                                                   
2  10  20  1  .  2  3                                                                                                                   
2  10  20  3  2  2  .                                                                                                                   
2  10  20  1  1  2  3                                                                                                                   
3   9  15  .  1  3  4                                                                                                                   
3   9  15  2  1  .  4                                                                                                                   
;                                                                                                                                       
run ;                                                                                                                                   
                                                                                                                                        
data want (keep = id date time v:) ;                                                                                                    
  if _n_ = 1 then do ;                                                                                                                  
    dcl hash h (multidata:"y") ;                                                                                                        
    h.definekey ("_n_") ;                                                                                                               
    h.definedata ("v1", "v2", "v3", "v4") ;                                                                                             
    h.definedone () ;                                                                                                                   
    dcl hiter i ("h") ;                                                                                                                 
  end ;                                                                                                                                 
  do until (last.time) ;                                                                                                                
    set have ;                                                                                                                          
    by id date time ;                                                                                                                   
    array v v1-v4 ;                                                                                                                     
    array t t1-t4 ;                                                                                                                     
    do over v ;                                                                                                                         
      t = v ;                                                                                                                           
    end ;                                                                                                                               
    do while (i.next() = 0) ;                                                                                                           
      do over v ;                                                                                                                       
        if nmiss (v, t) then continue ;                                                                                                 
        if v ne t then leave ;                                                                                                          
      end ;                                                                                                                             
      if _i_ &amp;gt; dim (v) then _dup = 1 ;                                                                                                  
    end ;                                                                                                                               
    if _dup then continue ;                                                                                                             
    do over v ;                                                                                                                         
      v = t ;                                                                                                                           
    end ;                                                                                                                               
    h.add() ;                                                                                                                           
  end ;                                                                                                                                 
  if h.num_items &amp;gt; 1 then do while (i.next() = 0) ;                                                                                     
    output ;                                                                                                                            
  end ;                                                                                                                                 
  h.clear() ;                                                                                                                           
run ;                                               
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that proper unduplication (as would be done, say, by proc SORT) would keep the key groups with a single record in the output. The only reason the last IF is used above is the weird nature of the OP's request dictating that if the V-variables in a key group are "same" from the standpoint of the specs, the entire group should be removed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That becomes a problem for a more concise hash solution not relying on the sorted order at all:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;                                                                                                                           
  if _n_ = 1 then do ;                                                                                                                  
    dcl hash h (dataset:"have(obs=0)", multidata:"y", ordered:"y") ;                                                                    
    h.definekey ("id", "date", "time") ;                                                                                                
    h.definedata (all:"y") ;                                                                                                            
    h.definedone () ;                                                                                                                   
  end ;                                                                                                                                 
  if z then h.output (dataset:"want") ;                                                                                                 
  set have end = z ;                                                                                                                    
  array v v1-v4 ;                                                                                                                       
  array t t1-t4 ;                                                                                                                       
  do over v ;                                                                                                                           
    t = v ;                                                                                                                             
  end ;                                                                                                                                 
  do while (h.do_over() = 0) ;                                                                                                          
    do over v ;                                                                                                                         
      if nmiss (v, t) then continue ;                                                                                                   
      if v ne t then leave ;                                                                                                            
    end ;                                                                                                                               
    if _i_ &amp;gt; dim (v) then _dup = 1 ;                                                                                                    
  end ;                                                                                                                                 
  if _dup then delete ;                                                                                                                 
  do over v ;                                                                                                                           
    v = t ;                                                                                                                             
  end ;                                                                                                                                 
  h.add() ;                                                                                                                             
run ;            
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Evidently, the group with ID=3 is kept in the output, as "normal" unduplication would prescribe but contrary to the OP's specs. Of course, it can be handled in the step above; but it hardly worth complicating the code. Instead, it can be just post-processed either via SQL or another DATA step (since the hash output is sorted), e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;                                    
  set want (keep = id date time in = _1) want ;
  by id date time ;                            
  if first.time then _iorc_ = 1 ;              
  else if _1    then _iorc_ + 1 ;              
  else if _iorc_ &amp;gt; 1 then output ;             
run ;                                          
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 05:06:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/593596#M170377</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-03T05:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/593880#M170531</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very nice indeed ... but there's something I am not seeing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What if an early observation in a BY group&amp;nbsp; (say {var1,var2,var3,var4}={1,.,3,.} gets put into the hash object H, because it is not preceded by a "parent".&amp;nbsp; And then later a "parent"&amp;nbsp; (say {1,2,3,.} is encountered.&amp;nbsp; I see where the new parent gets added to the hash object, but I don't see where the now-erroneous inclusion of {1,.,3,.} is deleted from the object.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edited addition:&amp;nbsp; And I did think there would be&amp;nbsp;a single-step hash solution, but I didn't think enough to think up one.&amp;nbsp; I'm glad you did.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 19:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/593880#M170531</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-03T19:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping Partial Duplicates but Ignoring Missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/593993#M170590</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Mark, I may be overlooking something, but to my mind the logic is no different in principle from the following (not using FIND/C function deliberately):&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_ ;                                           
  array rec $1 r1-r8 ("1","2","1","3","4","3","5","2") ;
  length hash $ 8 ;                                     
  do over rec ;                                         
    dup = . ;                                           
    do i = 1 to length (hash) ;                         
      if char (hash, i) = rec then dup = 1 ;            
    end ;                                               
    if not dup then hash = cats (hash, rec) ;           
  end ;                                                 
  put hash= ;                                           
run ;                                                   
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which results in:&lt;/P&gt;
&lt;PRE&gt;hash=12345
&lt;/PRE&gt;
&lt;P&gt;The differences are that the real comparison condition is more complex than:&lt;/P&gt;
&lt;PRE&gt;char (hash, i) = rec&lt;/PRE&gt;
&lt;P&gt;and the hash table is used instead of the string HASH. So, basically, we're adding the hash items while eliminating the post-coming dupes in the process, so there's no need to delete anything from the hash when there're no more records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 00:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keeping-Partial-Duplicates-but-Ignoring-Missings/m-p/593993#M170590</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-04T00:30:41Z</dc:date>
    </item>
  </channel>
</rss>

