Hello,

my dataset consists of the following variables: stock_cusip (identifier for every stock), mdate (year and month), score (rating of the stock) and some other variables, who are not of interest in this case.

I do have data regarding stock_cusip and mdate on a monthly basis. However, my data for score has plenty gaps. Therefore I did use ipolate in order to smooth the missing gaps between the reported score data. I did not use the epolate option because the gaps before my first score observation and after my last score observation are sometimes several years, so that it seems more suitable to assume that the values before and after the first/last reported score remain constant.

After having smoothed missing gaps between the reported values for score, I now want to fill the time period before my first score observation with the value of that first observation. And the period after my last score observation with the value of that last observation. However, I could not find any command to do that with.

For now my code looks like this (and works)
Code:
sort stock_cusip mdate
by stock_cusip: ipolate score mdate, gen(scorenew)


How can I now fill the remaining gaps (before/after the first/last score observation) with constant values?

Thank you very much for your help

Tim Wolf