Hi everyone,
I've Googled till kingdom come, as well as searched through this forum for the last few hours, and despite my best tries, I can't seem to find a solution to my problem. Though I'll be the first to admit that it is probably fairly easy and right in front of me. Apologies from the outset!
I have a bunch of panel data needing to be converted to Time-Series, but for this example, I'm going to use a single observation in wide format to get the simplest form of a solution. Here's my data:
I would like to turn this into the following:
For clarity:
studyid = Identifier
med = Medication
start = The day when medication began relative to when a diagnosis was given
duration = How many days between when the medication was started and when it was ended
day_of_seizure_stop = The day seizures stopped relative to when a diagnosis was given
end = The day when medication was stopped relative to when a diagnosis was given
day = Any given day relative to when a diagnosis was given
seizure_stop = Did the seizure stop on the current day? 0/1 = "No/Yes"
days_on_med = Given the current day, how many total days has the patient been on the current medication?
Any help would be appreciated!
Thanks,
Kevin
I've Googled till kingdom come, as well as searched through this forum for the last few hours, and despite my best tries, I can't seem to find a solution to my problem. Though I'll be the first to admit that it is probably fairly easy and right in front of me. Apologies from the outset!
I have a bunch of panel data needing to be converted to Time-Series, but for this example, I'm going to use a single observation in wide format to get the simplest form of a solution. Here's my data:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long studyid str10 med float(start duration day_of_seizure_stop end) 100001 "Tylenol" 11 4 12 14 end
I would like to turn this into the following:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long studyid str10 med float(day seizure_stop days_on_med) 100001 "No Rx" 0 0 1 100001 "No Rx" 1 0 2 100001 "No Rx" 2 0 3 100001 "No Rx" 3 0 4 100001 "No Rx" 4 0 5 100001 "No Rx" 5 0 6 100001 "No Rx" 6 0 7 100001 "No Rx" 7 0 8 100001 "No Rx" 8 0 9 100001 "No Rx" 9 0 10 100001 "No Rx" 10 0 11 100001 "Tylenol" 11 0 1 100001 "Tylenol" 12 1 2 100001 "Tylenol" 13 0 3 100001 "Tylenol" 14 0 4 100001 "No Rx" 15 0 1 100001 "No Rx" 16 0 2 end
studyid = Identifier
med = Medication
start = The day when medication began relative to when a diagnosis was given
duration = How many days between when the medication was started and when it was ended
day_of_seizure_stop = The day seizures stopped relative to when a diagnosis was given
end = The day when medication was stopped relative to when a diagnosis was given
day = Any given day relative to when a diagnosis was given
seizure_stop = Did the seizure stop on the current day? 0/1 = "No/Yes"
days_on_med = Given the current day, how many total days has the patient been on the current medication?
Any help would be appreciated!
Thanks,
Kevin
Comment