capture program drop facum
program define facum

qui by `1':  g cum`2'=sum(`2')
g cum`2'l=l.cum`2'
replace cum`2'l=0 if cum`2'l==.
drop cum`2'

end
**************************************************************
* COMMAND: FACUM NAME_INDIVIDUALS NAME_VARIABLE
* it creates the sum of the variable, and its lag replacing missing with zero
* WHEN A COMMAND, LIKE IVREG, TRANSFORM THE VARIABLE IN FIRST DIFF,
* ACTUALLY WE CAN USE THE LEVEL