<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/remove-duplicates/m-p/410631#M100332</link>
    <description>&lt;P&gt;Given that your data set is already in sorted order by ID AGE, you could try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id age;&lt;/P&gt;
&lt;P&gt;if first.age;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's worth spending time on the BY statement in a DATA step and how it creates FIRST.AGE (and a few more variables).&amp;nbsp; Those will be tools you use over and over again.&lt;/P&gt;</description>
    <pubDate>Sun, 05 Nov 2017 03:02:16 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-11-05T03:02:16Z</dc:date>
    <item>
      <title>remove duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-duplicates/m-p/410626#M100328</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp; age&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var1&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 32&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 33&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;How do I remove duplicate ID and age ? It doesn't matter if I keep the first or last of duplicate&lt;/P&gt;&lt;P&gt;So the I want my table to look like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID age var1&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; 30&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; 32&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp; 33&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2017 01:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-duplicates/m-p/410626#M100328</guid>
      <dc:creator>leahcho</dc:creator>
      <dc:date>2017-11-05T01:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: remove duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-duplicates/m-p/410627#M100329</link>
      <description>Look up the documentation of proc sort, especially the nodule option. Using Id and age as by-vars should solve the problem.</description>
      <pubDate>Sun, 05 Nov 2017 02:39:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-duplicates/m-p/410627#M100329</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2017-11-05T02:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: remove duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-duplicates/m-p/410631#M100332</link>
      <description>&lt;P&gt;Given that your data set is already in sorted order by ID AGE, you could try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id age;&lt;/P&gt;
&lt;P&gt;if first.age;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's worth spending time on the BY statement in a DATA step and how it creates FIRST.AGE (and a few more variables).&amp;nbsp; Those will be tools you use over and over again.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2017 03:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-duplicates/m-p/410631#M100332</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-05T03:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: remove duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-duplicates/m-p/410632#M100333</link>
      <description>&lt;P&gt;You can remove duplicats, either by&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=want NODUPKEY;
  by id age;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or by SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table want as
    select * from have
    group by id, age
; quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you compare the rwo methods, you'll find that -&lt;/P&gt;
&lt;P&gt;the one keeps the 1st occurence while the other keeps the last occurence.&lt;/P&gt;
&lt;P&gt;As much as I remeber, SQL keeps the 1st occurence.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Nov 2017 02:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-duplicates/m-p/410632#M100333</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-11-05T02:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: remove duplicates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-duplicates/m-p/410737#M100368</link>
      <description>&lt;P&gt;proc sort data=have;&amp;nbsp;&lt;/P&gt;&lt;P&gt;by ID age var1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by ID age var1;&lt;/P&gt;&lt;P&gt;if first.var1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2017 01:48:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-duplicates/m-p/410737#M100368</guid>
      <dc:creator>DavyJones</dc:creator>
      <dc:date>2017-11-06T01:48:38Z</dc:date>
    </item>
  </channel>
</rss>

