Announcement

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

  • estab problems

    Hello forum

    I am having a problem using -estab- to create an rtf.table output for some tabstats.
    I am using Stata/MP15.0

    I have data that looks like this:
    ID_Company Type_Company Industry Industry share
    A 1 (Domestic) Mining 5%
    B 1 Manuf 10%
    C 1 Mining 5%
    D 2 (Foreign) Mining 10%
    E 2 Manuf 7%
    For Type_Company, there are three levels in the categorical variable I'm interested in (1 2 7)

    I have created tabstat tables that sum the industry share by Type_Company

    Ideally I would like the following table to be in rtf format for a report:
    Domestic Foreign
    Mining 10 10
    Manuf 10 7
    my output has come however as:
    Domestic Foreign
    Mining 10
    Manuf 10
    Mining 10
    Manuf 7
    My code is as follows:


    Code:
    foreach i of numlist 1 2 7 {
    eststo `i' : estpost tabstat ind_share, by (Industry),if Type_Company== `i' , s(sum) nototal
    
     }
     esttab using test3.rtf, replace cell(sum(fmt(%9.1f)label("Share of Industry market value"))) noobs title("Table 3. shareholding by Industry") nomtitle nonumber  mlabels("Domestic" "Foreign" "Public") varlabels(`e(labels)')  varwidth(25)  addnotes(Source:  database, authors' own calculations)
     
       eststo clear
    I have checked out the forums and guides but not found anything.

    Would be most grateful for anyone's assistance
    Best
    Aroop
    Last edited by Manik Chatterjee; 01 Jan 2023, 16:09.

  • #2
    estout is from SSC (FAQ Advice #12). You need to provide a reproducible example using dataex to increase your chances of making progress.

    Code:
    dataex ind_share Industry Type_Company if inlist(Type_Company, 1, 2, 7)
    will do for

    foreach i of numlist 1 2 7 {
    eststo `i' : estpost tabstat ind_share, by (Industry),if Type_Company== `i' , s(sum) nototal
    }
    esttab using test3.rtf, replace cell(sum(fmt(%9.1f)label("Share of Industry market value"))) noobs title("Table 3. shareholding by Industry") nomtitle nonumber mlabels("Domestic" "Foreign" "Public") varlabels(`e(labels)') varwidth(25) addnotes(Source: database, authors' own calculations)

    eststo clear

    Comment


    • #3
      Thanks Andrew. Much appreciated

      Here's the code:

      Code:
      foreach i of numlist 1 2 7 {
      eststo : estpost tabstat ind_share_v, by (Industry),if Type_Company == `i' , s(sum) nototal
      
       }
       esttab using test3.rtf, replace cell(sum(fmt(%9.1f)label("Share of Industry market value"))) noobs title("Table 3. Institutional shareholding by Industry") nomtitle nonumber  mlabels("Domestic" "Foreign" "Public") varlabels(`e(labels)')  varwidth(25)  addnotes(Source: Who Owns Whom database, authors' own calculations)
      Here's the output I get:
      Domestic Foreign Public
      Share of Industry market value Share of Industry market value Share of Industry market value
      Basic Materials 0.1
      Consumer Discretionary 0.0
      Consumer Staples 0.0
      Energy 0.1 0.2 0.2
      Financials 0.2 0.3 0.3
      Health care 0.3
      Industrials 0.2 0.2
      Real Estate 0.2
      Technology 0.0
      Telecommunications 0.5
      Basic 0.5 0.0
      Materials 0.0 0.0
      Consumer 0.3 0.2
      Discretionary 0.0 0.2
      Consumer 0.1
      Staples 0.1
      Health 0.1 0.1
      care 0.0
      Here's the data using dataex:

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input long group float ind_share_v str22 Industry float Type_Company
        8   .005073443 "Basic Materials "       1
       11   .005718228 "Basic Materials "       1
       53   .005107379 "Basic Materials "       1
       73    .06649813 "Basic Materials "       1
       74  .0021237663 "Basic Materials "       2
       75    .00567984 "Basic Materials "       2
       77    .07898287 "Basic Materials "       2
       81    .00846705 "Basic Materials "       2
       82    .02968334 "Basic Materials "       2
       83    .02439862 "Basic Materials "       2
       87   .023336174 "Basic Materials "       2
       94   .006702374 "Basic Materials "       2
      107     .1136462 "Basic Materials "       2
      114    .11572058 "Basic Materials "       2
      116   .002963395 "Basic Materials "       2
      117    .01866939 "Basic Materials "       2
      128  .0022225461 "Basic Materials "       2
      129   .015952943 "Basic Materials "       2
      132 .00003393607 "Basic Materials "       2
      140   .001185358 "Basic Materials "       2
      141  .0000504021 "Basic Materials "       2
      156   .001284138 "Basic Materials "       2
      169   .012550124 "Basic Materials "       2
      504   .011640073 "Basic Materials "       7
        5  .0011803608 "Consumer Discretionary" 1
        6  .0018826007 "Consumer Discretionary" 1
        8   .002495193 "Consumer Discretionary" 1
       30  .0010608305 "Consumer Discretionary" 1
       32  .0007993582 "Consumer Discretionary" 1
       33  .0013745973 "Consumer Discretionary" 1
       41   .000926359 "Consumer Discretionary" 1
       54   .004019203 "Consumer Discretionary" 1
       77   .022577165 "Consumer Discretionary" 2
       78  .0016136577 "Consumer Discretionary" 2
       82  .0011878314 "Consumer Discretionary" 2
       86  .0012924203 "Consumer Discretionary" 2
       89  .0009935948 "Consumer Discretionary" 2
      105 .00018505873 "Consumer Discretionary" 2
      141 .00018505873 "Consumer Discretionary" 2
      504  .0030181375 "Consumer Discretionary" 7
        5   .015039738 "Consumer Staples"       1
       76  .0017394957 "Consumer Staples"       2
       77   .029123774 "Consumer Staples"       2
       84  .0002484994 "Consumer Staples"       2
       85  .0013915965 "Consumer Staples"       2
      101 .00004969988 "Consumer Staples"       2
      113   .025351264 "Consumer Staples"       2
      119    .02430324 "Consumer Staples"       2
      120  .0013915965 "Consumer Staples"       2
      126     .1201167 "Consumer Staples"       2
      130 .00004969988 "Consumer Staples"       2
      134 .00009939975 "Consumer Staples"       2
      135   .008697478 "Consumer Staples"       2
      139   .033050418 "Consumer Staples"       2
      158    .04641968 "Consumer Staples"       2
      168  .0010933973 "Consumer Staples"       2
        8    .04496874 "Energy"                 1
       24    .05777233 "Energy"                 1
       77    .02404578 "Energy"                 2
      503    .11663765 "Energy"                 7
      504     .0858778 "Energy"                 7
        5   .032576527 "Financials"             1
        6   .007051459 "Financials"             1
        8    .00998296 "Financials"             1
        9 .00006263114 "Financials"             1
       15   .003512254 "Financials"             1
       17   .014961133 "Financials"             1
       23  .0016916285 "Financials"             1
       24   .008272123 "Financials"             1
       29    .01274116 "Financials"             1
       30   .002707107 "Financials"             1
       31  .0007046003 "Financials"             1
       35   .013012726 "Financials"             1
       36   .004260427 "Financials"             1
       39  .0008455203 "Financials"             1
       42   .011477156 "Financials"             1
       43  .0035676744 "Financials"             1
       48   .005306483 "Financials"             1
       49  .0036508045 "Financials"             1
       51   .004609331 "Financials"             1
       65   .025534404 "Financials"             1
       67  .0015052627 "Financials"             1
       77   .008149964 "Financials"             2
       80   .004454739 "Financials"             2
       82   .006376321 "Financials"             2
       83  .0008898637 "Financials"             2
       86  .0034290026 "Financials"             2
       88   .003046581 "Financials"             2
       91   .006941378 "Financials"             2
       95  .0008474892 "Financials"             2
       97  .0008898637 "Financials"             2
      103   .036275238 "Financials"             2
      106   .003542536 "Financials"             2
      111   .001999849 "Financials"             2
      124   .003891409 "Financials"             2
      148  .0014437905 "Financials"             2
      149   .006589117 "Financials"             2
      151   .003906925 "Financials"             2
      155   .004385122 "Financials"             2
      164  .0016102296 "Financials"             2
      end

      Comment


      • #4
        I cannot replicate your problem. Here is what I get:

        Code:
        .  esttab, replace cell(sum(fmt(%9.1f)label("Share of Industry market value"))) noobs title("Table 3. Institutional shareholding by Industry") 
        > nomtitle nonumber  mlabels("Domestic" "Foreign" "Public") varlabels(`e(labels)')  varwidth(25)  addnotes(Source: Who Owns Whom database, auth
        > ors' own calculations)
        
        Table 3. Institutional shareholding by Industry
        ----------------------------------------------------------------
                                      Domestic      Foreign       Public
                                  Share of I~e Share of I~e Share of I~e
        ----------------------------------------------------------------
        Basic Materials                    0.1          0.5          0.0
        Consumer Discretionary             0.0          0.0          0.0
        Consumer Staples                   0.0          0.3             
        Energy                             0.1          0.0          0.2
        Financials                         0.2          0.1             
        ----------------------------------------------------------------
        Source: Who Owns Whom database, authors' own calculations
        I would advise that you re-install estout and try again.


        Code:
        ssc install estout, replace

        Comment


        • #5
          Thanks Andrew! will try that

          Comment

          Working...
          X