Announcement

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

  • Help with table1_mc: How to compare total N to subgroups?

    Hi,

    I'm fairly new to stata and have a problem with the table1_mc command. I want to create a table that shows baseline characteristics for my whole sample (N=1200) as well as for two subgroups of that sample who have either participated in a program and those who have not. So ideally, the table would have three columns. If i use the code:

    table1_mc, by(myexposurevariable) (vars variable1 variable2 etc.)

    that leaves out the total and just focuses on intervention vs non-intervention. I feel like my problem is fairly simple but I don't know how to fix this, so any help would be greatly appreciated!

  • #2
    I do not use table1_mc which should be community-contributed, but a common trick to get a total category is to expand the dataset and create a third category. With luck, this should work:

    Code:
    preserve
    expand 2, g(new)
    replace myexposurevariable= 3 if new
    table1_mc, by(myexposurevariable) (vars variable1 variable2 ...)
    restore

    Comment


    • #3
      Andrew's trick is very common and convenient for many situations. However, I advise caution with commands you are unfamiliar with operating because the command may interpret your data now as having 3 groups, for purposes of statistical testing, which is certainly wrong.

      I don't use this command personally, so you should always read the documentation (-help table1_mc-). I imagine this must be an option. If not, there are many resources to learn how to build such tables "by hand".

      Comment


      • #4
        according to the help file, one of the options available is "total(before|after)" (i.e., do you want the total column to appear and, if so, do you want it before or after the exposure variable columns?)

        Comment


        • #5
          Thank you so much everyone for the help, I appreciate it very much! The total option works perfectly (somehow I overlooked it in the help file), but for future reference it is also helpful to know the "expand" trick.

          Comment


          • #6
            Hello, I have used table1_mc to create a table. When I try to export it to word document I get the following error: maximum number of columns exceeded; limit 63.

            Please let me know if you have any advice on what to do.

            This is a sample of the code I am using to create the table:

            table1_mc, by(group) vars(age contn %4.2f \ gender cat %4.2f \ race cat %4.2f \ ) nospace missing onecol total(before)

            This is the code I am using to export it to word:

            table1_mc_dta2docx using "C:\example Table 1.docx", replace

            Thanks very much

            Comment


            • #7
              Hi Iana
              I am having the same problem, did you find a solution?
              Thanks
              Kate

              Comment


              • #8
                MS Word has an upper limit of 63 columns for tables, probably because they’re unreadable. If you need so many columns, you’ll need to consider a method that allows export to Excel or a dataset, etc. I have no specific method to offer beyond this because I never make such wide tables, and its likely a bad idea to do so.

                Comment

                Working...
                X