Announcement

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

  • Removing column statistic headers from collect table

    I am trying to use the table and collect commands to generate a table of descriptive statistics for a report that I am creating using putdocx.
    The table I am creating includes columns with both factor variables and continuous variables. I would like to remove the column headers that say "Factor-variable percent" and "Mean" but I do not know what these table elements are called or how to modify them.

    I have provided an example below (I am using confidential data, but NLSW88 is a similar format to my data). I am using Stata 18.0


    Code:
    sysuse nlsw88
    table race, statistic(fvpercent never_married) statistic(mean hours) statistic(mean wage) ///
    sformat("%s%%" fvpercent) nformat(%2.1f)
    collect layout (race) (result#var[1.never_married hours wage])
    Result:

    Code:
    collect preview
    
    ---------------------------------------------------------------------
            |  Factor-variable percent                 Mean              
            |            Never married   Usual hours worked   Hourly wage
            |            Never married                                  
    --------+------------------------------------------------------------
    Race    |                                                            
      White |                     7.7%                 36.9           8.1
      Black |                    18.0%                 38.1           6.8
      Other |                    11.5%                 36.8           8.6
      Total |                    10.4%                 37.2           7.8
    ---------------------------------------------------------------------
    Apologies if this has been asked elsewhere and I did not see the post.

  • #2
    Thanks for the reproducible example.

    Code:
    sysuse nlsw88, clear
    table race, statistic(fvpercent never_married) statistic(mean hours) statistic(mean wage) ///
    sformat("%s%%" fvpercent) nformat(%2.1f)
    collect label list result
    collect style header result, level(hide)
    collect layout (race) (result#var[1.never_married hours wage])
    Res.:

    Code:
    . collect label list result
    
      Collection: Table
       Dimension: result
           Label: Result
    Level labels:
       fvpercent  Factor-variable percent
            mean  Mean
    
    . collect style header result, level(hide)
    
    . collect layout (race) (result#var[1.never_married hours wage])
    
    Collection: Table
          Rows: race
       Columns: result#var[1.never_married hours wage]
       Table 1: 5 x 3
    
    -----------------------------------------------------------
            |  Never married   Usual hours worked   Hourly wage
            |  Never married                                   
    --------+--------------------------------------------------
    Race    |                                                  
      White |           7.7%                 36.9           8.1
      Black |          18.0%                 38.1           6.8
      Other |          11.5%                 36.8           8.6
      Total |          10.4%                 37.2           7.8
    -----------------------------------------------------------

    Comment


    • #3
      This worked perfectly. Thank you very much!

      Comment

      Working...
      X