I was struggling with a quite simple thing I guess.
Code:
foreach v of varlist YSVR9909ASREPGDP - YSVR2105ASREPGDP { replace temp_`v' = `v' - `v-1' tab temp_`v' }
So if there is var1 var2 var3
I am trying to create
temp_var2 = var2-var1
temp_var3 = var3-var2
I couldn't figure this out, as pointing to a previous column was not doable with [_n-1] or L. which are only used for rows(i.e. observations).
It would be great if someone could share their knowledge on this.
Thanks much,
Ed
0 Response to Making n new variables by doing rolling difference of existing variables
Post a Comment