Dear all,
I am new to Stata.
I would like to obtain the variable "change" as below.
In essence, what I need is that I need to get a variable with value of 1 if rank changes from 1 to 3 or 3 to 1 within the id.
Variable year could be with or without gaps.
My sincere and advance thank you.
I am new to Stata.
I would like to obtain the variable "change" as below.
In essence, what I need is that I need to get a variable with value of 1 if rank changes from 1 to 3 or 3 to 1 within the id.
Variable year could be with or without gaps.
My sincere and advance thank you.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(id year rank change) 1000 2000 1 . 1000 2001 1 . 1000 2002 2 . 1000 2003 2 . 1000 2004 1 . 1100 2000 1 . 1100 2001 2 . 1100 2002 1 . 1100 2005 3 1 1100 2006 3 . 1200 2000 3 . 1200 2002 3 . 1200 2004 2 . 1200 2006 1 1 1200 2007 1 . 1300 2007 3 1 1300 2008 1 1 1310 2000 2 . 1310 2001 2 . 1320 2002 2 . 1320 2003 2 . 1320 2005 3 1 1320 2006 1 1 1320 2007 3 1 end
Comment