Hi all,


I have the first observation for each id for experience, and I would like to replace the value of experience +1 for the next years.
So for 2002 if would be experience+1, for 2003 experience+2 etc.
I tried sorting by id and add but did not work.

Any help would be appreciated, thank you!


Code:
clear
input str7 id double year float experience
"0100003" 2001 26
"0100003" 2002  .
"0100003" 2003  .
"0100003" 2004  .
"0100003" 2005  .
"0100003" 2006  .
"0100003" 2007  .
"0100003" 2008  .
"0100003" 2009  .
"0100003" 2010  .
"0100003" 2011  .
"0100003" 2012  .
"0100003" 2013  .
"0100003" 2014  .
"0100003" 2015  .
"0100003" 2016  .
"0100003" 2017  .
"0100003" 2018  .
"0100003" 2019  .
"0100003" 2020  .
"0100005" 2001  0
"0100005" 2002  .
"0100005" 2003  .
"0100005" 2004  .
"0100005" 2005  .
"0100005" 2007  .
"0100005" 2008  .
"0100005" 2009  .
"0100005" 2010  .
"0100005" 2011  .
"0100005" 2012  .
"0100005" 2013  .
"0100005" 2014  .
"0100005" 2015  .
"0100005" 2016  .
"0100005" 2017  .
"0100005" 2018  .
"0100005" 2019  .
"0100005" 2020  .
"0100005" 2021  .
"0100006" 2002  0
"0100006" 2003  .
"0100006" 2004  .
"0100006" 2005  .
"0100006" 2008  .
"0100006" 2009  .
"0100006" 2010  .
"0100006" 2011  .
"0100006" 2012  .
"0100006" 2013  .
"0100006" 2014  .
"0100006" 2015  .
"0100006" 2016  .
"0100006" 2017  .
"0100006" 2018  .
"0100006" 2019  .
"0100006" 2020  .
"0100006" 2021  .
"0100010" 2001 14
"0100010" 2002  .
"0100010" 2003  .
"0100010" 2004  .
"0100010" 2005  .
"0100010" 2006  .
"0100010" 2007  .
"0100010" 2008  .
"0100010" 2009  .
"0100010" 2010  .
"0100010" 2011  .
"0100010" 2012  .
"0100010" 2013  .
"0100010" 2014  .
"0100010" 2015  .
"0100010" 2016  .
"0100010" 2017  .
"0100010" 2018  .
"0100010" 2019  .
"0100010" 2020  .
"0100010" 2021  .
"0100011" 2001  9

end