<?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 duplicates and keep last entry only in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicates-and-keep-last-entry-only/m-p/781171#M31738</link>
    <description>Thanks a lot Andrea!&lt;BR /&gt;It was really kind of you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Fri, 19 Nov 2021 01:44:31 GMT</pubDate>
    <dc:creator>mmh</dc:creator>
    <dc:date>2021-11-19T01:44:31Z</dc:date>
    <item>
      <title>Remove duplicates and keep last entry only</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicates-and-keep-last-entry-only/m-p/780979#M31704</link>
      <description>&lt;P&gt;Dear Altruists.&lt;BR /&gt;I am a new SAS user.&lt;BR /&gt;I have the following dataset:&lt;BR /&gt;&lt;BR /&gt;GVKey Report_Date Quarter&lt;BR /&gt;1001 31-03-21 Q1&lt;BR /&gt;1001 30-06-21 Q2&lt;BR /&gt;1001 30-09-21 Q3&lt;BR /&gt;1001 05-10-21 Q3&lt;BR /&gt;1001 10-10-21 Q3&lt;BR /&gt;1001 31-12-21 Q4&lt;BR /&gt;1002 31-03-21 Q1&lt;BR /&gt;1002 30-06-21 Q2&lt;BR /&gt;1002 01-07-21 Q2&lt;BR /&gt;1002 30-09-21 Q3&lt;BR /&gt;1002 31-12-21 Q4&lt;BR /&gt;&lt;BR /&gt;I want to remove the duplicates and keep only the last entry based on the variable "Quarter" for a given firm.&lt;BR /&gt;I want two resulting datasets. The first is a clean dataset as follows:&lt;BR /&gt;&lt;BR /&gt;GVKey Report_Date Quarter&lt;BR /&gt;1001 31-03-21 Q1&lt;BR /&gt;1001 30-06-21 Q2&lt;BR /&gt;1001 10-10-21 Q3&lt;BR /&gt;1001 31-12-21 Q4&lt;BR /&gt;1002 31-03-21 Q1&lt;BR /&gt;1002 01-07-21 Q2&lt;BR /&gt;1002 30-09-21 Q3&lt;BR /&gt;1002 31-12-21 Q4&lt;BR /&gt;&lt;BR /&gt;The second dataset will contain only the duplicate values as follows:&lt;BR /&gt;&lt;BR /&gt;GVKey Report_Date Quarter&lt;BR /&gt;1001 30-09-21 Q3&lt;BR /&gt;1001 05-10-21 Q3&lt;BR /&gt;1002 30-06-21 Q2&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I thank you in advance for your kind support!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 09:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-duplicates-and-keep-last-entry-only/m-p/780979#M31704</guid>
      <dc:creator>mmh</dc:creator>
      <dc:date>2021-11-18T09:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicates and keep last entry only</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicates-and-keep-last-entry-only/m-p/781012#M31706</link>
      <description>data have;&lt;BR /&gt;input GVKey $ RD $ Quarter$;&lt;BR /&gt;infile datalines dlm = ' ';&lt;BR /&gt;Report_date=mdy( substr(rd,4,2) , substr(rd,1,2) , substr(rd,7,2) );&lt;BR /&gt;format Report_date ddmmyy10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1001 31-03-21 Q1&lt;BR /&gt;1001 30-06-21 Q2&lt;BR /&gt;1001 30-09-21 Q3&lt;BR /&gt;1001 05-10-21 Q3&lt;BR /&gt;1001 10-10-21 Q3&lt;BR /&gt;1001 31-12-21 Q4&lt;BR /&gt;1002 31-03-21 Q1&lt;BR /&gt;1002 30-06-21 Q2&lt;BR /&gt;1002 01-07-21 Q2&lt;BR /&gt;1002 30-09-21 Q3&lt;BR /&gt;1002 31-12-21 Q4&lt;BR /&gt;; run;&lt;BR /&gt;&lt;BR /&gt;data out_last out_dup;&lt;BR /&gt;set have;&lt;BR /&gt;by GVKey Quarter;&lt;BR /&gt;if last.quarter=1 then output out_last;&lt;BR /&gt;else output out_dup;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Nov 2021 13:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-duplicates-and-keep-last-entry-only/m-p/781012#M31706</guid>
      <dc:creator>AndreaVianello</dc:creator>
      <dc:date>2021-11-18T13:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicates and keep last entry only</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicates-and-keep-last-entry-only/m-p/781015#M31707</link>
      <description>&lt;P&gt;Since the FIRST. and LAST. automatic variables contain only boolean values (1=true, 0=false), you can use last.quarter on its own without comparing it with 1.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if last.quarter
then output out_last;
else output out_dup;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Nov 2021 13:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-duplicates-and-keep-last-entry-only/m-p/781015#M31707</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-18T13:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Remove duplicates and keep last entry only</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Remove-duplicates-and-keep-last-entry-only/m-p/781171#M31738</link>
      <description>Thanks a lot Andrea!&lt;BR /&gt;It was really kind of you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 19 Nov 2021 01:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Remove-duplicates-and-keep-last-entry-only/m-p/781171#M31738</guid>
      <dc:creator>mmh</dc:creator>
      <dc:date>2021-11-19T01:44:31Z</dc:date>
    </item>
  </channel>
</rss>

