local money "Emax_score Smax_score Gmax_score Emin_score Smin_score Gmin_score Emean_score Smean_score Gmean_score Estd_score Sstd_score Gstd_score"
foreach x of local money {
by stock_id year, sort: replace "`x'"[_n-1] if "`x'"[_n]==. & "`x'"[_n-1]!=.
}