I have a database including id, revenue and year between 2010 and 2015.
I want to set up a dummy. If at least any one of the first three years of REVENUE values is greater than 0 under each id, set the dummy variable to 1, otherwise 0.
I posted an example, and I filled in the dummy variable manually in order to help you understand what I mean. I have a large sample, so I want to know which Stata commands I can use to fulfil my intentions. Thank you in advance.
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
Listed 23 out of 23 observations
I want to set up a dummy. If at least any one of the first three years of REVENUE values is greater than 0 under each id, set the dummy variable to 1, otherwise 0.
I posted an example, and I filled in the dummy variable manually in order to help you understand what I mean. I have a large sample, so I want to know which Stata commands I can use to fulfil my intentions. Thank you in advance.
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte id long revenue int year float dummy 1 0 2010 0 1 0 2012 0 2 0 2010 0 2 0 2011 0 2 0 2012 0 2 9000 2013 0 2 0 2014 0 2 0 2015 0 3 13000 2010 1 3 16500 2011 1 3 0 2012 1 3 0 2013 1 3 18100 2014 1 3 0 2015 1 4 15000 2010 1 4 39000 2011 1 5 0 2014 0 6 434573 2010 1 6 210080 2011 1 6 404003 2012 1 6 474938 2013 1 6 294145 2014 1 6 319562 2015 1 end
Listed 23 out of 23 observations

Comment