<?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: Proc sort Nodupkey..but I want to keep the first occurance in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sort-Nodupkey-but-I-want-to-keep-the-first-occurance/m-p/57992#M16190</link>
    <description>Another option if you want more "control" is to consider using a DATA step with a SET statement, a BY statement (input file must be sorted by the variable list), and use IF FIRST.variable_name and if necessary IF LAST.variable_name, and the OUTPUT statement to create the file as needed.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Thu, 30 Oct 2008 02:34:09 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2008-10-30T02:34:09Z</dc:date>
    <item>
      <title>Proc sort Nodupkey..but I want to keep the first occurance</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sort-Nodupkey-but-I-want-to-keep-the-first-occurance/m-p/57990#M16188</link>
      <description>I have a data set in which I have duplicates (rcode, pcodes, and prov).  I want to create a new table in which these are deduped, but retaining the first time they were experienced as unique by (keydt).  I cant use proc sort nodupkey because I need to include keydate in the sort, and will yield no dups by that particular date.  If I don’t use the keydate the sort will then sort by rcode, pcode and prov; and will not yield the first time the unique combination was observed.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data xx;&lt;BR /&gt;
format keydt date. rcode $4. pcode $5.;&lt;BR /&gt;
input ID keydt :date. rcode pcode pr;&lt;BR /&gt;
cards;&lt;BR /&gt;
8001	20-Jan-06	634	J0886	26&lt;BR /&gt;
8001	20-Jan-06	636	J1270	26&lt;BR /&gt;
8001	20-Jan-06	821	90999	26&lt;BR /&gt;
8001	06-Feb-06	634	J0886	26&lt;BR /&gt;
8001	06-Feb-06	636	J1270	26&lt;BR /&gt;
8001	06-Feb-06	821	90999	26&lt;BR /&gt;
8001	23-Feb-06	634	J0886	26&lt;BR /&gt;
8001	23-Feb-06	636	J1270	26&lt;BR /&gt;
8001	23-Feb-06	821	90935	26&lt;BR /&gt;
8001	03-Mar-06	634	J0886	26&lt;BR /&gt;
8001	03-Mar-06	636	J1270	26&lt;BR /&gt;
8001	03-Mar-06	821	90935	26&lt;BR /&gt;
8001	10-Apr-06	636	J1270	26&lt;BR /&gt;
8001	10-Apr-06	821	90935	26&lt;BR /&gt;
8001	20-Apr-06	634	J0886	26&lt;BR /&gt;
8001	20-Apr-06	636	J1270	26&lt;BR /&gt;
8001	20-Apr-06	821	90935	26&lt;BR /&gt;
8001	13-May-06	270	A4657	26&lt;BR /&gt;
8001	13-May-06	634	J0886	26&lt;BR /&gt;
8001	13-May-06	636	J1270	26&lt;BR /&gt;
8001	13-May-06	821	90935	26&lt;BR /&gt;
8001	16-May-06	270	A4657	26&lt;BR /&gt;
8001	16-May-06	634	J0886	26&lt;BR /&gt;
8001	16-May-06	636	J1270	26&lt;BR /&gt;
8001	16-May-06	821	90935	26&lt;BR /&gt;
8001	22-May-06	634	J0886	26&lt;BR /&gt;
8001	22-May-06	636	J1270	26&lt;BR /&gt;
8001	22-May-06	821	90935	26&lt;BR /&gt;
8001	07-Jun-06	634	J0886	26&lt;BR /&gt;
8001	07-Jun-06	636	J1270	26&lt;BR /&gt;
8001	07-Jun-06	821	90935	26&lt;BR /&gt;
8001	20-Jun-06	634	J0886	26&lt;BR /&gt;
8001	20-Jun-06	636	J1270	26&lt;BR /&gt;
8001	20-Jun-06	821	90935	26&lt;BR /&gt;
8001	07-Jul-06	270	A4657	26&lt;BR /&gt;
8001	07-Jul-06	634	J0886	26&lt;BR /&gt;
8001	07-Jul-06	636	J1270	26&lt;BR /&gt;
8001	07-Jul-06	821	90935	26&lt;BR /&gt;
8001	14-Jul-06	634	J0886	26&lt;BR /&gt;
&lt;BR /&gt;
;&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 29 Oct 2008 22:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sort-Nodupkey-but-I-want-to-keep-the-first-occurance/m-p/57990#M16188</guid>
      <dc:creator>Ray_H</dc:creator>
      <dc:date>2008-10-29T22:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort Nodupkey..but I want to keep the first occurance</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sort-Nodupkey-but-I-want-to-keep-the-first-occurance/m-p/57991#M16189</link>
      <description>Consider using multiple sorts, first without and then with the NODUPSKEY and also including the EQUALS parameter for your BY key variables. &lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 30 Oct 2008 02:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sort-Nodupkey-but-I-want-to-keep-the-first-occurance/m-p/57991#M16189</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-10-30T02:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort Nodupkey..but I want to keep the first occurance</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sort-Nodupkey-but-I-want-to-keep-the-first-occurance/m-p/57992#M16190</link>
      <description>Another option if you want more "control" is to consider using a DATA step with a SET statement, a BY statement (input file must be sorted by the variable list), and use IF FIRST.variable_name and if necessary IF LAST.variable_name, and the OUTPUT statement to create the file as needed.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 30 Oct 2008 02:34:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sort-Nodupkey-but-I-want-to-keep-the-first-occurance/m-p/57992#M16190</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-10-30T02:34:09Z</dc:date>
    </item>
  </channel>
</rss>

