Dear Statalist,

This is probably a trivial question, but I couldn't find a solution for it myself.

My data is organized as panel, with firm-day share prices. Sometimes an sec-filing occurs, and when it does the date is provided.

I want to create a new variable: price_when_sec which equals the price of the share when the SEC filing happens. In the example below, it is on 16-may-1997, and equal 30.875. So, I would have price_when_sec = 30.875 in the first observation and missing for the rest.

The problem is that sec_filing doesn't happen in set intervals, (i.e. every 10 days) but sporadically.


Please let me know if you can help.


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int(gvkey day_date filing_date) double price
1004 13604 13650     30
1004 13605     .     30
1004 13606     . 29.875
1004 13607     .   29.5
1004 13608     . 29.875
1004 13611     . 29.875
1004 13612     .   29.5
1004 13613     .     30
1004 13614     . 29.875
1004 13615     .  29.75
1004 13618     . 29.625
1004 13619     .   30.5
1004 13620     .  30.75
1004 13621     .     30
1004 13622     .  30.25
1004 13625     . 29.875
1004 13626     .     30
1004 13627     . 29.625
1004 13628     .   29.5
1004 13629     . 29.125
1004 13632     . 29.125
1004 13633     . 29.375
1004 13634     .  29.75
1004 13635     .  29.75
1004 13636     . 30.625
1004 13639     . 31.875
1004 13640     . 31.625
1004 13641     .  31.25
1004 13642     .     31
1004 13643     . 31.125
1004 13646     . 31.375
1004 13647     .  31.25
1004 13648     .  31.25
1004 13649     .  30.75
1004 13650     . 30.875
end
format %tddd-Mon-YY day_date
format %tddd-Mon-YY filing_date