Thanks so much! My dataset, however, not only have time gaps but also
may have more than one observation for a single time period. I cannot
sum them up. What can I do in this case?
I don't understand how a given ID has more than one value of var1 in
year t, unless they are being measured more frequently than annually
or there are competing measurements (e.g. multiple forecasters for
the same firm's returns). Your problem is well defined if you have
time series organized in a panel. With gaps, it becomes more
problematic. But with multiple measurements for a given (i,t), I
don't know what it is telling you, or what it means to compute a
std.dev. of the series "over time".