Here are two data sets: data1: data2: As you can see, data2 has a new observation for each time a drug was given to each patient (including duplicates). i.e. Patient 1 received 2 unique drugs (a3, s1). What I need as an end result is a merged data set by patient_id with indicator variables of whether or not the patient received any of the available drugs. It should look like this: data3: What I first did in attempt to solve the problem was to add these indicator variables onto data2 which looks like this: data4: Now I need to consolidate all indicators into one line per patient, but can't figure out how to do so. Does anyone know what my next step could be? Or another approach starting with the initial two data sets? Thanks.
... View more