I have a dataset as follows.
Basically, in each year, each agency delivers services to some clients.
So, I would like to find how many clients that are new to the agency company in year t+1 compared to year t.
My sample spans from 2003 to 2017.
I am thinking of creating a dummy variable that equals 1 if this client is new to the agency company in year t+1 compared to year t.
However, I actually don't know how to tackle this issue.
I am looking forward for your help.
I really appreciate all your suggestions.
Thank you so much.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long client double year long agency 109181 2008 2 64675 2004 12 21178 2017 13 13550 2009 16 13550 2010 16 13550 2011 16 13550 2012 16 13550 2013 16 9481 2009 17 9481 2010 17 31578 2003 20 142541 2003 20 142541 2004 20 31578 2004 20 31578 2005 20 31578 2006 20 162956 2007 20 4496 2003 21 4496 2004 21 4496 2005 21 4496 2006 21 4496 2007 21 114834 2008 25 2581 2003 27 61877 2003 31 23153 2003 31 28285 2003 31 133730 2003 31 61880 2003 31 61028 2003 31 65670 2003 31 31418 2004 31 61028 2004 31 23153 2004 31 61880 2004 31 65670 2004 31 28285 2004 31 133730 2004 31 61877 2004 31 61877 2005 31 61028 2005 31 25789 2005 31 23153 2005 31 31418 2005 31 61880 2005 31 31418 2006 31 60888 2006 31 23153 2006 31 25789 2006 31 61880 2006 31 61253 2006 31 61028 2006 31 5888 2006 31 5888 2007 31 31418 2007 31 60888 2007 31 61253 2007 31 23153 2007 31 61880 2007 31 25789 2007 31 61028 2007 31 146071 2007 31 146071 2008 31 61028 2008 31 60888 2008 31 23153 2008 31 61880 2008 31 24781 2008 31 5888 2008 31 31418 2008 31 25789 2008 31 13484 2008 31 61028 2009 31 13484 2009 31 61880 2009 31 23153 2009 31 24781 2009 31 60888 2009 31 31418 2009 31 5888 2009 31 25789 2009 31 122916 2009 31 126020 2004 33 126020 2005 33 61610 2006 33 126020 2006 33 126020 2007 33 61610 2007 33 62046 2008 33 126020 2008 33 61610 2008 33 126020 2009 33 61610 2009 33 8176 2009 33 31738 2009 38 116903 2010 39 31738 2010 39 31738 2011 39 31738 2012 39 31738 2013 39 end
0 Response to Working with groups_Find new element in year t+1 compared to year t
Post a Comment