I have a panel dataset (panelvar is id and timevar is year). I have been trying to generate a group of new variables from tssmooth exponential funciton using forvalues. Here is my sample data.
Code:
*To install: ssc install dataex, replace clear input int year int id float roi 2015 1 0.069 2013 1 0.091 2012 1 0.158 2010 1 0.126 2011 1 0.162 2014 1 0.063 2014 2 -0.019 2015 2 -0.074 2015 3 0.256 2012 3 0.199 2013 3 0.229 2014 3 0.254 2010 3 0.188 2011 3 0.114 2014 4 0.07 2012 4 0.184 2013 4 0.117 2015 4 -0.033 2011 4 0.184 2010 4 0.148 2012 5 -0.007 2014 5 0.076 2010 5 1.004 2015 5 -0.021 2011 5 -0.034 2013 5 0.076 2011 6 0.129 2013 6 0.09 2015 6 0.163 2012 6 0.133 2010 6 0.132 2014 6 0.091 2013 7 0.048 2012 7 0.067 2010 7 0.019 2014 7 0.062 2011 7 0.093 2015 7 0.066 2015 8 0.125 2014 8 0.112 2011 8 0.186 2010 8 0.198 2012 8 0.131 2013 8 0.12 end
Code:
xtset id year forvalues x = 0.1(0.05)1 { generate `i'= 20 * `x'-1 tssmooth exponential ewma_roi_`i' = roi, parms(`x') }
Array
Thanks,
David
0 Response to Loop over values not working
Post a Comment