Dear all,
I'm working on the following sample.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str6 company double year float earnings double decile
"001166" 2006      .1574603  6
"001166" 2007     .17622428  3
"001166" 2008      .0848003  7
"001166" 2009     .04289107 10
"001166" 2010      .3290127  6
"001166" 2011     .19211413  4
"001166" 2012     .05785522  8
"001166" 2013   -.008499536  1
"001166" 2014     .04031636  6
"001166" 2015     .05215391  5
"001166" 2016    .030050375  5
"001166" 2017     .04415479 10
"001166" 2018     .05634042 10
"001491" 2005     .04122434  4
"001491" 2006     .07826556  9
"001491" 2007     .06048017  8
"001491" 2008    .011324465  6
"001491" 2009   -.000723325  8
"001491" 2010    .013932136  6
"001491" 2011   -.013726063  8
"001491" 2012    .005304825  1
"001491" 2013    -.01955572  1
"001491" 2014   -.020802936  2
"001491" 2015    .005364127  1
"001491" 2016     .02345395  7
"001491" 2017      .0419029  7
"001491" 2018     .06463527  5
end
Within each decile, I would like to estimate annual cross-sectional regression of year-ahead earnings on current earnings. At this purpose, I would like to estimate the following regression separately for each decile each year:
earnings(t+1)=a+w*earnings(t)
How could I do that?
Thanks for the attention.

Daniel