Hi Stata experts,

I would like to run a rolling 5-year fixed window historical panel regression starting with the first year of the sample period to the end and with fixed industry effect (ff48). Do you possibly know how to add fixed industry effect into the -rangestat- rolling regression? I will be really apprecated that in advance!

This is my dataset:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(permno fyear) float(ff48 Inew V_aip)
10001 1987 31 -.00025486574  5.374803
10001 1988 31   -.022667235  5.994856
10001 1989 31     .27767307  8.646645
10001 1990 31    .014511943  9.448002
10001 1991 31     .02056227 10.058455
10001 1992 31     .11962668  9.527263
10001 1993 31     .08478531  11.13622
10001 1994 31    .036732513 11.540134
10001 1995 31     .09014966 13.132486
10001 1996 31     .07520458 13.682534
10001 1997 31    .027721357  14.50041
10001 1998 31    -.00518379  15.95688
10001 1999 31    .034324944 15.847775
10001 2000 31     .04045259 16.063047
10001 2001 31    .014479034 21.434006
10001 2002 31     .05148184 18.261208
10001 2003 31     .02504035 14.498052
10001 2004 31   -.019113567 13.053552
10001 2005 31  -.0038112625 20.693075
10001 2006 31   -.010415178  23.62806
10001 2007 31   -.011975456  26.26866
10001 2008 31             0         .
10001 2009 31     .07914685  42.61047
10001 2010 31     .03093053   77.5947
10001 2011 31     .12666628    77.215
10001 2012 31     .09422629  77.65676
10001 2013 31     .08052262  99.48582
10001 2014 31     .06712958  91.15439
10001 2015 31   -.012140281  87.68191
10001 2016 31   -.005171608  81.96088
10005 1987 30      .3781348 1.6020927
10005 1988 30     -.1810711 -.6017088
10005 1989 30     -.1455224   .500192
10005 1990 30    -.11643836  .1881152
10008 1987 37       .204408  30.92898
10010 1987 12     .11231432  8.326125
10010 1988 12     .06663649  9.422201
10010 1989 12     .05054261 11.310566
10010 1990 12     .10119182 13.786797
10010 1991 12     .24213764 21.268665
10010 1992 12      .5559647 18.761076
10010 1993 12    .017546788 14.292902
10010 1994 12     .04017688  19.82808
10011 1989 34      .0909091 2.2761087
10011 1990 34   -.028803453  5.144608
10011 1991 34   .0002860874  3.970445
10011 1992 34     .07316551  5.957683
10011 1993 34     .07586353  11.00185
10011 1994 34     .12715423 19.569626
10011 1995 34     .07225019  41.40971
10011 1996 34     .12799267  54.94191
10012 1987 36     .03343465   .941472
10012 1988 36    .065835886       2.1
10012 1989 36      .3640013 1.4134848
10012 1990 36      .0584013 1.9598656
10012 1991 36    .014351524  .7809984
10012 1992 36     .05726042   1.90736
10012 1993 36     .09401021   7.05376
10012 1994 36     .03840654  2.750093
10012 1995 36     .07171157 13.061484
10012 1996 36       .082332  5.970317
10012 1997 36      .0996732  3.834701
10012 1998 36     .04621073 .50046074
10012 1999 36     .10174172 11.844986
10012 2000 36     .05729908  16.23216
10012 2001 36    .005248114 18.136518
10012 2002 36     .05214926  21.17378
10012 2003 36      .1680165 1.1921728
10012 2004 36       .332123 -6.476019
10013 1986 43     -.1810711 -.6549312
10015 1984 43      .2527202 10.256064
10015 1985 43      .4152678  18.35205
10016 1987 34     .01047645  411.6268
10016 1988 34    .018017886  466.9822
10016 1989 34    .024853826  436.9596
10016 1990 34     .02611605   458.196
10016 1991 34     .04128244  442.2518
10016 1992 34    .003306214  439.8621
10016 1993 21    .014929842  73.25308
10016 1994 36   -.008219238  34.93773
10016 1995 36    .006321449  74.28373
10016 1996 21    .010767601 119.01295
10016 1997 12      .0139951  92.25301
10016 1998 12    -.01380783  87.91341
10016 1999 12   -.007108844  134.7971
10016 2000 12     .05243158 151.80717
10017 1987 35     .09729575 165.37006
10018 1987 34    -.03789775   .680064
10018 1988 34    -.10606953 -.7718144
10018 1989 34     .23502925   .468384
10018 1990 34    -.02980405 1.1555264
10018 1991 34    -.04190169   1.73936
10018 1992 34   -.018299595  2.029843
10018 1993 41      .2964915 3.7178175
10018 1994 41    -.02196583  3.226048
10018 1995 41     .01983112  .7198016
10019 1987 37     .10795794  26.03073
10019 1988 37     .14190516 30.112703
10019 1989 37     .13675138  35.19497
10019 1990 37     .11970106  40.95643
end
label values ff48 ff48
label def ff48 12 "Medical Equipment", modify
label def ff48 21 "Machinery", modify
label def ff48 30 "Petroleum and Natural Gas", modify
label def ff48 31 "Utilities", modify
label def ff48 34 "Business Services", modify
label def ff48 35 "Computers", modify
label def ff48 36 "Electronic Equipment", modify
label def ff48 37 "Measuring and Control Equipment", modify
label def ff48 41 "Wholesale", modify
label def ff48 43 "Restaraunts, Hotels, Motels", modify
------------------ copy up to and including the previous line ------------------

Here are my original code but showed error:

Code:
xtset permno fyear
gen lag_V_P = l.V_P
rangestat (reg) Inew lag_V_P i.ff48, interval(fyear -4 0) by(permno)
factor variables not allowed
r(101);

Any ideas?