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?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.