If you do this sort of operation a lot, you may want to try -carryforward-.

Though, on second thought, for this particular example, table was
part of the key, and is partially lost. So, before you can run
-carryforward-, you need to reconstruct a key -- which is the same
as, or equivalent to restoring table. Notice that, once table has
been partially wiped out, the dataset is in a precarious state: there
is nothing to tie observations into appropriate groups aside from
their present order. That's the reason behind Nick's suggestion to
clone the table variable beforehand, and his warning about an
"injudicious sort" afterwards.

But for those who may be interested in carryforward, see...
ssc desc carryforward
ssc inst carryforward