<?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: Only keep the records that have the later date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Only-keep-the-records-that-have-the-later-date/m-p/703765#M215688</link>
    <description>&lt;P&gt;You can try:&lt;/P&gt;&lt;P&gt;IF LAST.userid=1 THEN DO;&lt;BR /&gt;OUTPUT;&lt;/P&gt;</description>
    <pubDate>Sat, 05 Dec 2020 01:34:26 GMT</pubDate>
    <dc:creator>yeji6144</dc:creator>
    <dc:date>2020-12-05T01:34:26Z</dc:date>
    <item>
      <title>Only keep the records that have the later date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Only-keep-the-records-that-have-the-later-date/m-p/703753#M215681</link>
      <description>&lt;P&gt;Hi community!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a question regarding below example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; userid&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; factor&amp;nbsp;&lt;/P&gt;
&lt;P&gt;8/21/2020&amp;nbsp; &amp;nbsp; &amp;nbsp;736ksls&amp;nbsp; &amp;nbsp; &amp;nbsp; text&lt;/P&gt;
&lt;P&gt;11/20/2020&amp;nbsp; &amp;nbsp;736ksls&amp;nbsp; &amp;nbsp; &amp;nbsp; text&lt;/P&gt;
&lt;P&gt;02/07/2019&amp;nbsp; &amp;nbsp;blea282&amp;nbsp; &amp;nbsp; &amp;nbsp;text&lt;/P&gt;
&lt;P&gt;10/28/2020&amp;nbsp; &amp;nbsp;blea282&amp;nbsp; &amp;nbsp; &amp;nbsp;text&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Can anyone provide a solution to only keep the records ( when userid and factor are the same) with a later date? Thanks a lot from a beginner!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this example I only want to keep 2 records:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; userid&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; factor&amp;nbsp;&lt;/P&gt;
&lt;P&gt;11/20/2020&amp;nbsp; &amp;nbsp;736ksls&amp;nbsp; &amp;nbsp; &amp;nbsp; text&lt;/P&gt;
&lt;P&gt;10/28/2020&amp;nbsp; &amp;nbsp;blea282&amp;nbsp; &amp;nbsp; &amp;nbsp;text&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 00:11:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Only-keep-the-records-that-have-the-later-date/m-p/703753#M215681</guid>
      <dc:creator>yichentian226</dc:creator>
      <dc:date>2020-12-05T00:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Only keep the records that have the later date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Only-keep-the-records-that-have-the-later-date/m-p/703763#M215686</link>
      <description>&lt;P&gt;I am answering myself hahah&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table xx as&lt;/P&gt;
&lt;P&gt;select * from sample;&lt;/P&gt;
&lt;P&gt;group by userid&amp;nbsp;&lt;/P&gt;
&lt;P&gt;having date_new=max(date);&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please feel free to share any thoughts you have &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 01:22:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Only-keep-the-records-that-have-the-later-date/m-p/703763#M215686</guid>
      <dc:creator>yichentian226</dc:creator>
      <dc:date>2020-12-05T01:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Only keep the records that have the later date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Only-keep-the-records-that-have-the-later-date/m-p/703764#M215687</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input date :mmddyy10.             userid  $      factor  $;
format date mmddyy10.;
cards;
8/21/2020     736ksls      text

11/20/2020   736ksls      text

02/07/2019   blea282     text

10/28/2020   blea282     text
;

data want;
 set have;
 by userid factor notsorted;
 if last.factor;
run;
/*or SQL*/
proc sql;
 create table want as
 select *
 from have
 group by userid,factor
 having max(date)=date;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 05 Dec 2020 01:27:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Only-keep-the-records-that-have-the-later-date/m-p/703764#M215687</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-12-05T01:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: Only keep the records that have the later date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Only-keep-the-records-that-have-the-later-date/m-p/703765#M215688</link>
      <description>&lt;P&gt;You can try:&lt;/P&gt;&lt;P&gt;IF LAST.userid=1 THEN DO;&lt;BR /&gt;OUTPUT;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 01:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Only-keep-the-records-that-have-the-later-date/m-p/703765#M215688</guid>
      <dc:creator>yeji6144</dc:creator>
      <dc:date>2020-12-05T01:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Only keep the records that have the later date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Only-keep-the-records-that-have-the-later-date/m-p/703805#M215701</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344529"&gt;@yeji6144&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You can try:&lt;/P&gt;
&lt;P&gt;IF LAST.userid=1 THEN DO;&lt;BR /&gt;OUTPUT;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Better End; that Do;&lt;/P&gt;
&lt;P&gt;or just:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If last.userid;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 09:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Only-keep-the-records-that-have-the-later-date/m-p/703805#M215701</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-05T09:34:03Z</dc:date>
    </item>
  </channel>
</rss>

