<?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 Remove the duplicate in data based on time in date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-the-duplicate-in-data-based-on-time-in-date/m-p/646545#M193445</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset in below format. I need to remove the duplicates by ID var1 and dt. The date variable is in varchar datatype.&lt;/P&gt;&lt;P&gt;The date has a problem with same date but different timing. I have to remove the minimum timings on same date. In the below sample&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID 123 has two height value on the same date but I need only one value and that should be the max time. In the same scenario ID 321 has in wt category.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
input ID var1$ val dt$21.;
cards;
123 ht 145 2019-09-14 09:06:00.0
123 wt 78 2019-08-12 06:43:42.0
123 bp 24.8 2019-09-30 14:33:47.0
123 ht 146 2019-09-14 13:38:45.0
321 ht 173 2019-12-06 11:20:53.0
321 wt 85 2019-08-16 09:54:39.0
321 ht 173 2019-09-17 13:15:22.0
321 wt 86 2019-08-16 10:50:03.0
;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Sun, 10 May 2020 18:25:49 GMT</pubDate>
    <dc:creator>Sathish_jammy</dc:creator>
    <dc:date>2020-05-10T18:25:49Z</dc:date>
    <item>
      <title>Remove the duplicate in data based on time in date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-the-duplicate-in-data-based-on-time-in-date/m-p/646545#M193445</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset in below format. I need to remove the duplicates by ID var1 and dt. The date variable is in varchar datatype.&lt;/P&gt;&lt;P&gt;The date has a problem with same date but different timing. I have to remove the minimum timings on same date. In the below sample&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID 123 has two height value on the same date but I need only one value and that should be the max time. In the same scenario ID 321 has in wt category.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
input ID var1$ val dt$21.;
cards;
123 ht 145 2019-09-14 09:06:00.0
123 wt 78 2019-08-12 06:43:42.0
123 bp 24.8 2019-09-30 14:33:47.0
123 ht 146 2019-09-14 13:38:45.0
321 ht 173 2019-12-06 11:20:53.0
321 wt 85 2019-08-16 09:54:39.0
321 ht 173 2019-09-17 13:15:22.0
321 wt 86 2019-08-16 10:50:03.0
;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 18:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-the-duplicate-in-data-based-on-time-in-date/m-p/646545#M193445</guid>
      <dc:creator>Sathish_jammy</dc:creator>
      <dc:date>2020-05-10T18:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Remove the duplicate in data based on time in date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-the-duplicate-in-data-based-on-time-in-date/m-p/646547#M193447</link>
      <description>&lt;P&gt;1. Convert date to a date time that can be sorted properly&lt;/P&gt;
&lt;P&gt;2. Pick first record by each date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*convert to date/datetime;
data temp;
set have;
myDateTime = input(dt, anydtdtm.);
myDate = datepart(myDateTime);
myTime = timepart(myDateTime);

format myDatetime datetime. myDate date9. myTime time.;
run;

*sort data;
proc sort data=temp; 
by ID var1 myDate descending myTime;
run;

*keep only record of interest;
data want;
set temp;
by ID var1 myDate descending myTime;
if first.myDate;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215282"&gt;@Sathish_jammy&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset in below format. I need to remove the duplicates by ID var1 and dt. The date variable is in varchar datatype.&lt;/P&gt;
&lt;P&gt;The date has a problem with same date but different timing. I have to remove the minimum timings on same date. In the below sample&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID 123 has two height value on the same date but I need only one value and that should be the max time. In the same scenario ID 321 has in wt category.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input ID var1$ val dt$21.;
cards;
123 ht 145 2019-09-14 09:06:00.0
123 wt 78 2019-08-12 06:43:42.0
123 bp 24.8 2019-09-30 14:33:47.0
123 ht 146 2019-09-14 13:38:45.0
321 ht 173 2019-12-06 11:20:53.0
321 wt 85 2019-08-16 09:54:39.0
321 ht 173 2019-09-17 13:15:22.0
321 wt 86 2019-08-16 10:50:03.0
;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Thanks in advance!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 May 2020 18:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-the-duplicate-in-data-based-on-time-in-date/m-p/646547#M193447</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-05-10T18:34:19Z</dc:date>
    </item>
  </channel>
</rss>

