Hi dear Statalists,

Is there any specialist who can help me to translate this statement into Stata language?

"Real capital is measured using a perpetual inventory method to the change in total real assets. In detail, for the first year of a firm, I deflate the book-value of total net assets by the GDP deflator index of that year, to derive the capital stock Kt. For successive years, if the assets rise, then the increase is deflated by GDP deflator index of the current year and added to Kt−1 to yield the corresponding
Kt. If it declines, Kt is reduced proportionately
".

There are 3 variables:
Firms ID: NPC_FIC
Net assets:net_assets
Time: Year

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input double(NPC_FIC net_assets) long Year
500001184   44919 1
500003770   61138 2
500003770   57969 3
500003770   63275 1
500008310   96256 1
500008310   73796 2
500009155   59982 2
500009155   67327 3
500009155   59370 1
500017393   58679 2
500017854   23439 3
500017854   43350 1
500017854   31670 2
500019512  157548 3
500019512  176689 1
500019512  163438 2
500020809  160252 3
500020809  126492 2
500020809  122498 1
500023255   89325 2
500023255   85322 3
500023255   99930 1
500026382   31063 2
500026382   25977 3
500026382   38922 1
500027353   77661 2
500027353   64498 1
500027353   70421 3
500031300   61118 3
500031300   52147 1
500031300   56633 2
500049799  284088 2
500049799  287110 1
500049799  344532 3
500050215   38512 3
500050215   29716 1
500050215   33744 2
500053595   23446 2
500053595   19209 1
500053595   14521 3
500064048   94845 2
500064048   55010 3
500065618   61630 2
500065618   25735 3
500065618   55636 1
500070877   50973 2
500070877   46849 1
500078904   68221 1
500099588   61236 1
500135017   99415 3
500135017  212079 2
500135017  235884 1
500139105   79616 2
500139105   83408 3
500139105   70517 1
500139975  137454 2
500139975  132500 3
500139975  148598 1
500147640   45548 3
500147640   37948 1
500147640   41767 2
500149500   26781 1
500149500   27143 2
500149500   22076 3
500151382   49092 2
500151382   49997 3
500151382   48160 1
500153802  174887 1
500154496  417734 1
500154496  507248 3
500154496  430522 2
500158809    9214 1
500161453   33418 1
500161453   34797 2
500161507   52535 2
500161507   62570 1
500163048  114765 2
500163048  104426 1
500172549   50973 2
500172549   46849 1
500172549   55010 3
500175326   45281 2
500175326   40174 3
500175326   41348 1
500176954   53064 3
500176954   61375 1
500176954   41556 2
500183497 1384585 1
500184653   16756 3
500184653   21492 2
500184653   30183 1
500188587   77132 2
500188587   89137 1
500188587   65669 3
500205042   99415 3
500205042   94589 1
500205042  113892 2
500206942  207308 2
500206942  216322 1
500206942  114769 3
end
label values Year Year
label def Year 1 "2010", modify
label def Year 2 "2011", modify
label def Year 3 "2012", modify
Listed 100 out of 1067068 observations

I used this code but I am not sure about its accuracy. Any ideas appreciated.
Code:
xtset NPC_FIC Year, delta(1)
gen delta_K = net_assets - l.net_assets
gen delta_K_per = (delta_K/l.net_assets) + 1, after(delta_K)
gen real_delta_k = .
replace real_delta_k = delta_K/(GDPdeflator/100) if delta_K>0
replace real_delta_k = delta_K/(95.81/100) if delta_K>0
Cheers,
Paris