Dear all,

I want to create five year average periods for my independent variables (FDI inflows) and dependent variables (components of a decomposition) (e.g instead of five variables from 1980-1985, one variable that represents the average of that period) . I would like to know, if possible, a sample code. Do I have to repeat the process for all variables or just doing it one time makes it for all?


Also, I know some codes include "collapse" which makes me lose a lot of the information contained by deleting some columns. Also, I am including my dta file if somebody could give me a help. Thank you so much!!!


dataex FDIinflow L1FDIinflow

----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double FDIinflows float L1FDIinflows
  .26415        .
   .3091   .26415
  .18721    .3091
  .23238   .18721
  .03692   .23238
  .10761   .03692
  .44733   .10761
  .23356   .44733
  .39215   .23356
  .27869   .39215
  .82921   .27869
  .98874   .82921
   .2608   .98874
  .19645    .2608
  .26928   .19645
    .962   .26928
  .50028     .962
 -.01611   .50028
  .83411  -.01611
 1.23789   .83411
 1.19855  1.23789
 1.18634  1.19855
 1.78719  1.18634
 1.08861  1.78719
  1.3016  1.08861
  2.0055   1.3016
 2.35519   2.0055
 2.88483  2.35519
 2.24926  2.88483
 7.80316  2.24926
 3.38094  7.80316
  .74352  3.38094
 1.94324   .74352
 1.17628  1.94324
 2.48554  1.17628
 2.62447  2.48554
 2.36244  2.62447
 2.23401  2.36244
 2.65984  2.23401
 1.19431  2.65984
 2.65722  1.19431
 2.04466  2.65722
 1.95664  2.04466
  .17363  1.95664
 1.26733   .17363
  .35402  1.26733
 2.05838   .35402
 2.56782  2.05838
 1.83914  2.56782
 2.17758  1.83914
 2.30824  2.17758
 1.33183  2.30824
 1.33546  1.33183
   1.947  1.33546
  .78768    1.947
  .17858   .78768
   .1734   .17858
  .24247    .1734
  .32663   .24247
  .88331   .32663
  .69384   .88331
  .76336   .69384
 1.37645   .76336
 1.79104  1.37645
 2.16341  1.79104
  2.1553  2.16341
 2.17684   2.1553
 5.57397  2.17684
 5.80374  5.57397
10.77502  5.80374
12.07474 10.77502
 12.1965 12.07474
 8.76896  12.1965
 8.66873  8.76896
 8.55824  8.66873
 2.44236  8.55824
  .97411  2.44236
-2.49887   .97411
 2.45256 -2.49887
 2.79186  2.45256
 3.07403  2.79186
 2.43961  3.07403
 3.27204  2.43961
 3.58442  3.27204
 1.11235  3.58442
 1.14157  1.11235
  .90847  1.14157
 1.64735   .90847
 1.31454  1.64735
 1.11317  1.31454
   1.089  1.11317
 1.22902    1.089
 1.29162  1.22902
 1.29385  1.29162
  .99945  1.29385
 1.11807   .99945
 1.30461  1.11807
  .77826  1.30461
  .85755   .77826
  .75664   .85755
end