Announcement

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

  • esttab format LaTeX

    I'm using the -estpost- in combination with -tabstat- command to produce descriptive statistics, and output the results to my LaTeX file using -esttab-. Since the exported values are quite large it get a very messy table output. Thus I tried using the main format options for -esttab- but that doesn't work, neither in the stata output not the Tex-file.

    Code:
    estpost tabstat Assets Debt MarketCap Leverage Dividend Price, s(n mean min max sd) col(stat)
    esttab . using "C:\Users\...\Panel_Constituents.tex", ///
    c("mean min max sd") lab nomtitles nodepvars nonumbers replace
    If possible I would like to report different formats for the variables since Assets, Debt, and MarketCap are Dollar values reaching a couple millions, and leverage is a percentage, and Divdidends and Price are just small numbers. Could you help me with this?

    The code I use to import the Tex-file in my thesis is depicted below. This doesn't do anything specific apart from setting the imported Tex-file as a table in the middle of the page.
    Code:
    \begin{table}[H]\centering \caption{Descriptive statistics \label{Descriptives}}
        \input{C:/Users/Rob" "Sukaldi/Dropbox/Master/Msc" "Finance/Thesis/Data/Export/Panel_Constituents.tex}
    \end{table}
    The generated output from -esttab-:
    Code:
    estpost tabstat Assets Debt Leverage MarketCap Dividend Price, s(n    mean    min    max    sd)    col(stat)
    
    Summary statistics: count mean min max sd
    for variables: Assets Debt Leverage MarketCap Dividend Price
    
    e(count)    e(mean)     e(min)     e(max)      e(sd) 
        
    Assets      12946    3312285        401   3.33e+07    4558414 
    Debt      12654    1730447         49   2.49e+07    2642895 
    Leverage      12653   .5005819   .0003918   1.931789   .1812409 
    MarketCap      12850    2495014    178.332   6.82e+07    4773972 
    Dividend      10756   .5565929   .0007625   507.3009   6.730515 
    Price      12856   30.91611   .0230965     2092.5   75.46368

  • #2
    Hi Rob,

    a data example (ideally created using -dataex-, as requested in the FAQ) would have helped to quickly solve the problem.

    I guess what you're looking after is the -fmt()- sub-option to the -cells()- option of estout; it can take several formatting arguments, as documented in the corresponding help file, to use different formats for different variables in the model:
    Code:
    sysuse auto , clear
    estpost tabstat foreign price , statistics(n mean min max sd) columns(statistics)
    esttab . , ///
    c("mean(fmt(%3.1f %7.2f)) min max sd") lab nomtitles nodepvars nonumbers replace tex
    Kind regards
    Bela

    Comment


    • #3
      Thanks for the quick reply, I completely forgot the -dataex-, sorry. Here it is. For some reason it doesn't work for me...

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input double(Assets Debt MarketCap) float Leverage double(Dividend Price)
       410935  202361 187408.26627448498  .4924404  .1250842  7.139421
       402185  197900   203958.342953316  .4920621  .1250842  7.716732
       406680  199691   248302.140301969 .49102736   .139517  8.804003
       405421  198777   299992.979799333  .4902977   .139517 10.564803
       388184  190444    342614.25718032  .4906024   .139517 12.027326
       396059  188211 410516.34682172403  .4752095  .1539498 13.576446
       422876  214738   400438.562429883  .5078037  .1539498 13.220437
       433177  225004   432160.260952495  .5194274  .1539498 14.192245
       636731  285650 510852.37557309197  .4486196  .1539498 15.683633
       429063  173000   504818.880799904  .4032042  .1659771 15.471952
       458900  204639   586449.274704319  .4459338  .1659771 17.944771
       466328  206798   567422.594597408  .4434604  .1659771 17.309728
       841591  424800    632435.99310398 .50475824  .1659771 19.291831
       732712  392307   747900.879585898 .53541774  .1780044 22.659482
       761191  375556    751407.81066864  .4933794  .1780044 22.755701
       780224  402103  810186.0027768001 .51536864  .1780044 24.535745
       851692  447402  794959.2622965841  .5253096  .1780044 24.073896
       841499  452265   837655.153037868  .5374516  .1924372 25.084191
       879654  465009   834785.559089418 .52862716  .1924372 24.968729
       934995  500916   872906.186264453  .5357419  .1924372 26.104109
       999012  517903   824244.073647246  .5184152  .1924372 24.641586
      1196555  666030  779175.5954881499   .556623  .4161455 23.236794
      1234104  678836   748925.646371552 .55006385  .2020591 22.274608
      1293595  744697   817883.833218272  .5756802  .2020591 24.324064
      1291383  755271       479888.41287 .58485436  .2020591     14.27
      1398064  864584 359753.26999999996  .6184152   .255584     10.61
      1395294  800818 517758.74999999994  .5739421       .21     13.05
      1397367  807210          598068.02   .577665       .18     15.07
      1382464  780197  671206.9936599999  .5643525       .18     16.87
      1360172  754701  716515.2669599999   .554857       .18     17.86
      1462233  809462       675208.43898 .55357933       .18     16.82
      1490748  832151         764700.885  .5582104       .18        19
      1524806  854924         734242.536 .56067723       .18     18.24
      1561041  893086       762879.10952  .5721093       .18     18.92
      1612867  870541       819936.67078 .53974754       .18     20.33
      1606467  871223        754231.4571  .5423224       .18      18.7
      1653319  788840       857689.61264  .4771251       .18     20.14
      1726736  812630        982113.4435 .47061625       .18     22.54
      1854264  854854       1059411.4183 .46102065       .18     23.18
      1899583  872173 1169978.6620800002  .4591392       .18     24.82
      1908440  737186      1316263.55784 .38627675       .18     25.08
      2295869 1111499 1513863.9160499999    .48413       .18     27.77
      2310544 1102345      1368931.59351  .4770933       .21     24.69
      2349368 1125981      1368477.76608  .4792697       .21     24.68
      2264957 1039997 1381617.3784400001 .45916855       .21     24.83
      2345862 1108684      1496794.31482  .4726126       .23     26.38
      2372196 1074029      1661574.53953  .4527573       .23     28.09
      2454651 1141066      1657036.98622  .4648587       .23     27.58
      2720721 1118602      2181540.46261 .41114175       .23     32.03
      2870866 1304739      2397361.03328  .4544758       .54     34.88
      2973699 1326667       2003599.3816  .4461336       .24     29.11
      2968084 1317253 2075454.7643900001  .4438058       .24     30.07
      3032319 1358606      2329066.45725  .4480419       .24     33.15
      3148327 1296558      2514129.63441  .4118244        .5     35.13
      3235040 1314414      2655922.07712  .4063053       .25     35.52
      3578519 1295519 2930489.7609599996  .3620266       .25     36.24
      3995960 1558847      2731974.17588 .39010575       .25     32.68
      4014902 1572143      2513919.33306  .3915769       .41     30.06
      4048845 1614120       2325730.0134 .39866185       .26      27.8
       179007  137416     30580.82040288  .7676571         .   3.64144
       179096  139541 31072.528295704997  .7791408         .  3.671785
       180241  141145 32306.846208754003  .7830904         .  3.793166
       176999  135408  37297.04904134799  .7650213  .3337986  4.339382
       177739  137510    36036.069678048  .7736625         .  4.187656
       179409  139762    40161.678815915  .7790133         .  4.642835
       129453   79820 30425.160502463998  .6165944 2.7310797  3.489713
       119275   60973    42887.125836002  .5111968         .  4.909874
       129229   72942 42819.691209471996  .5644399         .  4.897736
       126104   71233    42039.731268582   .564875         .  4.794562
       109853   47163    43924.018689261  .4293283         .  5.006979
       121376   59754 44054.206913496004  .4923049         .  4.691388
       127149   66925     45246.68913177   .526351         .  4.794562
       128270   68861    45418.510138365 .53684413         .  4.812769
       127313   68645 44956.528470713005 .53918296         .  4.764217
       125755   68659 46411.884877585006  .5459743         .  4.915943
       131767   76550      45757.4671706  .5809497         .    4.8067
       130747   76275 45876.411699412005  .5833786         .  4.794562
       129335   76048    44889.198915288  .5879924         .  4.691388
       128446   76003     44152.54853861  .5917117         .   4.61249
       127451   76179 38478.507049789994   .597712         .  4.017722
       129011   76682    40266.307164301  .5943834         .  4.218001
       124643   46458 33035.566815328006  .3727285         .  3.459368
       116037   44808 23182.847539095997  .3861527  .4005584  2.427626
       113358   44709         7760.34413  .3944053         .       .77
       109021   44605        8622.586326  .4091414       .31      .853
       101970   43925         8499.73404   .430764         .       .84
       101160   43823         14645.8004  .4332048         .      1.45
        92381   43721         13172.9416  .4732683         .       1.3
        91413   43612 13150.912740000002  .4770875         .      1.29
        75445   31506      15918.4460278  .4176022         .    1.5601
        69727   31446        15611.32134  .4509874         .      1.53
        68179   31098      14929.4454452 .45612285         .    1.4599
        67562   30931        19753.77002  .4578165         .      1.93
        65481   30751 19027.460900000002  .4696171         .      1.85
        57501   30586        16147.62898  .5319212         .      1.57
        50056   24090 13186.305279999999   .481261         .      1.28
        51337   26012        15349.68349  .5066911         .      1.49
        50384   25914        14285.48538 .51432997         .      1.38
        43312   24651        14078.44936 .56914943         .      1.36
        42440   24566        12365.97687 .57884073         .      1.17
      end

      Comment


      • #4
        Please have a second look at the FAQ; "doesn't work" is not a helpful description of your problem. Please show exactly what you typed, and what Stata responded. "It works" perfectly for me, even using your data example:
        Code:
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input double(Assets Debt MarketCap) float Leverage double(Dividend Price)
         410935  202361 187408.26627448498  .4924404  .1250842  7.139421
         402185  197900   203958.342953316  .4920621  .1250842  7.716732
         406680  199691   248302.140301969 .49102736   .139517  8.804003
         405421  198777   299992.979799333  .4902977   .139517 10.564803
         388184  190444    342614.25718032  .4906024   .139517 12.027326
         396059  188211 410516.34682172403  .4752095  .1539498 13.576446
         422876  214738   400438.562429883  .5078037  .1539498 13.220437
         433177  225004   432160.260952495  .5194274  .1539498 14.192245
         636731  285650 510852.37557309197  .4486196  .1539498 15.683633
         429063  173000   504818.880799904  .4032042  .1659771 15.471952
         458900  204639   586449.274704319  .4459338  .1659771 17.944771
         466328  206798   567422.594597408  .4434604  .1659771 17.309728
         841591  424800    632435.99310398 .50475824  .1659771 19.291831
         732712  392307   747900.879585898 .53541774  .1780044 22.659482
         761191  375556    751407.81066864  .4933794  .1780044 22.755701
         780224  402103  810186.0027768001 .51536864  .1780044 24.535745
         851692  447402  794959.2622965841  .5253096  .1780044 24.073896
         841499  452265   837655.153037868  .5374516  .1924372 25.084191
         879654  465009   834785.559089418 .52862716  .1924372 24.968729
         934995  500916   872906.186264453  .5357419  .1924372 26.104109
         999012  517903   824244.073647246  .5184152  .1924372 24.641586
        1196555  666030  779175.5954881499   .556623  .4161455 23.236794
        1234104  678836   748925.646371552 .55006385  .2020591 22.274608
        1293595  744697   817883.833218272  .5756802  .2020591 24.324064
        1291383  755271       479888.41287 .58485436  .2020591     14.27
        1398064  864584 359753.26999999996  .6184152   .255584     10.61
        1395294  800818 517758.74999999994  .5739421       .21     13.05
        1397367  807210          598068.02   .577665       .18     15.07
        1382464  780197  671206.9936599999  .5643525       .18     16.87
        1360172  754701  716515.2669599999   .554857       .18     17.86
        1462233  809462       675208.43898 .55357933       .18     16.82
        1490748  832151         764700.885  .5582104       .18        19
        1524806  854924         734242.536 .56067723       .18     18.24
        1561041  893086       762879.10952  .5721093       .18     18.92
        1612867  870541       819936.67078 .53974754       .18     20.33
        1606467  871223        754231.4571  .5423224       .18      18.7
        1653319  788840       857689.61264  .4771251       .18     20.14
        1726736  812630        982113.4435 .47061625       .18     22.54
        1854264  854854       1059411.4183 .46102065       .18     23.18
        1899583  872173 1169978.6620800002  .4591392       .18     24.82
        1908440  737186      1316263.55784 .38627675       .18     25.08
        2295869 1111499 1513863.9160499999    .48413       .18     27.77
        2310544 1102345      1368931.59351  .4770933       .21     24.69
        2349368 1125981      1368477.76608  .4792697       .21     24.68
        2264957 1039997 1381617.3784400001 .45916855       .21     24.83
        2345862 1108684      1496794.31482  .4726126       .23     26.38
        2372196 1074029      1661574.53953  .4527573       .23     28.09
        2454651 1141066      1657036.98622  .4648587       .23     27.58
        2720721 1118602      2181540.46261 .41114175       .23     32.03
        2870866 1304739      2397361.03328  .4544758       .54     34.88
        2973699 1326667       2003599.3816  .4461336       .24     29.11
        2968084 1317253 2075454.7643900001  .4438058       .24     30.07
        3032319 1358606      2329066.45725  .4480419       .24     33.15
        3148327 1296558      2514129.63441  .4118244        .5     35.13
        3235040 1314414      2655922.07712  .4063053       .25     35.52
        3578519 1295519 2930489.7609599996  .3620266       .25     36.24
        3995960 1558847      2731974.17588 .39010575       .25     32.68
        4014902 1572143      2513919.33306  .3915769       .41     30.06
        4048845 1614120       2325730.0134 .39866185       .26      27.8
         179007  137416     30580.82040288  .7676571         .   3.64144
         179096  139541 31072.528295704997  .7791408         .  3.671785
         180241  141145 32306.846208754003  .7830904         .  3.793166
         176999  135408  37297.04904134799  .7650213  .3337986  4.339382
         177739  137510    36036.069678048  .7736625         .  4.187656
         179409  139762    40161.678815915  .7790133         .  4.642835
         129453   79820 30425.160502463998  .6165944 2.7310797  3.489713
         119275   60973    42887.125836002  .5111968         .  4.909874
         129229   72942 42819.691209471996  .5644399         .  4.897736
         126104   71233    42039.731268582   .564875         .  4.794562
         109853   47163    43924.018689261  .4293283         .  5.006979
         121376   59754 44054.206913496004  .4923049         .  4.691388
         127149   66925     45246.68913177   .526351         .  4.794562
         128270   68861    45418.510138365 .53684413         .  4.812769
         127313   68645 44956.528470713005 .53918296         .  4.764217
         125755   68659 46411.884877585006  .5459743         .  4.915943
         131767   76550      45757.4671706  .5809497         .    4.8067
         130747   76275 45876.411699412005  .5833786         .  4.794562
         129335   76048    44889.198915288  .5879924         .  4.691388
         128446   76003     44152.54853861  .5917117         .   4.61249
         127451   76179 38478.507049789994   .597712         .  4.017722
         129011   76682    40266.307164301  .5943834         .  4.218001
         124643   46458 33035.566815328006  .3727285         .  3.459368
         116037   44808 23182.847539095997  .3861527  .4005584  2.427626
         113358   44709         7760.34413  .3944053         .       .77
         109021   44605        8622.586326  .4091414       .31      .853
         101970   43925         8499.73404   .430764         .       .84
         101160   43823         14645.8004  .4332048         .      1.45
          92381   43721         13172.9416  .4732683         .       1.3
          91413   43612 13150.912740000002  .4770875         .      1.29
          75445   31506      15918.4460278  .4176022         .    1.5601
          69727   31446        15611.32134  .4509874         .      1.53
          68179   31098      14929.4454452 .45612285         .    1.4599
          67562   30931        19753.77002  .4578165         .      1.93
          65481   30751 19027.460900000002  .4696171         .      1.85
          57501   30586        16147.62898  .5319212         .      1.57
          50056   24090 13186.305279999999   .481261         .      1.28
          51337   26012        15349.68349  .5066911         .      1.49
          50384   25914        14285.48538 .51432997         .      1.38
          43312   24651        14078.44936 .56914943         .      1.36
          42440   24566        12365.97687 .57884073         .      1.17
        end
        estpost tabstat Assets Debt MarketCap Leverage Dividend Price, statistics(n mean min max sd) columns(statistics) quietly
        esttab . , ///
        c("mean(fmt(%10.0g %10.1f %9.1f %6.3f %6.3f %5.2f)) min max sd") label nomtitles nodepvars nonumbers replace
        (Note that I only re-formatted the output of the means, you can of course also adjust minima and maxima as desired.)

        Kind Regards
        Bela

        Comment


        • #5
          Thanks for the help Bela! It did work I was just looking at the estpost output instead of the esttab in latex. That's why "nothing changed" while everything changed...

          (Note that I only re-formatted the output of the means, you can of course also adjust minima and maxima as desired.)
          I get the idea of formatting every individual value by placing -fmt()- after the specific statistic, but it seems to work on all of them even though I only place it after mean. It doesn't really matter in this case since I have no percentages or such, but I cannot figure out why.
          Code:
          estpost tabstat Assets Debt MarketCap Leverage Dividend Price, s(n mean min max sd) col(stat)
          esttab . using "C:\...\Panel_Constituents.tex", ///
          c("mean(fmt(%10.0fc %10.0fc %9.0fc %6.2fc %6.2fc %5.2fc)) min max sd") label nomtitles nodepvars nonumbers replace
          Click image for larger version

Name:	Naamloos.png
Views:	1
Size:	28.4 KB
ID:	1416786

          Last edited by Rob Sukaldi; 02 Nov 2017, 06:57.

          Comment


          • #6
            I suppose (but I can't find a mention of this in estout's help file, so only Ben Jann can confirm this) the mechanism behind this is the same as when you only specify three format parameters: estout internally copies the format information for means to the other columns.

            As a final remark: If you want your table to become even prettier, try the additional option booktabs and \usepackage{booktabs} in your TeX document.

            Regards
            Bela

            Comment

            Working...
            X