Replacing observations with a previous set observation

I have three columns. One identifies the observations by F. The other column orders each observation within the same F, called T. The third column is a numerical value, called Q. I'd like all my values for Q passed a certain value of T to be replaced by the values at a fixed T, within the same F. For example, I'd like all values of Q within the same F that have T > 6 to be equal to whatever value Q has for that F has for T = 6. If an F has a Q value of 40 at T=6 and a Q value of 50 at T=7, I want that Q at T=7 to say 40 as well.

Can anyone help? Thanks.

This might not be the correct way of solving this, but it did the trick. If anyone has a better solution, please help me out.

> xtset F T
gen Q_fixed = Q
replace Q_fixed = . if T > 6
replace Q_fixed = L.Q_fixed if Q_fixed == .