Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Esttab with replace option

    I have data that resembles the following:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(y x)
            .         .
            .         .
            .         .
            .         .
            .         .
            .         .
            .         .
    1044.9503 32.779842
    1083.7495  44.36895
    1051.0396 30.921587
    1124.6843 28.448347
    1147.2919  25.31781
    1270.4303   19.1177
    1287.5344  26.94859
    1523.3024 22.700323
      1693.77 18.574171
    1649.1504 21.904953
    1799.5853 18.966541
    1838.4067  19.59158
     3330.642         .
     3675.304         .
    3836.3884         .
     3908.767         .
      3882.49         .
     3881.557  89.68583
     3915.648  75.38895
     4301.471    57.085
     4276.583  54.32134
    4578.4014  58.38034
     5081.489  65.52627
     5469.705  63.46786
     6017.642 67.905785
     6455.397  72.47503
     6282.694   58.7573
     6356.935  61.54311
     6346.944  60.66995
     6648.205  55.94013
     6735.461  50.74709
    100976.95         .
     101754.3         .
    104829.02         .
     100018.1         .
     97753.83         .
    102634.92         .
     98716.97  49.15923
     95894.91  49.50335
     97790.18   55.9232
     98076.53  63.56779
     91798.26 67.585434
     88086.36  68.62783
     78830.27 72.384094
     71314.67  78.86789
     60769.86  79.65332
     57232.62    77.738
     58363.68  89.78181
     59419.09  100.3223
     61688.38 100.63155
    13893.522   9.68041
    14485.508 10.428596
     15479.38  10.56085
    15894.558 10.415582
     15186.13  9.827174
     14899.87 10.986375
    14085.575 11.579008
    12412.606 28.382597
      13361.4  25.93094
     14410.15  23.84762
     15518.68 23.245876
    16592.266 23.026695
    17900.707  22.66275
    18436.863   22.0609
    17168.379 19.560986
    18712.063 18.933823
     19629.35  18.44921
    19224.875  16.23786
     19482.19 14.617173
    2173.3628  23.92792
    2336.5166 23.240004
     2441.182  20.27327
     2639.949  19.00302
      2744.43  20.75825
     2924.747  23.37526
     3224.141   25.4684
     3669.443 29.356573
     4206.975 32.152668
     4673.985 29.734814
     5356.614  28.80924
     6110.226 23.358986
     7010.627 19.185635
     7558.362 15.047107
     6532.964 15.474475
     6702.848  20.83011
     7022.104 23.756853
     7511.132  27.56672
     7727.929 28.359127
     30412.08 17.916885
     31179.31 18.939194
    32055.385  19.17481
    33174.906  19.59558
    34443.867 18.353956
    end
    ------------------ copy up to and including the previous line ------------------

    I wish to run a regression of y on x, and export the regression results using the
    Code:
    esttab
    class of commands. Specifically, I run:

    Code:
    regress y x
    esttab using "table1.tex", scalar(F) stats(N vce, labels("observations" "\(R^{2}\)" ) varwidth(25) keep(x) star(+ 0.15 * 0.10 ** 0.05 *** 0.01) p  label
    I also wish to run a separate regression of y on x^2, and export the regression results, again, but I do not wish to append the existing file, or create a new file, but simply overwrite the existing one. Naturally, the replace option is suitable.


    Code:
    gen xsq=x^2
    regress y xq
    esttab using "table1.tex", scalar(F) stats(N vce, labels("observations" "\(R^{2}\)" ) varwidth(25) keep(xsq) star(+ 0.15 * 0.10 ** 0.05 *** 0.01) p  label replace
    Unfortunately, the output file, "table1.tex" is produced with this new regression column appended to the first regression above, and is thus not replacing the existing file as I would expect. Any suggestions on this are most welcome.

    Best,
    CS

  • #2
    Any suggestions?

    Many thanks,
    CS

    Comment


    • #3
      The code which you posted contains two errrors.
      Instead of "xq" it's "xsq" and a ")" is missing at the end of the stats-option.
      Please make sure that your code runs without errors when you post it. After correcting these errors, there is no problem with the replace-option, at least on Stata 14.2 with esttab version 2.0.9.

      Comment

      Working...
      X