Hi there,
I am working with panel data and would like to be able to flag if, for each individual in the dataset, opioids were prescribed before anticonvulsants. I have dates and order of prescription, but would like to create an indicator variable that tells me whether opioids were prescribed first (e.g.: 'opioid_first'==1 if yes; ==0 if not). Any help is greatly appreciated.
Data example below:
I am working with panel data and would like to be able to flag if, for each individual in the dataset, opioids were prescribed before anticonvulsants. I have dates and order of prescription, but would like to create an indicator variable that tells me whether opioids were prescribed first (e.g.: 'opioid_first'==1 if yes; ==0 if not). Any help is greatly appreciated.
Data example below:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte claimant_id strL(medicine_type date_dispensed) float order 10 "opioid" "10feb2014" 1 10 "irrelevantdrug" "12feb2013" 2 10 "anticonvulsant" "14feb2014" 3 12 "anticonvulsant" "1jan2015" 1 12 "opioid" "2jan2015" 2 12 "opioid" "5jan2015" 3 20 "irrelevantdrug" "20dec2016" 1 20 "irrelevantdrug" "21dec2016" 2 20 "irrelevantdrug" "22dec2016" 3 20 "opioid" "24dec2016" 4 21 "anticonvulsant" "10oct2017" 1 21 "opioid" "11oct2017" 2 21 "anticonvulsant" "12oct2017" 3 21 "opioid" "13oct2017" 4 end
Comment