Reputation: 1
I have the following data; basically, some patients have more than one record.
....
I would like to have a variable "count" which is the total number of duplicates. like below
but code I have now and the results:
data grouped;
set have;
by id notsorted;
retain count;
if first.id then count=1;
else count+1;
run;
Upvotes: 0
Views: 872
Reputation: 21264
This add a count total to each record. In this case, SQL is better here.
proc sql;
create table grouped as
select *, count(*) as count
from have
group by id;
quit;
Upvotes: 1