Dear all,
I would like to assign to every patient at a particular consultation date, the most frequently visited DrID (the largest count) in 1 year preceding that particular consultation date. e.g., for a patient X11 in hospital A1Z at 01-Jan-2011, the most frequently seen doctor would be A00. likewise for a patient with ID B01 in the same hospital would be also A00.
Next, I would like to create a dummy variable that =1 if a DrID for a particular consultation date and patient is the same as the most frequently seen DrID (in the previous one year window preceding this consultation).
Next, I would like to create the percentage of dummies with a value of 1 for each hospital.
Could you please assist? I am happy to clarify any related questions.
Best regards,
T
clear
input str3(hospitalID patientID) int consdate str3 DrID byte month int year
"A1Z" "B40" 18332 "A00" 3 2010
"A1Z" "B40" 18394 "A00" 5 2010
"A1Z" "B40" 18448 "A00" 7 2010
"A1Z" "B40" 18449 "A00" 7 2010
"A1Z" "B40" 18514 "A00" 10 2010
"A1Z" "B40" 18514 "A00" 10 2010
"A1Z" "B40" 18606 "B01" 12 2010
"A1Z" "B56" 18332 "A00" 3 2010
"A1Z" "B56" 18394 "A00" 5 2010
"A1Z" "B56" 18448 "A00" 7 2010
"A1Z" "B56" 18514 "A00" 10 2010
"A1Z" "B56" 18606 "B01" 12 2010
"A1Z" "C21" 18332 "A00" 3 2010
"A1Z" "C21" 18558 "B01" 10 2010
"A1Z" "C21" 18610 "A00" 12 2010
"A1Z" "C21" 18628 "A00" 1 2011
"A1Z" "X11" 18332 "A00" 3 2010
"A1Z" "X11" 18558 "B01" 10 2010
"A1Z" "X11" 18610 "A00" 12 2010
"A1Z" "X11" 18628 "A00" 1 2011
"A1Z" "Z32" 18628 "A00" 1 2011
"A1Z" "Z33" 18514 "B01" 9 2010
"A1Z" "Z34" 18525 "A00" 9 2010
"A1Z" "Z35" 18537 "B01" 10 2010
"A1Z" "Z35" 18567 "B01" 11 2010
"A1Z" "Z35" 18606 "B01" 12 2010
"A1Z" "Z35" 18628 "A00" 1 2011
"A1Z" "Z90" 18537 "B01" 10 2010
"A1Z" "Z90" 18567 "B01" 11 2010
"A1Z" "Z90" 18606 "B01" 12 2010
"A1Z" "Z90" 18628 "A00" 1 2011
"A1Z" "Z91" 18606 "B01" 12 2010
"A2" "B41" 18514 "A00" 10 2010
"A2" "B43" 18332 "A00" 3 2010
"A2" "B43" 18394 "A00" 5 2010
"A2" "B43" 18448 "A00" 7 2010
"A2" "B43" 18448 "A00" 7 2010
"A2" "B43" 18514 "A00" 10 2010
"A2" "B43" 18514 "A00" 10 2010
"A2" "B43" 18606 "B01" 12 2010
"A2" "Z91" 18606 "B01" 12 2010
"A2" "Z92" 18606 "B01" 12 2010
end
I would like to assign to every patient at a particular consultation date, the most frequently visited DrID (the largest count) in 1 year preceding that particular consultation date. e.g., for a patient X11 in hospital A1Z at 01-Jan-2011, the most frequently seen doctor would be A00. likewise for a patient with ID B01 in the same hospital would be also A00.
Next, I would like to create a dummy variable that =1 if a DrID for a particular consultation date and patient is the same as the most frequently seen DrID (in the previous one year window preceding this consultation).
Next, I would like to create the percentage of dummies with a value of 1 for each hospital.
Could you please assist? I am happy to clarify any related questions.
Best regards,
T
clear
input str3(hospitalID patientID) int consdate str3 DrID byte month int year
"A1Z" "B40" 18332 "A00" 3 2010
"A1Z" "B40" 18394 "A00" 5 2010
"A1Z" "B40" 18448 "A00" 7 2010
"A1Z" "B40" 18449 "A00" 7 2010
"A1Z" "B40" 18514 "A00" 10 2010
"A1Z" "B40" 18514 "A00" 10 2010
"A1Z" "B40" 18606 "B01" 12 2010
"A1Z" "B56" 18332 "A00" 3 2010
"A1Z" "B56" 18394 "A00" 5 2010
"A1Z" "B56" 18448 "A00" 7 2010
"A1Z" "B56" 18514 "A00" 10 2010
"A1Z" "B56" 18606 "B01" 12 2010
"A1Z" "C21" 18332 "A00" 3 2010
"A1Z" "C21" 18558 "B01" 10 2010
"A1Z" "C21" 18610 "A00" 12 2010
"A1Z" "C21" 18628 "A00" 1 2011
"A1Z" "X11" 18332 "A00" 3 2010
"A1Z" "X11" 18558 "B01" 10 2010
"A1Z" "X11" 18610 "A00" 12 2010
"A1Z" "X11" 18628 "A00" 1 2011
"A1Z" "Z32" 18628 "A00" 1 2011
"A1Z" "Z33" 18514 "B01" 9 2010
"A1Z" "Z34" 18525 "A00" 9 2010
"A1Z" "Z35" 18537 "B01" 10 2010
"A1Z" "Z35" 18567 "B01" 11 2010
"A1Z" "Z35" 18606 "B01" 12 2010
"A1Z" "Z35" 18628 "A00" 1 2011
"A1Z" "Z90" 18537 "B01" 10 2010
"A1Z" "Z90" 18567 "B01" 11 2010
"A1Z" "Z90" 18606 "B01" 12 2010
"A1Z" "Z90" 18628 "A00" 1 2011
"A1Z" "Z91" 18606 "B01" 12 2010
"A2" "B41" 18514 "A00" 10 2010
"A2" "B43" 18332 "A00" 3 2010
"A2" "B43" 18394 "A00" 5 2010
"A2" "B43" 18448 "A00" 7 2010
"A2" "B43" 18448 "A00" 7 2010
"A2" "B43" 18514 "A00" 10 2010
"A2" "B43" 18514 "A00" 10 2010
"A2" "B43" 18606 "B01" 12 2010
"A2" "Z91" 18606 "B01" 12 2010
"A2" "Z92" 18606 "B01" 12 2010
end
Comment