I suggest that you think of your problem slightly differently, namely that you have new values of t
for which s
is not known; your interpolation rule is to replace by the previous known value of s
. The procedure in Stata terms is written up in this Stata FAQ.
. list, sep(0)
+------------+
| t s |
|------------|
1. | .5 .9 |
2. | 1.2 .85 |
3. | 1.5 .8 |
4. | 1.5 .8 |
5. | .7 . |
6. | .8 . |
7. | 1.25 . |
8. | 1.3 . |
+------------+
. sort t s
. replace s = s[_n-1] if missing(s)
(4 real changes made)
. list, sep(0)
+------------+
| t s |
|------------|
1. | .5 .9 |
2. | .7 .9 |
3. | .8 .9 |
4. | 1.2 .85 |
5. | 1.25 .85 |
6. | 1.3 .85 |
7. | 1.5 .8 |
8. | 1.5 .8 |
+------------+
Note: sort
ing on t
then s
allows known s
values to be copied for the same t
.