<?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: Find of there are identical values in data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600009#M173322</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A solution with sql :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
    CREATE TABLE duplicates AS 
    SELECT *, count(*) AS ndupl
    FROM ttbl
    GROUP BY x
    HAVING count(*)&amp;gt;1
    ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Oct 2019 09:46:42 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2019-10-29T09:46:42Z</dc:date>
    <item>
      <title>Find of there are identical values in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/599999#M173317</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have a data set that includes one field.&lt;/P&gt;
&lt;P&gt;Task is to find if there are any 2 (or more rows) with same value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data ttbl;
input x;
cards;
23455
44566
77788
55444
89899
55555
55444
34456
;
Run;

/*Task: Find if in the table there are 2 lines with same values*/
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Oct 2019 08:05:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/599999#M173317</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-10-29T08:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: Find of there are identical values in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600001#M173319</link>
      <description>&lt;P&gt;Do something like this and save the duplicates in a data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=ttbl out=ttbl_2 dupout=Duplicates;
    by x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Oct 2019 08:12:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600001#M173319</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-29T08:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Find of there are identical values in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600008#M173321</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Using datastep*/
Data t1;
input x;
cards;
23455
44566
77788
55444
89899
55555
55444
34456
;
Run;

proc sort data=t1  ;		/* if we use nodupkey in proc sort we didn't get proper output*/
by x;
run;

data unique duplicate;
set t1;
by x;
if first.x and last.x then output unique;
else output	duplicate;
run;

/*Using Procedure*/
proc freq data=t1 ;
tables x /nocum nocol norow nopercent;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Oct 2019 09:42:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600008#M173321</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2019-10-29T09:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Find of there are identical values in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600009#M173322</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A solution with sql :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
    CREATE TABLE duplicates AS 
    SELECT *, count(*) AS ndupl
    FROM ttbl
    GROUP BY x
    HAVING count(*)&amp;gt;1
    ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Oct 2019 09:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600009#M173322</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-10-29T09:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Find of there are identical values in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600011#M173323</link>
      <description>&lt;P&gt;Alternatively try proc sql as below&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Using datastep*/
Data t1;
input x;
cards;
23455
44566
77788
55444
89899
55555
55444
34456
;
Run;

proc sql;
create table want as select count(x) as count, x from t1 group by x;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 249px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33456iB11A99EE0A53D5CE/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 09:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600011#M173323</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2019-10-29T09:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Find of there are identical values in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600047#M173348</link>
      <description>&lt;P&gt;Just for fun.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there are some error info in LOG , then table has duplicated value.&lt;/P&gt;
&lt;PRE&gt;ERROR: Duplicate key found when loading data set ttbl at line 40 column 2.
&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data ttbl;
input x;
cards;
23455
44566
77788
55444
89899
55555
55444
34456
;
Run;

data _null_;
 if 0 then set ttbl	;
 declare hash h(dataset:'ttbl',duplicate:'e');
 h.definekey(all:'y');
 h.definedone();
 stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 12:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600047#M173348</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-10-29T12:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Find of there are identical values in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600069#M173360</link>
      <description>&lt;P&gt;Hi sharp&lt;/P&gt;&lt;P&gt;why it shows in error in log&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hash table cannot find duplicate values hash table only joins two tables please explain with code&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 13:55:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600069#M173360</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2019-10-29T13:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Find of there are identical values in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600073#M173363</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp; &amp;nbsp;Proc Freq would generally be the natural inclination for most people considering it's easy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

Data t1;
input x;
cards;
23455
44566
77788
55444
89899
55555
55444
34456
;
Run;

/*Count greater than 1*/

proc freq data=t1 noprint;
tables x/out=want(keep=x count where=(count&amp;gt;1));
run;
/*Or */
/*Count all*/

proc freq data=t1 noprint;
tables x/out=want(keep=x count);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Oct 2019 14:12:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600073#M173363</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-10-29T14:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Find of there are identical values in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600348#M173513</link>
      <description>&lt;P&gt;I made an parameter&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;duplicate:&lt;SPAN class="token string"&gt;'e'&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in Hash Table .&lt;/P&gt;
&lt;P&gt;It will issue an error info if there are&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;duplicate values&amp;nbsp;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Actually Hash table could tell you which one is duplicated , but need more code ,I think you don't need it .&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 12:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-of-there-are-identical-values-in-data-set/m-p/600348#M173513</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-10-30T12:12:00Z</dc:date>
    </item>
  </channel>
</rss>

