I want to create a variable that is based on consecutive observations in my panel data. If an observation is the first in a consecutive series of 5 observations, it should be 1. If it is the second, it should be 2, etc.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte companyno int year byte newvar 1 2000 1 1 2001 2 1 2002 3 1 2006 0 2 2010 1 2 2011 2 2 2013 0 2 2015 1 2 2016 2 3 1999 0 3 2001 1 3 2002 2 end
Many thanks.
0 Response to Generating a variable based on consecutive observations
Post a Comment