Thank you for the quick reply In the original data I have the following variables Patient Id variable, a string variable that contains a drug nme, drug recieved data, strength, repetition, patient age...etc Example Patient ID Drug name recieved date strength 1 Cefrriaxone 1/1/2016 500 1 Cefrriaxone 2/1/2016 500 2 Cefaclor 5/6/2016 1000 2 Cefaclor 6/6/2016 1000 And I wanted restructure the data by transforming each different drug name in the drug name variable to a new variable and transform the date to starting date and discontinuation date (1st and last recieved date for each drug for each patient). so the data would look like this Patient ID Ceftriaxone starting date disc.date strength cefaclor startingdate2 disc.date2 str.2 1 1 1/1/2016 2/1/2016 500 2 n/p 2 2 n/a 1 5/6/2016 6/6/2016 1000
... View more