<?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: Keeping one of duplicate rows in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119158#M32850</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, hit enter too soon. - &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; I want to keep records with the bigger 'Difference' / earlier Date1. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 21 Oct 2013 19:50:01 GMT</pubDate>
    <dc:creator>acros</dc:creator>
    <dc:date>2013-10-21T19:50:01Z</dc:date>
    <item>
      <title>Keeping one of duplicate rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119155#M32847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is an example of my dataset:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Patient&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date1&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date2&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;&amp;nbsp; Difference&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Anna Smith&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 14MAY2013&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22JUL2013&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; 69&lt;/P&gt;&lt;P&gt;Anna Smith&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01MAY2013&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22JUL2013&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; 82&lt;/P&gt;&lt;P&gt;John Brown&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 05JUN2013&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12JUL2013&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; 37&lt;/P&gt;&lt;P&gt;John Brown&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 06MAY2013&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12JUL2013&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; 67&lt;/P&gt;&lt;P&gt;Susan Garcia&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 06MAY2013&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 06SEP2013&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; 123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 19:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119155#M32847</guid>
      <dc:creator>acros</dc:creator>
      <dc:date>2013-10-21T19:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping one of duplicate rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119156#M32848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So duplicate is identified by Patient? How do you know which one you want to keep?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sort with a nodupkey is an option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A data step (assuming sorted data) with first/last are another option.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Logic is required though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 19:47:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119156#M32848</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-21T19:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping one of duplicate rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119157#M32849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Sorry, I didn't finish typing my question:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I want to get rid of duplicates, but specifically keep the records with the bigger 'Difference' / earlier Date1 (those records that are in bold above). How can I do this? &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 19:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119157#M32849</guid>
      <dc:creator>acros</dc:creator>
      <dc:date>2013-10-21T19:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping one of duplicate rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119158#M32850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, hit enter too soon. - &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; I want to keep records with the bigger 'Difference' / earlier Date1. &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 19:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119158#M32850</guid>
      <dc:creator>acros</dc:creator>
      <dc:date>2013-10-21T19:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping one of duplicate rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119159#M32851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the double sort method below. There's a link below that explains how it works in more details.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have;&lt;/P&gt;&lt;P&gt;by patient descending difference;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=have out=want nodupkey;&lt;/P&gt;&lt;P&gt;by patient;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.datasavantconsulting.com/roland/nodup.html" title="http://www.datasavantconsulting.com/roland/nodup.html"&gt;Proc sort nodup&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 19:55:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119159#M32851</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-21T19:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping one of duplicate rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119160#M32852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah. That's simple. I don't know know why I thought it needed to be more complicated that than. Thank you for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Oct 2013 20:40:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119160#M32852</guid>
      <dc:creator>acros</dc:creator>
      <dc:date>2013-10-21T20:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping one of duplicate rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119161#M32853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="255172" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Even though your double sort approach works and I've seen this recently even done in a production implementation I personally have strong reservations of using this, because:&lt;/P&gt;&lt;P&gt;- It relies on implicit knowledge of the sort algorithm Proc Sort uses&lt;/P&gt;&lt;P&gt;- I believe this approach will stop working when Proc Sort is pushed to a data base&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#n083u6oz7drxh9n15y59r6jzw5o1.htm" title="http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#n083u6oz7drxh9n15y59r6jzw5o1.htm"&gt;Base SAS(R) 9.3 Procedures Guide, Second Edition&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I personally prefer to either use a Proc Sort together with a Data step and first. or last. or to use a Proc SQL with a min() function and Group By / Having clause.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Oct 2013 03:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119161#M32853</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-10-22T03:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping one of duplicate rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119162#M32854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;Patrick wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;A _jive_internal="true" data-containerid="-1" data-containertype="-1" data-objectid="255172" data-objecttype="3" href="https://communities.sas.com/people/Reeza"&gt;Fareeza Khurshed&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Even though your double sort approach works and I've seen this recently even done in a production implementation I personally have strong reservations of using this, because:&lt;/P&gt;
&lt;P&gt;1 It relies on implicit knowledge of the sort algorithm Proc Sort uses&lt;/P&gt;
&lt;P&gt;2 I believe this approach will stop working when Proc Sort is pushed to a data base&lt;/P&gt;
&lt;P&gt;&lt;A class="jive-link-external-small" href="http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#n083u6oz7drxh9n15y59r6jzw5o1.htm"&gt;Base SAS(R) 9.3 Procedures Guide, Second Edition&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I personally prefer to either use a Proc Sort together with a Data step and first. or last. or to use a Proc SQL with a min() function and Group By / Having clause.&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;I disagree with 1, you don't need to know the sort algorithm of Proc Sort, just the concept of sorting data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure what you mean by 2 sort on a database.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Oct 2013 15:09:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Keeping-one-of-duplicate-rows/m-p/119162#M32854</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-22T15:09:20Z</dc:date>
    </item>
  </channel>
</rss>

