<?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: TOTAL NUMBER OF DUPLICATES ROWS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/TOTAL-NUMBER-OF-DUPLICATES-ROWS/m-p/352436#M82151</link>
    <description>&lt;PRE&gt;PROC SORT DATA=have;
  BY id;
RUN;

DATA HAVE1;
  do until(last.id);
    SET HAVE;
    BY ID;
    if first.id then count=1;
    else count+1;
  end;
  do until(last.id);
    SET HAVE;
    BY ID;
    output;
  end;
RUN;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 22 Apr 2017 15:06:31 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-04-22T15:06:31Z</dc:date>
    <item>
      <title>TOTAL NUMBER OF DUPLICATES ROWS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TOTAL-NUMBER-OF-DUPLICATES-ROWS/m-p/352435#M82150</link>
      <description>&lt;P&gt;I'd like to create a var "count" for the total number of repated rows in combination of multiple variables as shown in data "want". I know how to accomplish this using proc freq and merging output data back to original file. I wonder if i can do it in data step, as shown how my program had failed to do so below. I'm using SAS 9.4.&lt;/P&gt;&lt;P&gt;Could you please help with direct correction on my code below?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id cat dog ant;
datalines;
1 1 2 3
1 1 2 3
1 1 2 3
1 1 2 3
2 2 6 0
3 3 4 5
4 4 6 7
;
run; 

data want;
input id cat dog ant count;
datalines;
1 1 2 3 4
1 1 2 3 4
1 1 2 3 4
1 1 2 3 4
2 2 6 0 1
3 3 4 5 1
4 4 6 7 1
;
run; 

PROC SORT DATA=have;
BY id;
RUN;
DATA HAVE1; SET HAVE;
RETAIN COUNT;
BY ID;
IF FIRST.ID THEN VISIT = 1; ELSE VISIT+1;
IF LAST.ID THEN COUNT=VISIT;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2017 14:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TOTAL-NUMBER-OF-DUPLICATES-ROWS/m-p/352435#M82150</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-04-22T14:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: TOTAL NUMBER OF DUPLICATES ROWS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TOTAL-NUMBER-OF-DUPLICATES-ROWS/m-p/352436#M82151</link>
      <description>&lt;PRE&gt;PROC SORT DATA=have;
  BY id;
RUN;

DATA HAVE1;
  do until(last.id);
    SET HAVE;
    BY ID;
    if first.id then count=1;
    else count+1;
  end;
  do until(last.id);
    SET HAVE;
    BY ID;
    output;
  end;
RUN;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2017 15:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TOTAL-NUMBER-OF-DUPLICATES-ROWS/m-p/352436#M82151</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-04-22T15:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: TOTAL NUMBER OF DUPLICATES ROWS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/TOTAL-NUMBER-OF-DUPLICATES-ROWS/m-p/352438#M82152</link>
      <description>Баярлалаа. Thank you.</description>
      <pubDate>Sat, 22 Apr 2017 15:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/TOTAL-NUMBER-OF-DUPLICATES-ROWS/m-p/352438#M82152</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-04-22T15:09:42Z</dc:date>
    </item>
  </channel>
</rss>

