Announcement

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

  • Way to standardize table size using esttab?

    Hello,
    I am having a problem with two regression output tables I've created not being the same size. I am using Stata 17.0 SE - Standard Edition for Mac.

    I ran the code below to create two separate .tex files. Upon opening them in LaTex, the tables are not the same size and do not line up. They have the same number of columns and rows, the only thing different between the two tables are some variables I used in the regressions.

    Is there a way I can set dimensions in esttab so the tables are in line with each other in LaTex?

    Thank you,
    Elaine

    Code:
    ******************Intensity measure 1: High intensity state ****************
    
    * Creates intensity and cohort interaction
            genl born1970_75Xhighintensity=born1970_75*highintensity, l(Born 1970-75 * High-intensity state)
    
    * Loop for dependent variables
    foreach depvar in yrseduc numbirthbefore25 {
        
            * Regression
            eststo: reg `depvar' born1970_75Xhighintensity born1970_75 highintensity $controls $OLcohort, cl(cluster) 
            estadd local SFE "No"
            estadd local YFE "No"
            
            eststo: reg `depvar' born1970_75Xhighintensity born1970_75 i.state1970 $controls $OLcohort, cl(cluster)
            estadd local SFE "Yes"
            estadd local YFE "No"
            
            eststo: reg `depvar' born1970_75Xhighintensity i.state1970 i.respyearofbirth $controls $OLcohort, cl(cluster)
            estadd local SFE "Yes"
            estadd local YFE "Yes"
        
    }
    
    esttab using "${root}/output/tables/regression_createddata1.tex", replace f ////
     b(3) t(3) r2 nogaps nomtitles numbers varwidth(25) obslast label star(* 0.10 ** 0.05 *** 0.01) ///
     booktabs nonotes ///
    keep(born1970_75Xhighintensity born1970_75 highintensity) ///
    mgroups("Years of Schooling" "Number of kids before age 25", pattern(1 0 0 1 0 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
    scalars ("SFE" "YFE") sfmt(3) ///
    
    
    ******************Intensity measure 2: 1976 per capita funds****************
    
    est clear 
    
    * Creates intensity and cohort interaction
            genl born1970_75XOlfunds1976=born1970_75*Olfunds1976, l(Born 1970-75 * Classroom Construction funds per capita)
            
    * Loop for dependent variables
    foreach depvar in yrseduc numbirthbefore25 {
        
            * Regression
            eststo: reg `depvar' born1970_75XOlfunds1976 born1970_75 Olfunds1976 $controls $OLcohort, cl(cluster) 
            estadd local SFE "No"
            estadd local YFE "No"
            
            eststo: reg `depvar' born1970_75XOlfunds1976 born1970_75 Olfunds1976 i.state1970 $controls $OLcohort, cl(cluster)
            estadd local SFE "Yes"
            estadd local YFE "No"
            
            eststo: reg `depvar' born1970_75XOlfunds1976 Olfunds1976 i.state1970 i.respyearofbirth $controls $OLcohort, cl(cluster)
            estadd local SFE "Yes"
            estadd local YFE "Yes"
            
        }
    
    esttab using "${root}/output/tables/regression_createddata2.tex", replace f ////
     b(3) t(3) r2 nogaps nomtitles numbers varwidth(25) obslast label star(* 0.10 ** 0.05 *** 0.01) ///
     booktabs nonotes ///
    keep(born1970_75XOlfunds1976 born1970_75 Olfunds1976) ///
    mgroups("Years of Schooling" "Number of kids before age 25", pattern(1 0 0 1 0 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
    scalars ("SFE" "YFE") sfmt(3) ///
    varlabels(born1970_75XOlfunds1976 "\multirow{2}{*}{\shortstack{Born 1970-75 * Classroom Construction \\ funds per capita}}" Olfunds1976 "\multirow{2}{*}{\shortstack{Classroom Construction funds \\ per capita}}" )

  • #2
    estout is from SSC (FAQ Advice #12). Maybe try appending the tables rather than saving them as two separate tables. The titles would distinguish them, in any case.

    Code:
    *TABLE 1
    esttab using "${root}/output/tables/regression_createddata1.tex", replace ...
    *TABLE 2
    esttab using "${root}/output/tables/regression_createddata1.tex", append ...

    Comment


    • #3
      Thank you, this was very helpful with lining up the columns.
      I am having a problem with title(string) in the esttab command. I have specified the string in quotes that I want each table to be titled as. In LaTex, the titles do not show up for either table though. I am not sure why this is happening?

      Code:
      esttab using "${root}/output/tables/tex_files/regression_createddata3.tex", replace f ////
       b(3) t(3) r2 nogaps numbers nofloat mtitles("Baseline" "SFE" "YFE" "Baseline" "SFE" "YFE") label star(* 0.10 ** 0.05 *** 0.01) ///
       title("A. Program Intensity measured with a dummy variable for high-intensity (non-Western) states") ///
       booktabs nonotes ///
      keep(born1970_75Xhighintensity born1970_75 highintensity) ///
      mgroups("Years of Schooling" "Number of kids before age 25", pattern(1 0 0 1 0 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
      scalars ("Intensity") sfmt(3) ///
      
      esttab using "${root}/output/tables/tex_files/regression_createddata3.tex", append f ////
       b(3) t(3) r2 nogaps numbers nofloat mtitles("Baseline" "SFE" "YFE" "Baseline" "SFE" "YFE") label star(* 0.10 ** 0.05 *** 0.01) ///
       title("B. Program Intensity measured by 1976 per capita federal funds disbursed for primary school construction") ///
       booktabs nonotes ///
      keep(born1970_75XOlfunds1976 born1970_75 Olfunds1976) ///
      mgroups("Years of Schooling" "Number of kids before age 25", pattern(1 0 0 1 0 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
      scalars ("Intensity") sfmt(3) ///
      varlabels(born1970_75XOlfunds1976 "\multirow{2}{*}{\shortstack{Born 1970-75 * Classroom Construction \\ funds per capita}}" Olfunds1976 "\multirow{2}{*}{\shortstack{Classroom Construction funds \\ per capita}}" ) ///

      Comment


      • #4
        Add the highlighted to each table, only changing the title.

        Code:
        esttab using "${root}/output/tables/tex_files/regression_createddata3.tex", replace f ////
         b(3) t(3) r2 nogaps numbers nofloat mtitles("Baseline" "SFE" "YFE" "Baseline" "SFE" "YFE") label star(* 0.10 ** 0.05 *** 0.01) ///
        prehead(\begin{table}[htbp]\centering ///
        \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} ///
        \caption{A. Program Intensity measured with a dummy variable for high-intensity (non-Western) ///
        states} \begin{tabular}{l*{1}{c}} \hline\hline) ///
         booktabs nonotes ///
        keep(born1970_75Xhighintensity born1970_75 highintensity) ///
        mgroups("Years of Schooling" "Number of kids before age 25", pattern(1 0 0 1 0 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
        scalars ("Intensity") sfmt(3) postfoot(\hline \end{tabular} \end{table})

        Comment


        • #5
          Thank you.

          Comment

          Working...
          X