Help using Base SAS procedures

Remove duplicates for two field unique identifier

Accepted Solution Solved
Reply
Regular Contributor
Posts: 164
Accepted Solution

Remove duplicates for two field unique identifier

Hi

I am still plugging away on the readmits program and I figured it out but I want to remove multiple readmits for the same patient's episode.  If I use the following code, it works but it removes all entries for a chart number when really I only want to remove when the same chartno with the same admit date is duplicated.  So if the same chart number had a different admit date I don't want it removed.

data single dup;

set temp;

by chartno;

if first.chartno and last.chartno then output single;

else output dup;

run;

So is it possible to do have a first observation with two fields like first.chartno admdate and last.chartno admdate?  Thanks.


Accepted Solutions
Solution
‎10-25-2013 10:46 PM
Trusted Advisor
Posts: 1,137

Re: Remove duplicates for two field unique identifier

I hope, this will help you

data single dup;

set temp;

by chartno admit_date;

if first.admit_date then output single;

else output dup;

run;

Thanks,

jagadish

Thanks,
Jag

View solution in original post


All Replies
Trusted Advisor
Posts: 1,137

Re: Remove duplicates for two field unique identifier

Please try

data single dup;

set temp;

by chartno admit_date;

if first.admit_date and last.admit_date then output single;

else output dup;

run;

Thanks,

Jagadish

Thanks,
Jag
Regular Contributor
Posts: 164

Re: Remove duplicates for two field unique identifier

Posted in reply to Jagadishkatam

Thanks so much Jagadish but that didn't work.  I had a case with 3 readmits noted for one chart number, 2 were the same admit date and the third wasn't but the code wiped out all but one.

Any other suggestions?  Thanks so much.

Solution
‎10-25-2013 10:46 PM
Trusted Advisor
Posts: 1,137

Re: Remove duplicates for two field unique identifier

I hope, this will help you

data single dup;

set temp;

by chartno admit_date;

if first.admit_date then output single;

else output dup;

run;

Thanks,

jagadish

Thanks,
Jag
Regular Contributor
Posts: 164

Re: Remove duplicates for two field unique identifier

Posted in reply to Jagadishkatam

Hi

Thanks so much, that seems to have worked!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 223 views
  • 0 likes
  • 2 in conversation