Dear All, I found this question here (https://bbs.pinggu.org/thread-7644841-1-1.html). The data is
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long stkcd float year long reportdate float(rptyear rptday) long insid float feps
2 2011 20110210 2011 210   1093  .76
2 2011 20110106 2011 106  10202 .778
2 2011 20110308 2011 308  10416 .925
2 2011 20110407 2011 407  10416 .925
2 2011 20110323 2011 323  10416 .925
2 2011 20110420 2011 420  10416 .925
2 2011 20110419 2011 419  10512  .89
2 2011 20110308 2011 308  10823  .96
2 2011 20110420 2011 420  10823   .9
2 2011 20110307 2011 307 101434 .895
end
For each `stkcd', each `year', and each institution `insid' (probably with more than one observation), how can I keep the (only one) observation `feps' with date (`reportdate') nearest to 4/30? For example, for `insid'=10823, there are two observations of `feps' (.96 and .9). In this case, I'd like to keep `feps'=.9 (reportfate=20110420).