<?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: Delete occurrences by keeping the most recent date in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Delete-occurrences-by-keeping-the-most-recent-date/m-p/350240#M63817</link>
    <description>&lt;P&gt;SAS can handle this easily enough, but the solution in part depends on whether your BEGIN and END variables are valid SAS dates vs. whether they are character strings. &amp;nbsp;PROC CONTENTS will tell you that. &amp;nbsp;If they are valid SAS dates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by id begin;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id begin;&lt;/P&gt;
&lt;P&gt;if last.id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your dates are actually character strings, does "JANV" actually appear in your data, or is that supposed to be "JAN"? &amp;nbsp;If there are invalid dates (which would include "JANV") they would need to be fixed first. &amp;nbsp;Then ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;begin_sasdate = input(begin, date9.);&lt;/P&gt;
&lt;P&gt;end_sasdate = input(end, date9.);&lt;/P&gt;
&lt;P&gt;format begin_sasdate end_sasdate date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=want;&lt;/P&gt;
&lt;P&gt;by id begin_sasdate;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set want;&lt;/P&gt;
&lt;P&gt;by id begin_sasdate;&lt;/P&gt;
&lt;P&gt;if last.id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's the same approach, but this approach requires that your data contain SAS dates, not character strings.&lt;/P&gt;</description>
    <pubDate>Sat, 15 Apr 2017 10:09:57 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-04-15T10:09:57Z</dc:date>
    <item>
      <title>Delete occurrences by keeping the most recent date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Delete-occurrences-by-keeping-the-most-recent-date/m-p/350239#M63816</link>
      <description>&lt;P&gt;I have a data set like this :&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;/P&gt;&lt;P&gt;345&amp;nbsp;&amp;nbsp; CARL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16MAR2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31MAR2017&lt;/P&gt;&lt;P&gt;345&amp;nbsp;&amp;nbsp; CARL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03APR2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30APR2017&lt;/P&gt;&lt;P&gt;120&amp;nbsp;&amp;nbsp; ROSA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01JAN2017&amp;nbsp;&amp;nbsp;&amp;nbsp; 14FEB2017&lt;/P&gt;&lt;P&gt;120&amp;nbsp;&amp;nbsp; ROSA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02DEC2016&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 31DEC2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I delete occurence but taking the most recent date ? I mean get some thing like this :&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;/P&gt;&lt;P&gt;345&amp;nbsp;&amp;nbsp; CARL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03APR2017&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30APR2017&lt;/P&gt;&lt;P&gt;120&amp;nbsp;&amp;nbsp; ROSA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01JAN2017&amp;nbsp;&amp;nbsp;&amp;nbsp; 14FEB2017&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Apr 2017 10:31:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Delete-occurrences-by-keeping-the-most-recent-date/m-p/350239#M63816</guid>
      <dc:creator>John4</dc:creator>
      <dc:date>2017-04-15T10:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Delete occurrences by keeping the most recent date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Delete-occurrences-by-keeping-the-most-recent-date/m-p/350240#M63817</link>
      <description>&lt;P&gt;SAS can handle this easily enough, but the solution in part depends on whether your BEGIN and END variables are valid SAS dates vs. whether they are character strings. &amp;nbsp;PROC CONTENTS will tell you that. &amp;nbsp;If they are valid SAS dates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by id begin;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id begin;&lt;/P&gt;
&lt;P&gt;if last.id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your dates are actually character strings, does "JANV" actually appear in your data, or is that supposed to be "JAN"? &amp;nbsp;If there are invalid dates (which would include "JANV") they would need to be fixed first. &amp;nbsp;Then ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;begin_sasdate = input(begin, date9.);&lt;/P&gt;
&lt;P&gt;end_sasdate = input(end, date9.);&lt;/P&gt;
&lt;P&gt;format begin_sasdate end_sasdate date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=want;&lt;/P&gt;
&lt;P&gt;by id begin_sasdate;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set want;&lt;/P&gt;
&lt;P&gt;by id begin_sasdate;&lt;/P&gt;
&lt;P&gt;if last.id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's the same approach, but this approach requires that your data contain SAS dates, not character strings.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Apr 2017 10:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Delete-occurrences-by-keeping-the-most-recent-date/m-p/350240#M63817</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-15T10:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Delete occurrences by keeping the most recent date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Delete-occurrences-by-keeping-the-most-recent-date/m-p/350242#M63818</link>
      <description>&lt;P&gt;yes its valid date (I edit the topic, its JAN instead of JANV)&lt;/P&gt;</description>
      <pubDate>Sat, 15 Apr 2017 10:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Delete-occurrences-by-keeping-the-most-recent-date/m-p/350242#M63818</guid>
      <dc:creator>John4</dc:creator>
      <dc:date>2017-04-15T10:27:05Z</dc:date>
    </item>
  </channel>
</rss>

