Please post complete code for future questions.
Below some code that can get you started. I stick with your tsmooth ma
and make an assumption regarding the weights assigned to each member, by year. Specifically, I average the metric by year and then compute the moving average. You may want to change the weighting scheme.
clear all
set more off
input ///
str1 memberid year metric
"A" 1981 35
"A" 1983 36
"A" 1982 40
"B" 1982 29
"B" 1983 18
"C" 1980 74
"C" 1981 64
"C" 1982 98
end
sort year
list, sepby(year)
* compute mean for each year
by year: egen me = mean(metric)
* keep only one observation per year (means are repeated)
by year: keep if _n == 1
drop memberid metric
list
* compute moving average using one lag, present, and one lead
tsset year
tssmooth ma newmetric=me, window(1 1 1)
list
More succinctly, the lines
by year: egen me = mean(metric)
by year: keep if _n == 1
drop memberid metric
can be substituted for
collapse (mean) metric, by(year)