Hi All
I kindly request your help below.
My data consists of 'clientid' (client), 'auditorid' (auditor), year and 'tenure' (number of years auditor has audited client).
1. I would like to create new_var1 as shown below. New_var1 is such that for each client, if the last observation of tenure for an auditor is greater than or equal to 5, new_var receives an indicator 1, otherwise 0
2. new_var2 is such that, for each client, if an auditor has new_var1 =1, then the next auditor(if there is) will have an indicator of 1, otherwise 0 as shown below
3. new_var3 is such that, for each client, if the last observation of tenure for that auditor is less than 5 and there is a new auditor the following year for that same client, new_var3 receives an indicator 1, otherwise 0 as shown below
4.new_var4 is such that for each client, if an auditor has new_var3 =1, then the next auditor (if there is) will have an indicator of 1, otherwise 0 as shown below.
I kindly request your help below.
My data consists of 'clientid' (client), 'auditorid' (auditor), year and 'tenure' (number of years auditor has audited client).
1. I would like to create new_var1 as shown below. New_var1 is such that for each client, if the last observation of tenure for an auditor is greater than or equal to 5, new_var receives an indicator 1, otherwise 0
2. new_var2 is such that, for each client, if an auditor has new_var1 =1, then the next auditor(if there is) will have an indicator of 1, otherwise 0 as shown below
3. new_var3 is such that, for each client, if the last observation of tenure for that auditor is less than 5 and there is a new auditor the following year for that same client, new_var3 receives an indicator 1, otherwise 0 as shown below
4.new_var4 is such that for each client, if an auditor has new_var3 =1, then the next auditor (if there is) will have an indicator of 1, otherwise 0 as shown below.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte clientid int(auditorid year) byte(tenure new_var1 new_var2 new_var3 new_var4) 2 778 2009 1 0 0 0 0 2 778 2010 2 0 0 0 0 2 778 2011 3 0 0 0 0 2 778 2012 4 0 0 0 0 2 778 2013 5 0 0 0 0 2 778 2014 6 1 0 0 0 2 628 2015 1 0 1 0 0 2 628 2016 2 0 0 0 0 2 628 2017 3 0 0 0 0 3 801 2013 1 0 0 0 0 3 801 2014 2 0 0 0 0 3 801 2015 3 0 0 0 0 3 801 2016 4 0 0 0 0 3 801 2017 5 1 0 0 0 4 888 2010 1 0 0 1 0 4 1073 2011 1 0 0 1 1 4 875 2012 1 0 0 0 1 4 875 2013 2 0 0 0 0 4 875 2014 3 0 0 0 0 4 875 2015 4 0 0 0 0 4 875 2016 5 0 0 0 0 4 875 2017 6 1 0 0 0 5 810 2010 1 0 0 0 0 5 810 2011 2 0 0 0 0 5 810 2012 3 0 0 1 0 5 581 2013 1 0 0 0 1 5 581 2014 2 0 0 1 0 5 618 2015 1 0 0 0 1 5 618 2016 2 0 0 0 0 5 618 2017 3 0 0 0 0 6 971 2011 1 0 0 0 0 6 971 2012 2 0 0 0 0 6 971 2013 3 0 0 0 0 6 971 2014 4 0 0 0 0 6 971 2015 5 0 0 0 0 6 971 2016 6 1 0 0 0 6 254 2017 1 0 1 0 0 8 638 2010 1 0 0 0 0 8 638 2011 2 0 0 0 0 8 638 2012 3 0 0 0 0 8 638 2013 4 0 0 0 0 8 638 2014 5 0 0 0 0 8 638 2015 6 0 0 0 0 8 638 2016 7 1 0 0 0 10 495 2010 1 0 0 0 0 10 495 2011 2 0 0 0 0 10 495 2012 3 0 0 0 0 10 495 2013 4 0 0 0 0 10 495 2014 5 0 0 0 0 10 495 2015 6 0 0 0 0 10 495 2016 7 1 0 0 0 13 156 2012 1 0 0 1 0 13 475 2013 1 0 0 0 1 13 475 2014 2 0 0 0 0 13 475 2015 3 0 0 0 0 13 475 2016 4 0 0 0 0 13 475 2017 5 1 0 0 0 14 898 2012 1 0 0 0 0 14 898 2013 2 0 0 0 0 14 898 2014 3 0 0 0 0 14 898 2015 4 0 0 0 0 14 898 2016 5 1 0 0 0 14 482 2017 1 0 1 0 0 15 337 2011 1 0 0 1 0 15 400 2012 1 0 0 0 1 17 978 2009 1 0 0 0 0 17 978 2010 2 0 0 0 0 17 978 2011 3 0 0 0 0 17 978 2012 4 0 0 0 0 17 978 2013 5 1 0 0 0 17 699 2014 1 0 1 0 0 17 699 2015 2 0 0 0 0 17 699 2016 3 0 0 0 0 17 699 2017 4 0 0 0 0 18 45 2010 1 0 0 0 0 18 45 2011 2 0 0 0 0 18 45 2012 3 0 0 0 0 18 45 2013 4 0 0 0 0 18 45 2014 5 1 0 0 0 18 139 2015 1 0 1 0 0 18 139 2016 2 0 0 1 0 18 773 2017 1 0 0 0 1 19 743 2011 1 0 0 0 0 19 743 2012 2 0 0 0 0 19 743 2013 3 0 0 0 0 19 743 2014 4 0 0 0 0 19 743 2015 5 1 0 0 0 19 805 2016 1 0 1 0 0 19 805 2017 2 0 0 0 0 20 116 2011 1 0 0 0 0 20 116 2012 2 0 0 0 0 20 116 2013 3 0 0 0 0 20 116 2014 4 0 0 0 0 20 116 2015 5 1 0 0 0 20 1038 2016 1 0 1 0 0 20 1038 2017 2 0 0 0 0 end
Comment