<?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: Detect Duplicate Observations in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521813#M4299</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Be careful recommending NODUPRECS ... because it only deletes duplicate records that are adjacent to each other.&amp;nbsp; For instance the following proc sort does NOT delete any records, even though records 1 and 3 are duplicates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id x y z;
datalines;
1 1 1 1
1 2 2 2
1 1 1 1
run;
proc sort data=have out=sorted_have noduprecs;
  by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest keeping nodupkey, but use the variable proxy _ALL_ as the last sort key, as in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=sorted_have_all nodupkeys;
  by id _ALL_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The technique here is to list all the desired primary sort keys first, and then append _ALL_ at the end of the by-list.&amp;nbsp; It doesn't matter that ID is both the primary sort key, and also a subordinate sort key because it is part of _ALL_.&amp;nbsp; The subordinate usage will have no impact on resulting sort order.&lt;/P&gt;</description>
    <pubDate>Sun, 16 Dec 2018 17:58:20 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-12-16T17:58:20Z</dc:date>
    <item>
      <title>Detect Duplicate Observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521776#M4286</link>
      <description>&lt;P&gt;Hello. I have a data set with 2 variables (ID and Var1). There are some duplicates (red color in the following example) in this data sets.&lt;/P&gt;&lt;P&gt;The left is what I have and the right one is what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Var1&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; ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Var1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;aa&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; &lt;FONT color="#000000"&gt;101&lt;/FONT&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;FONT color="#000000"&gt;aa&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ab&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; &lt;FONT color="#000000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ab&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ac&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; &lt;FONT color="#000000"&gt;&lt;SPAN&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ac&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ad&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;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ad&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ca&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; &lt;SPAN&gt;1&lt;FONT color="#000000"&gt;02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ca&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;da&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;&lt;SPAN&gt;103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; da&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;aa&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ab&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ad&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;The code I am using is&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sort data=have out=want nodupkey;
by ID Var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt;However, I found that only one duplicate observation was deleted and the reminaing duplicates are still in the data set. Did I use the wrong code? Thanks.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2018 06:54:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521776#M4286</guid>
      <dc:creator>dapenDaniel</dc:creator>
      <dc:date>2018-12-16T06:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Duplicate Observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521778#M4287</link>
      <description>&lt;P&gt;When I run&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Var1 $;
datalines;
101 aa
101 ab
101 ac
101 ad
102 ca
103 da
101 aa
101 ab
101 ac
101 ad
;

proc sort data=have out=want nodupkey;
   by ID Var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The log says&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25725i308457C371A29D18/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2018 07:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521778#M4287</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-16T07:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Duplicate Observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521782#M4288</link>
      <description>&lt;P&gt;Alternatively with first. in the data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Var1 $;
datalines;
101 aa
101 ab
101 ac
101 ad
102 ca
103 da
101 aa
101 ab
101 ac
101 ad
;

proc sort data=have;
by ID Var1;
run;

data want;
set have;
by ID Var1;
if first.Var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Dec 2018 09:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521782#M4288</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-12-16T09:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Duplicate Observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521803#M4295</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Var1 $;
datalines;
101 aa
101 ab
101 ac
101 ad
102 ca
103 da
101 aa
101 ab
101 ac
101 ad
;



proc sort data =have out= want noduprecs;
by id var1 ;
run;

/*or*/

proc sql;
create table want as
select distinct *
from have;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Dec 2018 16:31:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521803#M4295</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-16T16:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Duplicate Observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521813#M4299</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Be careful recommending NODUPRECS ... because it only deletes duplicate records that are adjacent to each other.&amp;nbsp; For instance the following proc sort does NOT delete any records, even though records 1 and 3 are duplicates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input id x y z;
datalines;
1 1 1 1
1 2 2 2
1 1 1 1
run;
proc sort data=have out=sorted_have noduprecs;
  by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest keeping nodupkey, but use the variable proxy _ALL_ as the last sort key, as in&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=sorted_have_all nodupkeys;
  by id _ALL_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The technique here is to list all the desired primary sort keys first, and then append _ALL_ at the end of the by-list.&amp;nbsp; It doesn't matter that ID is both the primary sort key, and also a subordinate sort key because it is part of _ALL_.&amp;nbsp; The subordinate usage will have no impact on resulting sort order.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Dec 2018 17:58:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521813#M4299</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-16T17:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Duplicate Observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521962#M4318</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202889"&gt;@dapenDaniel&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello. I have a data set with 2 variables (ID and Var1). There are some duplicates (red color in the following example) in this data sets.&lt;/P&gt;
&lt;P&gt;The left is what I have and the right one is what I want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Var1&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; ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Var1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;aa&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; &lt;FONT color="#000000"&gt;101&lt;/FONT&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;FONT color="#000000"&gt;aa&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ab&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; &lt;FONT color="#000000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ab&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ac&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; &lt;FONT color="#000000"&gt;&lt;SPAN&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ac&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ad&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;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ad&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ca&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; &lt;SPAN&gt;1&lt;FONT color="#000000"&gt;02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ca&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;da&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;&lt;SPAN&gt;103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; da&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;aa&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ab&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ac&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ad&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;&lt;FONT color="#000000"&gt;The code I am using is&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sort data=have out=want nodupkey;
by ID Var1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT color="#ff0000"&gt;&lt;FONT color="#000000"&gt;However, I found that only one duplicate observation was deleted and the reminaing duplicates are still in the data set. &lt;FONT size="4"&gt;&lt;STRONG&gt;&lt;FONT color="#0000ff"&gt;Did I use the wrong code?&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt; Thanks.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;We can't tell if you used the wrong code because you have not shown what you actually got for a result. If you did not get the result you show it may mean that your data is not quite what you think. If a&amp;nbsp; value has a leading space then ' aa' is not equal to 'aa' and would not be deleted. This is a potential issue with any of the variables on the BY statement. Another is if a value is numeric the assigned format might not be displaying decimal values that would show up as not equal.&lt;/P&gt;
&lt;P&gt;Example of this last issue:&lt;/P&gt;
&lt;PRE&gt;data example;
   input x;
   format x f1.;
datalines;
1.5
1.6
1.7
;
run;&lt;/PRE&gt;
&lt;P&gt;If you print or view the Example data set created above all of the values will appear as 2 because of the format but the actual values are different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is one reason we recommend posting data as an actual data step.&amp;nbsp; Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 16:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521962#M4318</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-12-17T16:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Duplicate Observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521979#M4324</link>
      <description>&lt;P&gt;Thank you. There is indeed some leading spaces. I have solved this problem.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 17:26:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521979#M4324</guid>
      <dc:creator>dapenDaniel</dc:creator>
      <dc:date>2018-12-17T17:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Duplicate Observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521982#M4327</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;. I know and love it when you've helped and continue to help me learn numerous times.&amp;nbsp; What I assumed was OP wanting select unique records and my understanding of noduprecs( exclude duplicate records and pick one record) rather than dup keys which is akin to select distinct * in proc sql, and hence i posted that lazy version too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nonetheless when and if&lt;STRONG&gt; you participate,&lt;/STRONG&gt; i tend to pay sincere attention and kept thinking. So basically I think&lt;/P&gt;
&lt;P&gt;proc sort&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by _all_&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with a noduprecs&amp;nbsp;&lt;/P&gt;
&lt;P&gt;should be equal to&lt;/P&gt;
&lt;P&gt;proc sort&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by all variables listed one after another with a nodupkey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also OP's requirement seems to pick a combination of all vars as unique obs than based keys unless of course all keys making it a composite combination.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
  input id x y z;
datalines;
1 1 1 1
1 2 2 2
1 1 1 1
;
run;

proc sort noduprecs;
by _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I wonder if my understanding is correct, distinct sql is perhaps the easiest/laziest and convenient way to go &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Btw, my apologies for the late acknowledgement as I slept like a baby all weekend and barely moved. I hope you have a nice day and week ahead.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 17:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/521982#M4327</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-17T17:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Detect Duplicate Observations</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/522000#M4333</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes.&amp;nbsp; To my knowledge the code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=want noduprecs;
  by _all_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;produces the same results as&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 distinct *
  from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And of course in the case of BY _ALL_, keywords NODUPKEY and NODUPRECS are the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem with BY _ALL_, as with&amp;nbsp;SELECT *, is that, while duplicates are removed, you may not end up with the desired record order,&amp;nbsp;for instance when&amp;nbsp;ID is not the first variable in the data set.&amp;nbsp; That's when you might choose to precede _ALL_ with the variables you want controlling the output order.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 18:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Detect-Duplicate-Observations/m-p/522000#M4333</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-17T18:40:59Z</dc:date>
    </item>
  </channel>
</rss>

