<?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 Keep observations using a condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555297#M154533</link>
    <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my question is how I can only keep the IDs with the highest value of&amp;nbsp; A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id A B C;&lt;BR /&gt;cards;&lt;BR /&gt;1 2 3 4&lt;BR /&gt;1 4 2 5&lt;BR /&gt;1 5 3 12&lt;BR /&gt;1 7 34 3&lt;BR /&gt;2 5 5 5&lt;BR /&gt;2 6 12 0&lt;BR /&gt;2 9 3 2&lt;BR /&gt;2 11 3 1&lt;BR /&gt;3 7 6 5&lt;BR /&gt;3 23 3 2&lt;BR /&gt;3 12 12 44&lt;BR /&gt;4 4 23 33&lt;BR /&gt;4 9 6 1&lt;BR /&gt;5 5 7 2&lt;BR /&gt;6 7 8 1&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;input id A B C;&lt;BR /&gt;cards;&lt;BR /&gt;1 7 34 3&lt;BR /&gt;2 11 3 1&lt;BR /&gt;3 23 3 2&lt;BR /&gt;4 9 6 1&lt;BR /&gt;5 5 7 2&lt;BR /&gt;6 7 8 1&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 May 2019 08:16:30 GMT</pubDate>
    <dc:creator>ali_far</dc:creator>
    <dc:date>2019-05-01T08:16:30Z</dc:date>
    <item>
      <title>Keep observations using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555297#M154533</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my question is how I can only keep the IDs with the highest value of&amp;nbsp; A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input id A B C;&lt;BR /&gt;cards;&lt;BR /&gt;1 2 3 4&lt;BR /&gt;1 4 2 5&lt;BR /&gt;1 5 3 12&lt;BR /&gt;1 7 34 3&lt;BR /&gt;2 5 5 5&lt;BR /&gt;2 6 12 0&lt;BR /&gt;2 9 3 2&lt;BR /&gt;2 11 3 1&lt;BR /&gt;3 7 6 5&lt;BR /&gt;3 23 3 2&lt;BR /&gt;3 12 12 44&lt;BR /&gt;4 4 23 33&lt;BR /&gt;4 9 6 1&lt;BR /&gt;5 5 7 2&lt;BR /&gt;6 7 8 1&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;input id A B C;&lt;BR /&gt;cards;&lt;BR /&gt;1 7 34 3&lt;BR /&gt;2 11 3 1&lt;BR /&gt;3 23 3 2&lt;BR /&gt;4 9 6 1&lt;BR /&gt;5 5 7 2&lt;BR /&gt;6 7 8 1&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 08:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555297#M154533</guid>
      <dc:creator>ali_far</dc:creator>
      <dc:date>2019-05-01T08:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Keep observations using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555301#M154536</link>
      <description>&lt;P&gt;Please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by id a;
run;

data want;
set have;
by id a;
if last.id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 May 2019 08:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555301#M154536</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-05-01T08:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Keep observations using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555302#M154537</link>
      <description>&lt;P&gt;by proc sql&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as select a.* from have as a 
inner join 
(select id, max(a) as maxa  from have group by id) as b  on a.id=b.id and a.a=b.maxa;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 May 2019 08:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555302#M154537</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-05-01T08:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Keep observations using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555303#M154538</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/149294"&gt;@ali_far&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option is PROC SUMMARY:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have;
by id;
var a;
output out=want(drop=_:) max= maxid(a(b c))=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 08:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555303#M154538</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-05-01T08:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Keep observations using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555304#M154539</link>
      <description>Thanks Jag,&lt;BR /&gt;both codes work well!&lt;BR /&gt;appreciate your time</description>
      <pubDate>Wed, 01 May 2019 08:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555304#M154539</guid>
      <dc:creator>ali_far</dc:creator>
      <dc:date>2019-05-01T08:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Keep observations using a condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555305#M154540</link>
      <description>Thanks a lot.&lt;BR /&gt;Your code also works well and it is so cool...</description>
      <pubDate>Wed, 01 May 2019 08:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-observations-using-a-condition/m-p/555305#M154540</guid>
      <dc:creator>ali_far</dc:creator>
      <dc:date>2019-05-01T08:48:17Z</dc:date>
    </item>
  </channel>
</rss>

