Announcement

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

  • how to edit tabulate command

    Is there any way to use tabulate command in such a manner so that it publishes output like the following (I took this table from a research paper randomly to use it as a reference):
    Age (in year)
     20–39 39.9 (7697) 18.5 (1659) 58.3 (6038) < 0.001
     40–59 34.5 (6959) 38.6 (3674) 31.0 (3285)
     60+ 25.6 (7279) 42.9 (5830) 10.7 (1449)
    Gender
     Male 47.1 (10,499) 50.1 (5671) 44.6 (4828) < 0.001
     Female 52.9 (11,436) 49.9 (5492) 55.4 (5944)
    When I use tabulate command I get results like the following:


    | married
    race | single married | Total
    -----------+----------------------+----------
    white | 487 1,150 | 1,637
    black | 309 274 | 583
    other | 8 18 | 26
    -----------+----------------------+----------
    Total | 804 1,442 | 2,246

    Pearson chi2(2) = 101.4215 Pr = 0.000


    lives in | married
    south | single married | Total
    -----------+----------------------+----------
    0 | 464 840 | 1,304
    1 | 340 602 | 942
    -----------+----------------------+----------
    Total | 804 1,442 | 2,246

    Pearson chi2(1) = 0.0620 Pr = 0.803

    From where I need to create that above table manually. Is there any way to do this directly?

  • #2
    You've posted several slightly different versions of this question within a few hours. Please don't do that.

    This could be programmed but isn't obviously simple (to me).

    In your example it's not obvious what defines the columns.

    Code:
    help tab2
    shows a command that will get you closer to what you want than will tabulate. Note the firstonly option.

    There aren't options of tabulate that will get you what you want.

    Writing a new command is a good idea if you need to do something again and again, but don't underestimate the number of ideas that you need to learn together.

    For one-off output, you're better off editing output in a favourite environment, such as LaTeX, HTML, XML or MS Office.


    Comment


    • #3
      I suspect a version of what you want would be possible. I don't make tables in my research anymore because I prefer graphics, but yes, I suspect something like what you want is on the menu. Before you do that though, you'd likely need to be intimately familiar with estout, esttab and estpost, user written commands. You'd need to know how to both use them and append the files they generate on top of one another. This to me seems like your most viable path to victory here. Again, I haven't used these commands in forever, but I'm pretty sure something like what you want is possible.

      I also second Nick Cox's latter comments on writing commands. If you'll make a table like this often, well... okay, I suppose this is fine, but... and I'll make a strange analogy so bear with me: writing a new Stata command or editing a native Stata for this purpose would be a little bit like using a SCUD missile or a stealth bomber to take down a high-school bully. Surely it's possible (leaving the ethics of this aside for a moment), but the startup costs would be too great and the complexity too awesome (for me at least, maybe some Mata wizard could do this) to want to do this.

      So my basic advice is to read and download Ben Jann's estout commands (package?) and you'll sort of be on the way to do this, I think. Adiba Bilqees Promiti

      Comment


      • #4
        The output you have posted seems much similar to Table 1, that is commonly found in biomedical research papers. asdocx, which is a premium version of asdoc, can produce such tables with many variations. You may like to explore more about it here https://fintechprofessor.com/asdocx/...tients-asdocx/.
        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment

        Working...
        X