Hello,
I have multiple rows of patient data with a repeating ID, but the data contained within each row is different. The patient ID on top is the one I'd like to remove:
data have;
studyid age sex los cause of injury
2048 34 F 3 MVA
2048 33 F 4 MCC
data want;
studyid age sex los cause of injury
2048 33 F 4 MCC
Agree with @Reeza 's solution. I am making the assumption to account for a case where there's just one studyid record
data have;
infile cards truncover;
input (studyid age sex los causeofinjury) ($);
cards;
2048 34 F 3 MVA
2048 33 F 4 MCC
;
data want;
set have;
by studyid;
if first.studyid and last.studyid or not first.studyid;
run;
Oops @Reeza the OP doesn't want the 1st record. Am i mistaken?
"The patient ID on top is the one I'd like to remove:"
@Reeza Are you assuming all by groups to have only 2 records for last.studyid alone check?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.