I have a dataset with a set of variables labeled t0_X t1_X ... t12_X
I want to perform a set of operations on t*_X using both the current index number of t*_X and the previous index number (t-1)*_X.
I have a forvalues command as follows:
forvalues i=1(1) 12 {
gen t`i'_Y=t`i"_X-t`z'_X where `z'==`i'-1.
However this doesn't work. I tried a number of options but couldn't get this to work (for example I tried a "forvalues z=`i'-1 (1) 11 { " which gave me an error message.
Any help would be appreciated.
Zeev
I want to perform a set of operations on t*_X using both the current index number of t*_X and the previous index number (t-1)*_X.
I have a forvalues command as follows:
forvalues i=1(1) 12 {
gen t`i'_Y=t`i"_X-t`z'_X where `z'==`i'-1.
However this doesn't work. I tried a number of options but couldn't get this to work (for example I tried a "forvalues z=`i'-1 (1) 11 { " which gave me an error message.
Any help would be appreciated.
Zeev
Comment