Please, help me with the following issue. I have a data uploaded below. What I need is to create a "year_m"==year(date) and "month_m" after "fyrc"==month the very first time withing a given firm ("gvkey"). After twelve months (month(date)) the year should increase by one. For example, "year_m" ==1997 from 9th observations until 20th and "month_m"=1 in the 9th obs and increases to 12 at 20th obs. From 21st "year_m" should change into 1998 and "month_m" should start from 1, etc. Sometimes there are might be gaps as between observation 69 and 70. In this case "year_m"==2015 from 63 obs till 73 and "month_m"=1 in the 63rd obs, increases by one until 69th, at 70th it increases by 2 (since there is a missing observation) "month_m" in the 69th obs = 7 and in 70th=9 , then continues increasing until 12.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 gvkey double fyrc float(month year) long date "001004" 5 10 1996 13453 "001004" 5 11 1996 13482 "001004" 5 12 1996 13514 "001004" 5 1 1997 13545 "001004" 5 2 1997 13573 "001004" 5 3 1997 13604 "001004" 5 4 1997 13634 "001004" 5 5 1997 13664 "001004" 5 6 1997 13695 "001004" 5 7 1997 13726 "001004" 5 8 1997 13755 "001004" 5 9 1997 13787 "001004" 5 10 1997 13818 "001004" 5 11 1997 13846 "001004" 5 12 1997 13879 "001004" 5 1 1998 13909 "001004" 5 2 1998 13937 "001004" 5 3 1998 13969 "001004" 5 4 1998 13999 "001004" 5 5 1998 14028 "003897" 12 1 2005 16467 "003897" 12 2 2005 16495 "003897" 12 3 2005 16526 "003897" 12 4 2005 16555 "003897" 12 5 2005 16587 "003897" 12 6 2005 16617 "003897" 12 7 2005 16646 "003897" 12 8 2005 16679 "003897" 12 9 2005 16709 "003897" 12 10 2005 16740 "003897" 12 11 2005 16770 "003897" 12 12 2005 16800 "003897" 12 1 2006 16832 "003897" 12 2 2006 16860 "003897" 12 3 2006 16891 "003897" 12 4 2006 16919 "003897" 12 5 2006 16952 "003897" 12 6 2006 16982 "003897" 12 7 2006 17013 "003897" 12 8 2006 17044 "003897" 12 9 2006 17073 "003897" 12 10 2006 17105 "003897" 12 11 2006 17135 "003897" 12 12 2006 17164 "005492" 6 1 2014 19754 "005492" 6 2 2014 19782 "005492" 6 3 2014 19813 "005492" 6 4 2014 19843 "005492" 6 5 2014 19873 "005492" 6 6 2014 19904 "005492" 6 7 2014 19935 "005492" 6 8 2014 19964 "005492" 6 9 2014 19996 "005492" 6 10 2014 20027 "005492" 6 11 2014 20055 "005492" 6 12 2014 20088 "005492" 6 1 2015 20118 "005492" 6 2 2015 20146 "005492" 6 3 2015 20178 "005492" 6 4 2015 20208 "005492" 6 5 2015 20237 "005492" 6 6 2015 20269 "005492" 6 7 2015 20300 "005492" 6 8 2015 20331 "005492" 6 9 2015 20361 "005492" 6 10 2015 20391 "005492" 6 11 2015 20422 "005492" 6 12 2015 20453 "005492" 6 1 2016 20482 "005492" 6 3 2016 20544 "005492" 6 4 2016 20573 "005492" 6 5 2016 20605 "005492" 6 6 2016 20635 "005492" 6 7 2016 20664 "005492" 6 8 2016 20697 "005492" 6 9 2016 20727 "005492" 6 10 2016 20758 "005492" 6 11 2016 20788 "005492" 6 12 2016 20818 end format %d date
0 Response to Creating fiscal month given fiscal year end month
Post a Comment