I have the following data set
PatientName BVAID Rank TreatmentCode TreatmentID DoseID
Tim Stuart BVA-027 3 OP_TBC 1 1
Tim Stuart BVA-041 4 OP_TBC 1 1
Tim Stuart BVA-021 7 OP_TBC 1 1
Tim Stuart BVA-048 10 OP_TBC 1 1
Tim Stuart BVA-020 14 OP_TBC 1 1
Tim Stuart BVA-024 15 OP_TBC 1 1
Tim Stuart BVA-001 16 OP_TBC 1 1
Tim Stuart BVA-013 27 OP_TBC 1 1
Tim Stuart BVA-018 28 OP_TBC 1 1
Tim Stuart BVA-051 29 OP_TBC 1 1
Tim Stuart BVA-027 3 OP_TC 2 1
Tim Stuart BVA-041 4 OP_TC 2 1
Tim Stuart BVA-048 10 OP_TC 2 1
Tim Stuart BVA-020 14 OP_TC 2 1
Tim Stuart BVA-001 16 OP_TC 2 1
Tim Stuart BVA-002 17 OP_TC 2 1
Tim Stuart BVA-019 18 OP_TC 2 1
Tim Stuart BVA-044 22 OP_TC 2 1
Tim Stuart BVA-025 23 OP_TC 2 1
Tim Stuart BVA-016 26 OP_TC 2 1
Tim Stuart BVA-013 27 OP_TC 2 1
Tim Stuart BVA-001 16 OP_SICO 3 1
Tim Stuart BVA-002 17 OP_SICO 3 1
Tim Stuart BVA-013 27 OP_SICO 3 1
I need to output the records with the smallest rank
in each TreatmentID
group however if the record was outputted in the previous TreatmentID
group I need to select the next smallest rank
and output the record for the TreamtmentID
group - I only need one record per TreatmentID
group.
This needs to be a scalable solution that I can automate.
My output file will only have tree unique records i.e. one per each group and each records is unique in BVAID
and will have the smallest rank in that group.
PatientName BVAID Rank TreatmentCode TreatmentID DoseID
Tim Stuart BVA-027 3 OP_TBC 1 1
Tim Stuart BVA-041 4 OP_TC 2 1
Tim Stuart BVA-001 16 OP_SICO 3 1
which program can handle this better SAS or R