10-21-2016 05:56 PM - edited 10-21-2016 06:19 PM
I have pharmacy claims data. I would like to keep the first record for each patient and each drug based on fill date. My data look like this:
Patid Drug Fill_date
Normally, if I was interested in only 1 drug, i would only keep those records, and then I would sort by patid and fill_date, then do something like this:
proc sort data=have; by patid drug fill_date; run;
But since I need the first patid AND drug, that will not work. How would this be done if I sorted by patid, drug, and fill_date?
10-21-2016 06:04 PM
You want each each new instance of drug in this case, so change your FIRST to be relative to the drug variable.
Make sure your BY statement has at least both variables.
10-21-2016 06:18 PM
Sorry, I need the first of the drug for each unique patient ID. Does your method still work with that requirement?