Announcement

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

  • #16
    Many thanks, Andrew.
    I've tried to run your code but there is a error message.

    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . local byvar rep78
    
    . gen Mean= price
    
    . drop if missing(`byvar')
    (5 observations deleted)
    
    . expand 2, g(new)
    (69 observations created)
    
    . qui sum `byvar'
    
    . assert `byvar'!=99999
    
    . replace `byvar'= 99999 if new
    variable rep78 was int now long
    (69 real changes made)
    
    . bys `byvar': egen Std_Err=sd(Mean)
    
    . bys `byvar': egen Freq=count(Mean)
    
    . collapse Mean Std_Err Freq, by("`byvar'")
    
    . estpost tabstat  Mean Std_Err Freq, by("`byvar'")
    
    Summary statistics: mean
         for variables: Mean Std_Err Freq
      by categories of: rep78
    
           rep78 |   e(Mean)  e(Std_E~)    e(Freq)
    -------------+---------------------------------
               1 |    4564.5   522.5519          2
               2 |  5967.625   3579.357          8
               3 |  6429.233    3525.14         30
               4 |    6071.5   1709.608         18
               5 |      5913   2615.763         11
           99999 |  6146.043    2912.44         69
    -------------+---------------------------------
           Total |   5848.65   2477.477         23
    
    . esttab, cells("Mean Std_Err Freq") noobs nomtitle nonumber ///
    > collab(,lhs("`:var lab `byvar''")) drop(Total) ///
    > substitute("99999" "Total" "Std_Err" "Std. Err") varwidth(20)
    coefficient Total not found
    r(111);
    
    end of do-file
    
    r(111);
    
    
    
    .

    Code:
    CODE]
    
    
    sysuse auto, clear
    local byvar rep78
    gen Mean= price
    drop if missing(`byvar')
    expand 2, g(new)
    qui sum `byvar'
    assert `byvar'!=99999
    replace `byvar'= 99999 if new
    bys `byvar': egen Std_Err=sd(Mean)
    bys `byvar': egen Freq=count(Mean)
    collapse Mean Std_Err Freq, by("`byvar'")
    estpost tabstat  Mean Std_Err Freq, by("`byvar'")
    esttab, cells("Mean Std_Err Freq") noobs nomtitle nonumber ///
    collab(,lhs("`:var lab `byvar''")) drop(Total) ///
    substitute("99999" "Total" "Std_Err" "Std. Err") varwidth(20)
    *LaTeX Table
    esttab, cells("Mean Std_Err Freq") noobs nomtitle nonumber ///
    collab(,lhs("`:var lab `byvar''")) drop(Total) ///
    substitute("99999" "Total" "Std_Err" "Std. Err") varwidth(20) tex
    Last edited by Tiago Munhoz; 22 Apr 2021, 19:52.

    Comment


    • #17
      It works for me. Update estout and see if it solves it.

      Code:
      ssc install estout, replace

      Comment


      • #18
        Thanks. Now it's working fine.

        Comment


        • #19
          Is there any new way to export two-way tabulations to latex since then? I'm currently trying to export the following tables to latex. Ideally append them on top of each other.

          tab categorical_1 categorical_2, column nofreq

          tab categorical_1 categorical_2, cell nofreq

          Comment


          • #20
            If you are asking about the updated table and new collect commands, then you should start a new thread and indicate this in the title so that those who are familiar with creating such tables may easily find your question.

            Comment

            Working...
            X