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

  • Adding a non-standard row to a summary table

    Hi there!

    I'm new to STATA and trying to create a table similar to the below. Specifically, I'm looking to figure out how to get the N count in the middle of the two columns.

    I'm using collect command to create the table, but I can't figure out how to create that style. If there's another way you could suggest, that would be much appreciated!

    Thank you
    Click image for larger version

Name:	Screen Shot 2021-11-02 at 6.06.48 PM.png
Views:	1
Size:	29.4 KB
ID:	1634476

  • #2
    Welcome to Statalist.

    If you are creating a Word document with this table, one possibility may be to use putdocx collect to add the table to a Word file, and then use the putdocx table command, in particular the colspan option, to further modify the table to your liking.

    Note that this is all theoretical from reading the documentation (starting at the Remarks and Examples section of the PDF documentation for the collect style putdocx command). I haven't actually tried to accomplish this.


    • #3
      Thank you for your help, William. I should have mentioned this but I'm trying to create a latex file. Regardless, thanks for the creative solution!


      • #4
        May be asdocx users will be interested in this. I published flexmat on ssc two months ago . flexmat can create such a customized table with ease. Once developed, the table can then be exported with asdocx. In the following code lines, I show how to create the above table and send the output to Word.

        flexmat reset
        * Note \hmerge_2: it will create a horizontal merge of two cells, thus placing the text in the middle.
        flexmat addrow, data("\empty, \hmerge_2 Control") row(1)
        * We can easily choose which row to write to. similarly col() can be used to specify the column
        flexmat addrow, data("Characteristics, Mean, SD") row(2)
        * \empty adds an empty cell
        flexmat addrow, data("Sender Characteristics, \hmerge_2 N = 5626 )") row(3)
        * Note \indent_4: it indents the text by 4 spaces
        flexmat addrow, data("\indent_4 Total number of past purchase [before test], 7.352, 9.335") row(4)
        flexmat addrow, data("\indent_4 Total spending (before test), 285.9, 458.1") row(5)
        flexmat addrow, data("\indent_4 Days after creating account, 899.8, 422.2") row(6)
        flexmat addrow, data("deal Characteristics, \hmerge_2 (N=1457)") row(7)
        * This is how the table looks like on the Stata screen
          0 |1                                                    2                3
          1 |\empty                               \hmerge_2 Control                  
          2 |Characteristics                                   Mean               SD
          3 |Sender Characteris~s              \hmerge_2 N = 5626 )           
          4 |\indent_4 Total nu~p                             7.352            9.335
          5 |\indent_4 Total sp~e                             285.9            458.1
          6 |\indent_4 Days aft~c                             899.8            422.2
          7 |deal Characteristics                  \hmerge_2 N=1457          
        * When exported to Word, it looks like this
        asdocx export
        Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	29.6 KB
ID:	1635203

        Last edited by Attaullah Shah; 07 Nov 2021, 00:46.
        Attaullah Shah, PhD.
        Associate Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        Check my asdoc program, or even better asdocx, that easily sends Stata output to MS Word