Announcement

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

  • How to display a descriptive table for all items of an item set, presenting percentages for each response category?

    Dear all,

    I am stuck at a problem, although the solution should be straightforward.

    I have several 5-point Likert-scale item sets (different dimensions of a construct, each measured by a different number of items) and for each set I would like to present a descriptive table with the item name in the first column and the response categories in the columns 2-6. The cells should give the percentage of responses in the respective categories. That means the table should look like this:
    completely agree somewhat agree undecided somewhat disagree completely disagree TOTAL
    Item 1 10% 20% 10% 50% 10% 100%
    Item 2 20% 10% 50% 10% 10% 100%
    Item 3 10% 20% 10% 50% 10% 100%
    Item 4 5% 20% 40% 30% 5% 100%
    Is there an easy way to do that in Stata? I am using Stata 15. (Of course, I am aware that I could use "tab1 item1-item10" and then manually transpose the table in Excel separately for each item but I thought that perhaps there is a more convenient solution for that.)


    Best

    Peter

  • #2
    Install estout and see -help estpost-.

    Code:
    ssc install estout, replace

    Comment


    • #3
      Thanks, Andrew. Unfortunately, I could not find any solution there. Do you mean running the variables through a loop and then saving the results from the e(pct) matrix at each step? estpost tabulate only accepts one variable at a time.

      Comment


      • #4
        Code:
        . sysuse auto, clear
        (1978 automobile data)
        
        . bysort foreign : gen total = _N
        
        . bysort foreign rep78 : gen pc = 100 * _N / total
        
        . tabdisp foreign rep78, c(pc)
        
        ----------------------------------------------------------------------
        Car       |                     Repair record 1978                    
        origin    |        1         2         3         4         5         .
        ----------+-----------------------------------------------------------
         Domestic | 3.846154  15.38461  51.92308  17.30769  3.846154  7.692307
          Foreign |                     13.63636  40.90909  40.90909  4.545455
        ----------------------------------------------------------------------
        
        . tabdisp foreign rep78, c(pc) format(%2.1f)
        
        ----------------------------------------------
        Car       |         Repair record 1978        
        origin    |    1     2     3     4     5     .
        ----------+-----------------------------------
         Domestic |  3.8  15.4  51.9  17.3   3.8   7.7
          Foreign |             13.6  40.9  40.9   4.5
        ----------------------------------------------
        
        .
        To avoid the missings:

        Code:
        . sysuse auto, clear
        (1978 automobile data)
        
        . bysort foreign : egen total = count(rep78)
        
        . bysort foreign rep78 : gen pc = 100 * _N / total
        
        . tabdisp foreign rep78 if rep78 < ., c(pc) format(%2.1f)
        
        ----------------------------------------
        Car       |      Repair record 1978     
        origin    |    1     2     3     4     5
        ----------+-----------------------------
         Domestic |  4.2  16.7  56.3  18.8   4.2
          Foreign |             14.3  42.9  42.9
        ----------------------------------------
        Last edited by Nick Cox; 04 Aug 2021, 04:16.

        Comment


        • #5
          From Nick's example:

          Code:
          sysuse auto, clear
          qui estpost tabulate foreign rep78
          esttab, cell(rowpct(fmt(2))) unstack noobs nonumb collab(none)
          Res.:

          Code:
          . esttab, cell(rowpct(fmt(2))) unstack noobs nonumb collab(none)
          
          ------------------------------------------------------------------------------------------
                                                                                                    
                                  1            2            3            4            5        Total
          ------------------------------------------------------------------------------------------
          Domestic             4.17        16.67        56.25        18.75         4.17       100.00
          Foreign              0.00         0.00        14.29        42.86        42.86       100.00
          Total                2.90        11.59        43.48        26.09        15.94       100.00
          ------------------------------------------------------------------------------------------

          Comment


          • #6
            Thanks for illustrating both options, Nick and Andrew. That helps a lot.

            Comment

            Working...
            X