I have a dataset with physicians id (variable named phy_id) working in different hospitals (variable named hosp_id) in different years/months. I say that physicians are colleagues when they work together in the same hospital at the same time. Physicians may work in different hospitals at the same time and/or over time.
I would like to identify, for each physician at a given hospital in a given time, all physicians that have worked with their current colleagues in different hospitals in the past (but not with them).
Code:
clear
input str1 hosp_id period str1 phy_id
"i" 1 "A"
"i" 1 "B"
"i" 1 "C"
"i" 1 "D"
"i" 2 "A"
"i" 2 "B"
"i" 2 "C"
"i" 2 "D"
"j" 1 "B"
"j" 1 "C"
"j" 1 "E"
"j" 2 "B"
"j" 2 "C"
"j" 2 "E"
"k" 1 "B"
"k" 1 "F"
"k" 2 "G"
end
label var phy_id "physician id"
label var hosp_id "hospital id"
Consider the sample above. I have three hospitals (i, j, k), 2 periods (1, 2) and 7 physicians (A, B, C, D, E, F, G). In hospital i at periods 1 and 2 physicians A, B, C, D are colleagues. In hospital j at periods 1 and 2 physicians B, C and E are colleagues. In hospital k at period 1 physicians B and F are colleagues and at period 2 physician G works alone. Hence, I would like to identify for physician A at time 2 in hospital i, physicians E (once they worked with physicians B and C at time 1 in hospital j) and F (once he worked with physicians B at time 1 in hospital k).
Any ideas on how I can code this?
Many thanks
Paula
0 Response to identifying indirect relationships
Post a Comment