Announcement

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

  • How to Center the Row Variable Label Across the Table in dtable?

    Hello everyone,

    I am trying to customize a table I created using the dtable command, but I can't achieve the formatting I want. Here is an example dataset:

    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float cult_obj byte continua
    2 2
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    2 2
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    2 1
    2 2
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    1 1
    2 1
    end
    label values cult_obj cult_obj
    label def cult_obj 1 "Yes", modify
    label def cult_obj 2 "No", modify
    label values continua continua
    label def continua 1 "Yes", modify
    label def continua 2 "No", modify
    label var cult_obj "Was the target crop present on the plot during the 21/22 season?"
    label var continua "Can the survey continue?"
    I would like to isolate the label/title of the row variable, but it seems impossible because the levels of the row variable dimension only identify the two categories (1.cult_obj and 2.cult_obj). I believe there is a way to add a blank row (or level), but I haven’t been able to figure out how.

    The result I get after running the following code:

    collect clear
    qui dtable i.cult_obj, by(continua) sample(, place(seplabels))
    collect style cell cell_type[column-header] , halign(center)
    collect style cell cell_type[row-header] , halign(center)
    collect style cell cell_type[item] , halign(center)
    collect style cell, font(Arial, size(11pt))
    collect preview "Exm.docx", replace
    Produces the following output:

    Click image for larger version

Name:	Imagen 1 para statalist.png
Views:	1
Size:	18.9 KB
ID:	1772185


    However, I would like the result to look like this:
    Click image for larger version

Name:	Imagen 2 para statalist.png
Views:	1
Size:	17.3 KB
ID:	1772186



    In other words, I would like to center the row variable label across the entire table, but I cannot do it because I cannot uniquely isolate this element/cell.

    Can anyone guide me on how to achieve this?
Working...
X