Announcement

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

  • table: grand total missing in 4-way table

    I have a four way table. I can get a row total and a column total, but the grand total is missing (empty lower left cell).

    cls
    clear
    webuse nhanes2l
    label var highbp "Blood Pressure"
    label define highbp 0 "Normal" 1 "High"
    label values highbp highbp
    table ( sex race ) ( highbp diabetes ) (), ///
    totals(sex#race highbp#diabetes)

    ----------------------------------------------------------------------------------
    | Blood Pressure
    | Normal High Total
    | Diabetes status Diabetes status Diabetes status
    | Not diabetic Diabetic Not diabetic Diabetic Total
    ------------+---------------------------------------------------------------------
    Sex |
    Male |
    Race |
    White | 2,253 58 1,885 116 4,312
    Black | 226 18 236 20 500
    Other | 54 2 44 3 103
    Female |
    Race |
    White | 2,916 88 1,605 142 4,751
    Black | 290 11 248 37 586
    Other | 56 1 37 3 97
    Total |
    Race |
    Total | 5,795 178 4,055 321
    ----------------------------------------------------------------------------------


    .
    I tried interacting all four variables, but that didn't work. Requesting all totals is not the answer, because I don't want the subtotals for the individual variables (race, sex, etc.). That creates a much larger table:


    -------------------------------------------------------------------------------------------------------------------
    | Blood Pressure
    | Normal High Total
    | Diabetes status Diabetes status Diabetes status
    | Not diabetic Diabetic Total Not diabetic Diabetic Total Not diabetic Diabetic Total
    ------------+------------------------------------------------------------------------------------------------------
    Sex |
    Male |
    Race |
    White | 2,253 58 2,311 1,885 116 2,001 4,138 174 4,312
    Black | 226 18 244 236 20 256 462 38 500
    Other | 54 2 56 44 3 47 98 5 103
    Total | 2,533 78 2,611 2,165 139 2,304 4,698 217 4,915
    Female |
    Race |
    White | 2,916 88 3,004 1,605 142 1,747 4,521 230 4,751
    Black | 290 11 301 248 37 285 538 48 586
    Other | 56 1 57 37 3 40 93 4 97
    Total | 3,262 100 3,362 1,890 182 2,072 5,152 282 5,434
    Total |
    Race |
    White | 5,169 146 5,315 3,490 258 3,748 8,659 404 9,063
    Black | 516 29 545 484 57 541 1,000 86 1,086
    Other | 110 3 113 81 6 87 191 9 200
    Total | 5,795 178 5,973 4,055 321 4,376 9,850 499 10,349
    -------------------------------------------------------------------------------------------------------------------


  • #2
    The font changed when I posted my message and the table became unreadable. Here it is as an image.

    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	14.0 KB
ID:	1687543

    Comment


    • #3
      I have been wondering the same thing for a while. I think if you just take out the total subcommand, you get all totals, including the grand total. But when I haven't wanted every subtotal -- as in your case just wanting the marginals totals on your table, then I have been unable to get the grand total. Seems a wierd omission.

      Comment

      Working...
      X