lrk889
lrk889

Reputation: 119

SAS - deleting duplicates on multiple variables

I am trying to delete the observations in my data set that are the same across multiple variables.

For example

RID       Admission Date       End Date
1          Jan 1 2014         Jan 3 2014>
1         January 1           Jan 3 2014
1         March 2 2014       March 5 2014
2        July 1 2014        July 8 2014
2         July 1 2014        July 8 2014
2        August 9 2014         August 24 2014

I would want to keep all unique admissions for each RID, but delete any observations with the same RID and the same admission/end dates.

Thanks!

Upvotes: 0

Views: 609

Answers (1)

davids12
davids12

Reputation: 323

PROC SORT DATA=work.yourdatasetin OUT=work.datasetout NODUPLICATES ;
  BY rid ;
RUN ;

Something like this might also work.

proc sql;
create table work.yourdatasetout as 
select distinct
    *
from 
    work.yourdatasetin;
quit;

Upvotes: 1

Related Questions