Dear all:

Sorry for bothering you. I have a problem when I use stata, could you give me some adive? So, I am using time series data, tr and afd are two variables, i is one of all the periods, and I want to replace the tr(i) by tr(i-1)*afd(i) in a loop for i from 1 to the whole periods, but I can't make it after several tries. The code is as follows.
Code:
 set trace on
local j =_N
forvalues i=1(1)`j'{
    local k = `i'-1
      replace tr = tr[`k']*afd[`i']
}
set trace off
Best wishes,
Xinkai Mao