<?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: keep only 1 line in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23794#M3961</link>
    <description>Scott is right.&lt;BR /&gt;
My system options is set to SORTEQUALS, so if you're not sure about yours, you should specify the EQUALS options for the sort procedure to ensure that the order is preserved.&lt;BR /&gt;
&lt;BR /&gt;
_data null_'s solution is a great alternative (didn't knew about the idgroup option).&lt;BR /&gt;
&lt;BR /&gt;
Greetings from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos at &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
    <pubDate>Tue, 28 Apr 2009 16:39:27 GMT</pubDate>
    <dc:creator>DanielSantos</dc:creator>
    <dc:date>2009-04-28T16:39:27Z</dc:date>
    <item>
      <title>keep only 1 line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23789#M3956</link>
      <description>I have sas data set as below&lt;BR /&gt;
&lt;BR /&gt;
       id  var2  var3   date&lt;BR /&gt;
      001    B    11    20080601    &lt;BR /&gt;
      001    B     11    20080709&lt;BR /&gt;
       001   B      11    20090113&lt;BR /&gt;
&lt;BR /&gt;
I have 3 lines but same id, i would like to keep only the latest date line (in this case is 20090113).  How do i keep it ?</description>
      <pubDate>Mon, 27 Apr 2009 10:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23789#M3956</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-27T10:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: keep only 1 line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23790#M3957</link>
      <description>proc sort data = DSNAME;&lt;BR /&gt;
 by id date;&lt;BR /&gt;
 if last.id then output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
//Fredrik</description>
      <pubDate>Mon, 27 Apr 2009 10:26:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23790#M3957</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2009-04-27T10:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: keep only 1 line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23791#M3958</link>
      <description>Somethings wrong about the code above.&lt;BR /&gt;
&lt;BR /&gt;
The correct syntax would be.&lt;BR /&gt;
&lt;BR /&gt;
proc sort data = yourdata; /* arrange data by id, and descending date */&lt;BR /&gt;
by id descending date;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort nodupkey; /* keep first id of each group */&lt;BR /&gt;
by id;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
OR:&lt;BR /&gt;
&lt;BR /&gt;
proc sort data = yourdata; /* arrange data by id, and descending date */&lt;BR /&gt;
by id descending date;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data yourdata;  /* keep first id of each group */&lt;BR /&gt;
set yourdata;&lt;BR /&gt;
by id;&lt;BR /&gt;
if first.id;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
both do the same.&lt;BR /&gt;
&lt;BR /&gt;
Greetings from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos at &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
      <pubDate>Mon, 27 Apr 2009 10:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23791#M3958</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-04-27T10:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: keep only 1 line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23792#M3959</link>
      <description>The SORT-only execution requires the EQUALS parameter, if not the default for your sort package.  And the use of FIRST.&lt;VARNAME&gt;   or LAST.&lt;VARNAME&gt;  with regards to OUTPUT delivers the same result.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/VARNAME&gt;&lt;/VARNAME&gt;</description>
      <pubDate>Mon, 27 Apr 2009 13:07:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23792#M3959</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-04-27T13:07:07Z</dc:date>
    </item>
    <item>
      <title>Re: keep only 1 line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23793#M3960</link>
      <description>PROC SUMMARY provides nice single step solution to this problem.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
   input id:$3.  var2:$1. var3 date :yymmdd.;&lt;BR /&gt;
   format date date9.;&lt;BR /&gt;
   cards;&lt;BR /&gt;
001 B 11 20080601 &lt;BR /&gt;
001 B 11 20080709&lt;BR /&gt;
001 B 11 20090113&lt;BR /&gt;
002 B 11 20080601 &lt;BR /&gt;
002 a 12 20080709&lt;BR /&gt;
002 B 11 20060113&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc summary data=work.have nway missing;&lt;BR /&gt;
   class id;&lt;BR /&gt;
   output out=need(drop=_:) idgroup(max(date) out(date var:)=);&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 27 Apr 2009 13:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23793#M3960</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-04-27T13:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: keep only 1 line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23794#M3961</link>
      <description>Scott is right.&lt;BR /&gt;
My system options is set to SORTEQUALS, so if you're not sure about yours, you should specify the EQUALS options for the sort procedure to ensure that the order is preserved.&lt;BR /&gt;
&lt;BR /&gt;
_data null_'s solution is a great alternative (didn't knew about the idgroup option).&lt;BR /&gt;
&lt;BR /&gt;
Greetings from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos at &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;.</description>
      <pubDate>Tue, 28 Apr 2009 16:39:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-1-line/m-p/23794#M3961</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-04-28T16:39:27Z</dc:date>
    </item>
  </channel>
</rss>

