Code:
input float(firmid year firm_prod) long productid double value 1 2014 5 92029000 0 1 2015 3 85444110 0 1 2015 6 92079000 0 1 2015 2 85182100 0 1 2015 4 92021000 0 1 2015 1 42029200 0 1 2015 5 92029000 0 1 2015 7 92099200 0 1 2016 1 42029200 12.706065809481624 1 2016 2 85182100 8.36822903827628 1 2016 6 92079000 10.515777110135918 1 2016 7 92099200 5.37989735354046 1 2016 5 92029000 10.767600388351703 1 2016 3 85444110 8.797699580118923 1 2016 4 92021000 9.025335217553026 2 2012 18 94039000 0 2 2012 24 95039000 0 2 2012 11 87150000 0 2 2012 14 94017900 0 2 2012 13 94017190 0 2 2012 15 94018090 0 2 2012 20 94049040 0 2 2012 22 95010000 0 2 2012 17 94032000 0
Code:
xtset firm_prod year, yearly gen add = . replace add = 0 if value== 0 & L.value == 0 replace add = 1 if value >0 & L.value == 0 egen total_added = total(add), by(firmid year)
I have been trying to figure this out, but I'm not sure how to get around it. Thank you for your help.
0 Response to Trouble with counting
Post a Comment