Announcement

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

  • Exporting descriptive statistics by group

    Hello everyone, i'm trying to export some summary statistics (i use Stata 17). I have this command: bysort cohorte_FPE sexe : sum salaire_total_annuelle if annee==2019 and i want to export the result in rtf format. Can you help me?

  • #2
    You can use the table command and the collect suite of commands in version 17.

    Code:
    webuse grunfeld, clear
    keep if company<5
    bys company: sum invest
    
    *USING TABLE AND COLLECT
    collect clear
    table company, stat(count invest) stat(mean invest) ///
    stat(sd invest) stat(min invest) stat(max invest) nformat(%5.0f)
    collect label levels result count "N", modify
    collect label levels result sd "SD", modify
    collect label levels result min "Min.", modify
    collect label levels result max "Max.", modify
    collect export myfile, replace as(docx)
    Res.:

    Code:
    . bys company: sum invest
    
    -----------------------------------------------------------------------------------------------------------------------------------------
    -> company = 1
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
          invest |         20      608.02    309.5746      257.7     1486.7
    
    -----------------------------------------------------------------------------------------------------------------------------------------
    -> company = 2
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
          invest |         20     410.475    125.3994      209.9      645.5
    
    -----------------------------------------------------------------------------------------------------------------------------------------
    -> company = 3
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
          invest |         20      102.29     48.5845       33.1      189.6
    
    -----------------------------------------------------------------------------------------------------------------------------------------
    -> company = 4
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
          invest |         20     86.1235    42.72555      40.29     174.93

    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	11.6 KB
ID:	1775319

    Comment


    • #3
      Ty!

      Comment

      Working...
      X