Firstly, Happy Holidays to everyone

Now my problem. I need to run a cross-sectional regression by year and by size-based peer groups. Size-based peer groups are chosen by matching the year and the 50 adjacent observations (25 firms with a lower value of total assets and 25 firms with a higher value of total assets.
Can anyone please suggest how I can generate those peer groups and run the regression?
I am using Stata 14.2

Thank you.