Hi, i have a table with announcement date (anndat) and statistical period which is counts as a forecast period(statper) and i need to keep only statper that is closest to announcement date (anndat). How can I do this? I am a bit confused about the code i need to use.

Thank you in advance.

Olga
id anndat statper
1 14Feb2014 17apr2014
1 7May2014 19Sep2014
1 06Aug2014 17Nov2014
2 30Jan2015 17Sep2015
2 28Oct2015 18Oct2015