Hi,

I have a panel dataset, which includes observation for returns and turnover for the past 52 weeks. I want to extract the coefficient of LMSW_2002 in the following regression equation which is based on the 52 observations for each firm-year.

I can get the results of the regression using the following command. Unfortunately, I cannot store these result. I am looking for a solution that would run the regression for each group (Index) and store the results of the entire regression or just the coefficient of LMSW_2002.

Code:
by Index : reg Ret lagret LMSW_2002
Sample data is attached as follows
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int Index long PERMNO byte Weeks double Ret float(lagret LMSW_2002)
1 22592 -52   .03066  -.02839   .0015403944
1 22592 -51 -.029901   .03066   -.002951392
1 22592 -50  .023084 -.029901  -.0001493088
1 22592 -49 -.034812  .023084   -.008187853
1 22592 -48  .016831 -.034812   -.006448435
1 22592 -47 -.040725  .016831   .0006774608
1 22592 -46 -.048069 -.040725   -.005754218
1 22592 -45 -.000719 -.048069   -.014784833
1 22592 -44 -.010654 -.000719 .000031164695
1 22592 -43  .003201 -.010654    -.00345002
1 22592 -42  .029156  .003201   .0010735776
1 22592 -41 -.011275  .029156    .005789125
1 22592 -40   .04747 -.011275     .00033129
1 22592 -39  .000136   .04747    .001350522
1 22592 -38 -.009508  .000136  2.311508e-06
1 22592 -37 -.009408 -.009508   .0018295203
1 22592 -36 -.033659 -.009408   .0016629375
1 22592 -35  .013875 -.033659   -.001987037
1 22592 -34  .036066  .013875   .0046342714
1 22592 -33 -.044441  .036066     .02636297
1 22592 -32 -.069834 -.044441   -.008258095
1 22592 -31 -.160062 -.069834    -.02828788
1 22592 -30  .041098 -.160062    -.14564113
1 22592 -29  .055231  .041098    .026202515
1 22592 -28  .078678  .055231     .03807466
1 22592 -27  .008243  .078678    .036639154
1 22592 -26 -.027302  .008243   .0009457734
1 22592 -25  -.01964 -.027302   -.007746905
1 22592 -24  .091843  -.01964   -.009994903
1 22592 -23 -.105782  .091843   -.006197574
1 22592 -22 -.063659 -.105782    -.04772526
1 22592 -21   .01035 -.063659   -.013357646
1 22592 -20 -.015542   .01035    .000224061
1 22592 -19  .061894 -.015542    .017627724
1 22592 -18 -.024497  .061894    -.04321004
1 22592 -17 -.022861 -.024497    .010510028
1 22592 -16 -.062389 -.022861    .007009152
1 22592 -15  .016824 -.062389     .02297962
1 22592 -14 -.026027  .016824 -.00028896355
1 22592 -13  -.05669 -.026027   .0005485007
1 22592 -12 -.033566  -.05669  .00006714724
1 22592 -11 -.037884 -.033566    .006307902
1 22592 -10  -.07985 -.037884   -.002673329
1 22592  -9  .147502  -.07985   -.017015157
1 22592  -8 -.043125  .147502    .007189305
1 22592  -7  .095798 -.043125    .004106716
1 22592  -6  .035367  .095798   -.008555142
1 22592  -5  .019574  .035367   -.005936099
1 22592  -4  .012799  .019574   -.012329363
1 22592  -3  .059283  .012799   -.002809522
1 22592  -2  .015439  .059283     .00299079
1 22592  -1  .038182  .015439  -.0027095284
2 22592 -52 -.036113  .038182   -.008072878
2 22592 -51 -.023458 -.036113    .009752043
2 22592 -50   .01837 -.023458    .008100242
2 22592 -49   .06725   .01837   -.009800303
2 22592 -48  .000985   .06725   -.009077097
2 22592 -47 -.026721  .000985 -.00024920338
2 22592 -46 -.001853 -.026721    .006144799
2 22592 -45  .016706 -.001853   .0004743336
2 22592 -44 -.007635  .016706    -.00557728
2 22592 -43   .05235 -.007635   .0002223419
2 22592 -42  .103306   .05235    -.01228291
2 22592 -41  .015846  .103306    .009666022
2 22592 -40  .033749  .015846   -.003186107
2 22592 -39 -.021674  .033749  -.0039089997
2 22592 -38  .025846 -.021674   .0023565795
2 22592 -37 -.009912  .025846   -.008456712
2 22592 -36 -.007925 -.009912   .0031727066
2 22592 -35  .037141 -.007925   .0023518275
2 22592 -34  .008378  .037141    -.01484172
2 22592 -33 -.010989  .008378  -.0021790809
2 22592 -32 -.025339 -.010989   .0044569033
2 22592 -31  .038927 -.025339    .004950087
2 22592 -30  .017262  .038927   -.014910948
2 22592 -29  .023678  .017262   -.004745167
2 22592 -28 -.054613  .023678   .0022792008
2 22592 -27   .02501 -.054613  -.0026666506
2 22592 -26  .025328   .02501   -.005092273
2 22592 -25 -.002297  .025328   -.006771228
2 22592 -24  .001435 -.002297   .0007454183
2 22592 -23  .019414  .001435  -.0009510986
2 22592 -22  .044862  .019414  -.0018849007
2 22592 -21 -.009541  .044862     .01090874
2 22592 -20  .019513 -.009541   -.002094009
2 22592 -19  .001454  .019513   -.018156344
2 22592 -18  .019959  .001454  -.0007767971
2 22592 -17 -.011267  .019959   .0008321834
2 22592 -16  -.02267 -.011267    .001602538
2 22592 -15  -.01215  -.02267  -.0002425309
2 22592 -14 -.024227  -.01215   -.003120765
2 22592 -13  .008149 -.024227   -.005951347
2 22592 -12  .036298  .008149   .0018901667
2 22592 -11 -.016806  .036298   -.011348456
2 22592 -10  .028571 -.016806  -.0005825338
2 22592  -9 -.012858  .028571   -.004710372
2 22592  -8  .007127 -.012858  -.0008782291
2 22592  -7 -.011713  .007127    .001869973
2 22592  -6  .035185 -.011713    -.00105196
2 22592  -5 -.004293  .035185    .002762586
end
Thank You