Hello,
I have the following database:
I would like to sum the number of different actors of the two columns (actor_id and actor_id2) by gid and year. In other words, I would like to have a column with the sum of the distincts values of the variables actor_id and actor_id2 by gid and year. When there are some missing values, I would like taking into account them as a 0. Variable ccode_GID does not change by gid (it is time invariant)
Do you think it is feasible to do it? I do not find the way. Any suggestion is more than welcome.
Best,
Diego.
I have the following database:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long gid int(year ccode_GID) long(actor_id actor_id2) 62356 1997 216 . . 62357 1997 216 . . 79599 1997 216 . . 79600 1997 216 . . 79601 1997 216 . . 80317 2012 216 2082 393 80317 2014 216 2082 393 80317 2015 216 2515 393 80317 2013 216 1795 393 80317 2012 216 2082 393 80317 2017 216 2515 393 80317 2016 216 2515 393 80317 2012 216 2082 393 80317 2016 216 2515 393 80317 2012 216 2082 393 80317 2012 216 2082 1911 80318 2012 216 2082 1911 80318 2009 216 2082 393 80318 2015 216 2515 393 80318 2012 216 2082 393 80318 2017 216 2515 393 80318 2012 216 2082 1911 80318 2002 216 2515 393 80318 2015 216 1258 393 80318 2012 216 2082 1911 80318 2014 216 2515 393 80318 1997 216 2515 393 80318 2012 216 2082 393 80318 2003 216 2515 393 80318 1998 216 2515 393 80318 2004 216 2515 392 80318 2015 216 2082 1911 80318 2012 216 32 21 80318 2013 216 2622 335 80318 2012 216 2082 1911 80318 2012 216 2082 1911 80318 2007 216 2082 1822 80318 2012 216 2082 1911 80318 2012 216 2082 1911 80318 1998 216 2515 393 80318 2014 216 2515 393 80318 2012 216 2082 1911 80318 2014 216 2515 393 80318 2017 216 2515 393 80318 2012 216 2082 1911 80318 2013 216 2515 393 80318 1997 216 2515 393 80318 2003 216 2515 393 80318 2013 216 1795 393 80318 2015 216 2082 1822 80318 2012 216 2515 393 80318 2013 216 2515 393 80319 2012 216 2082 1911 80319 2012 216 2082 1911 80320 1997 216 . . 80321 1997 216 . . 80322 1997 216 . . 80323 1997 216 . . 80324 1997 216 . . 80325 1997 216 . . 80326 1997 216 . . 80327 2012 216 2082 1911 80327 2012 216 2082 1911 80327 2012 216 2082 1911 80328 1997 216 . . 80329 1997 216 . . 80330 2004 216 2515 393 80331 1997 216 . . 80332 1997 216 . . 81037 2012 216 2082 408 81037 2003 216 2515 1727 81037 2000 216 2515 393 81037 2014 216 2515 393 81037 1998 216 1909 393 81037 2004 216 2515 1727 81037 2002 216 2515 393 81037 2012 216 2082 1911 81037 1999 216 2515 393 81037 2015 216 2082 1822 81037 1999 216 33 2095 81037 2002 216 2082 393 81037 2013 216 2082 361 81037 2015 216 2082 1911 81037 2014 216 2515 393 81037 1998 216 1909 393 81037 2000 216 2515 393 81037 2016 216 33 393 81037 2000 216 2515 393 81037 1999 216 2515 361 81037 2016 216 2082 381 81037 2000 216 2515 393 81037 2014 216 2515 393 81037 1998 216 1909 393 81037 2017 216 2548 392 81037 2000 216 2515 393 81037 2001 216 2515 393 81037 2014 216 2515 393 81037 1998 216 2515 393 81037 2012 216 2082 1822 81037 2014 216 2515 393 end
Do you think it is feasible to do it? I do not find the way. Any suggestion is more than welcome.
Best,
Diego.
Comment