Hi there,
I have read quite some posts on the topic but I don't seem to find a solution. Please consider the sample below.
In this sample, I have one collaborator ("10065968") which is associated with two inventors (as also indicated by count_invid). In some years, the collaborator is active (case_collab!="") while neither of the inventors is (case_invid==""), in this case in 1997.
Using expand I duplicated (by a factor count_invid) such years in order to be able to have one of these observation per inventor, tag indicates the duplicated observation in this case. Since I am running an analysis at the dyadic level inventor-collaborator, I would like to associate the activity of the collaborator in year 1997 to each of the two inventors, as in "wanted".
In my dataset, I have up to 15 inventors per collaborator so I would need a scalable way to do so.
Thank you so much for any suggestion you can provide,
Best wishes,
Giovanna Capponi
clear
input str10 case_invid str23(inventor wanted) float year str23 collaborator str10 case_collab float count_invid byte tag
"" "" "10000709" 1997 "10065968" "12954" 2 1
"" "" "10158528" 1997 "10065968" "12954" 2 0
"25766" "10000709" "10000709" 2000 "10065968" "" 2 0
"25763" "10000709" "10000709" 2000 "10065968" "" 2 0
"25915" "10000709" "10000709" 2001 "10065968" "" 2 0
"25982" "10000709" "10000709" 2001 "10065968" "" 2 0
"29357" "10000709" "10000709" 2001 "10065968" "" 2 0
"44819" "10000709" "10000709" 2004 "10065968" "48769" 2 0
"44803" "10000709" "10000709" 2004 "10065968" "44803" 2 0
"44819" "10000709" "10000709" 2004 "10065968" "44803" 2 0
"44803" "10000709" "10000709" 2004 "10065968" "48769" 2 0
"44819" "10000709" "10000709" 2004 "10065968" "48471" 2 0
"44803" "10000709" "10000709" 2004 "10065968" "48770" 2 0
"44819" "10000709" "10000709" 2004 "10065968" "48770" 2 0
"44803" "10000709" "10000709" 2004 "10065968" "48471" 2 0
"44803" "10000709" "10000709" 2004 "10065968" "48927" 2 0
"44819" "10000709" "10000709" 2004 "10065968" "48927" 2 0
"44819" "10000709" "10000709" 2004 "10065968" "44819" 2 0
"44803" "10000709" "10000709" 2004 "10065968" "44819" 2 0
"50217" "10000709" "10000709" 2005 "10065968" "50217" 2 0
"50217" "10000709" "10000709" 2005 "10065968" "50213" 2 0
"60823" "10000709" "10000709" 2007 "10065968" "62944" 2 0
"60823" "10000709" "10000709" 2007 "10065968" "57293" 2 0
"60823" "10000709" "10000709" 2007 "10065968" "61848" 2 0
"67824" "10000709" "10000709" 2009 "10065968" "67824" 2 0
"67824" "10000709" "10000709" 2009 "10065968" "68070" 2 0
"67824" "10000709" "10000709" 2009 "10065968" "71017" 2 0
"67824" "10000709" "10000709" 2009 "10065968" "68865" 2 0
"67824" "10000709" "10000709" 2009 "10065968" "70374" 2 0
"67824" "10000709" "10000709" 2009 "10065968" "71003" 2 0
"67824" "10000709" "10000709" 2009 "10065968" "70725" 2 0
"36266" "10158528" "10158528" 2002 "10065968" "35960" 2 0
"36024" "10158528" "10158528" 2002 "10065968" "36030" 2 0
"36266" "10158528" "10158528" 2002 "10065968" "36266" 2 0
"36266" "10158528" "10158528" 2002 "10065968" "36030" 2 0
"36024" "10158528" "10158528" 2002 "10065968" "35960" 2 0
"36024" "10158528" "10158528" 2002 "10065968" "36266" 2 0
"36472" "10158528" "10158528" 2003 "10065968" "36472" 2 0
"36471" "10158528" "10158528" 2003 "10065968" "36472" 2 0
"36472" "10158528" "10158528" 2003 "10065968" "36471" 2 0
"36662" "10158528" "10158528" 2003 "10065968" "36662" 2 0
"36471" "10158528" "10158528" 2003 "10065968" "36411" 2 0
"36662" "10158528" "10158528" 2003 "10065968" "36411" 2 0
"36662" "10158528" "10158528" 2003 "10065968" "36471" 2 0
"36662" "10158528" "10158528" 2003 "10065968" "36472" 2 0
"36472" "10158528" "10158528" 2003 "10065968" "36411" 2 0
"36622" "10158528" "10158528" 2003 "10065968" "36413" 2 0
"36347" "10158528" "10158528" 2003 "10065968" "36472" 2 0
"36347" "10158528" "10158528" 2003 "10065968" "36471" 2 0
"36413" "10158528" "10158528" 2003 "10065968" "36413" 2 0
"36413" "10158528" "10158528" 2003 "10065968" "36472" 2 0
"36472" "10158528" "10158528" 2003 "10065968" "36662" 2 0
"36622" "10158528" "10158528" 2003 "10065968" "36347" 2 0
"36472" "10158528" "10158528" 2003 "10065968" "36347" 2 0
"36471" "10158528" "10158528" 2003 "10065968" "36347" 2 0
"36471" "10158528" "10158528" 2003 "10065968" "36413" 2 0
"36411" "10158528" "10158528" 2003 "10065968" "36662" 2 0
"36347" "10158528" "10158528" 2003 "10065968" "36662" 2 0
"36662" "10158528" "10158528" 2003 "10065968" "36347" 2 0
"36411" "10158528" "10158528" 2003 "10065968" "36413" 2 0
"36413" "10158528" "10158528" 2003 "10065968" "36347" 2 0
"36347" "10158528" "10158528" 2003 "10065968" "36411" 2 0
"36413" "10158528" "10158528" 2003 "10065968" "36471" 2 0
"36411" "10158528" "10158528" 2003 "10065968" "36471" 2 0
"36471" "10158528" "10158528" 2003 "10065968" "36662" 2 0
"36471" "10158528" "10158528" 2003 "10065968" "36471" 2 0
Related Posts with Fill missing values by groups
The workflow of data cleanHi! Does anyone know how to make the data cleanning process automazation? Any time I got some new or…
Wrapping up twoway plots using loopHi, Using the codes below, I could nicely plot my data and retain my plots of interest using gr comb…
Summing dollar amount for each unique id for each yearstr50 year str27 state str29 district long regno str110 donortype str109 double amount "2009-2010" "…
Calculate the difference of the value of one observation with the average value for observations in other groupsHi everyone, I have a question of how to use stata to calculate the difference of the value of one …
Issues with loop used to drop observationsHello, everyone, The data that I'm using has been delivered to us with duplicated patient IDs. Thes…
Subscribe to:
Post Comments (Atom)
0 Response to Fill missing values by groups
Post a Comment