<?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: Remove duplicated records based on the comparison of two dates in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964073#M43255</link>
    <description>^^edited</description>
    <pubDate>Thu, 10 Apr 2025 21:07:42 GMT</pubDate>
    <dc:creator>quickbluefish</dc:creator>
    <dc:date>2025-04-10T21:07:42Z</dc:date>
    <item>
      <title>Remove duplicated records based on the comparison of two dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964033#M43251</link>
      <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID :$20. Admission :date09. Discharge :date09.; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 13JAN2015
0001 13JAN2015 31MAR2015
0001 01MAR2018 30SEP2018
0001 01JAN2019 31DEC2019
0002 01JAN2015 31DEC2015
0002 01JAN2019 01JAN2019
0002 01JAN2019 15APR2019
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is there a way to get the following?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB1;
  input ID :$20. Admission :date09. Discharge :date09.; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 31MAR2015
0001 01MAR2018 30SEP2018
0001 01JAN2019 31DEC2019
0002 01JAN2015 31DEC2015
0002 01JAN2019 15APR2019
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In other words for equal admission dates I would like to remove the rows where admission == discharge and retain all the cases where admission =! discharge. The first case occurs because there is an emergency department access while the second is a real admission.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help me please?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2025 15:22:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964033#M43251</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2025-04-10T15:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicated records based on the comparison of two dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964046#M43252</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB1;
set DB;
WHERE discharge&amp;gt;admission;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could also use:&lt;/P&gt;
&lt;P&gt;discharge^=admission&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2025 16:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964046#M43252</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-04-10T16:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicated records based on the comparison of two dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964064#M43253</link>
      <description>&lt;P&gt;Thank you for your help. Unfortunately there are also cases where admission=discharge and no other admissions occur for that patient. The way you suggest would remove that cases.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2025 19:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964064#M43253</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2025-04-10T19:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicated records based on the comparison of two dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964070#M43254</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=DB; by ID admission; run;

data DB1;
set DB;
by ID;
if (first.ID=1 and last.ID=1) or discharge&amp;gt;admission;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will keep records in EITHER of these two cases:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;- 1. person has only one record&lt;/P&gt;
&lt;P&gt;&amp;nbsp;- 2. discharge is greater than admission&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2025 21:07:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964070#M43254</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-04-10T21:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicated records based on the comparison of two dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964073#M43255</link>
      <description>^^edited</description>
      <pubDate>Thu, 10 Apr 2025 21:07:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964073#M43255</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-04-10T21:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicated records based on the comparison of two dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964088#M43256</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID :$20. Admission :date09. Discharge :date09.; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 13JAN2015
0001 13JAN2015 31MAR2015
0001 01MAR2018 30SEP2018
0001 01JAN2019 31DEC2019
0002 01JAN2015 31DEC2015
0002 01JAN2019 01JAN2019
0002 01JAN2019 15APR2019
;


data temp;
 set DB;
 do date= Admission to Discharge ;
   output;
 end;
keep ID date;
format date date9.;
run;
proc sort data=temp nodupkey;by id date;run;
data temp2;
 set temp;
 by id;
 if first.id or dif(date) ne 1 then group+1;
run;
proc summary data=temp2;
by group id;
var date;
output out=want(drop=_:) min=Admission max=Discharge;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Apr 2025 01:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-duplicated-records-based-on-the-comparison-of-two-dates/m-p/964088#M43256</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-04-11T01:29:27Z</dc:date>
    </item>
  </channel>
</rss>

