Announcement

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

  • Announcing table1_mc: Stata module to create "Table 1" of baseline characteristics for a manuscript

    Dear Statalisters,

    I have just posted my program table1_mc on SSC (requires version 14.2). This program is essentially an extension of Phil Clayton’s table1 command.

    . sysuse auto, clear
    (1978 Automobile Data)

    . generate much_headroom = (headroom>3)

    . table1_mc, by(foreign) vars(price conts \ price contln %5.0f %4.2f \ weight contn %5.0f \ rep78 cate \ much_headroom bine)

    +------------------------------------------------------------------------------------+
    | Level Domestic Foreign p-value |
    |------------------------------------------------------------------------------------|
    | N=52 N=22 |
    |------------------------------------------------------------------------------------|
    | Price 4,782.5 (4,184-6,234) 5,759 (4,499-7,140) 0.30 |
    | Price 5534 (×/1.50) 5959 (×/1.44) 0.46 |
    |------------------------------------------------------------------------------------|
    | Weight (lbs.) 3317 (695) 2316 (433) <0.001 |
    |------------------------------------------------------------------------------------|
    | Repair Record 1978 1 2 ( 4%) 0 ( 0%) <0.001 |
    | 2 8 (17%) 0 ( 0%) |
    | 3 27 (56%) 3 (14%) |
    | 4 9 (19%) 9 (43%) |
    | 5 2 ( 4%) 9 (43%) |
    |------------------------------------------------------------------------------------|
    | much_headroom 28 (54%) 2 ( 9%) <0.001 |
    +------------------------------------------------------------------------------------+
    Data are presented as mean (SD) or geometric mean (×/GSD) or median (IQR) for continuous measures, and frequency (percentage) for categorical measures.


    Feedback welcome.

    Best wishes, Mark
    Last edited by Mark Chatfield; 02 Jun 2017, 01:17.

  • Mark Chatfield
    replied
    Wei
    I'm sorry, I have no idea why you are getting that error message. No one has ever told me of such a message before. Possibly this may be helpful to diagnose:
    . set more on
    then re-run your commands
    Email me the output if you like.
    BW,
    Mark

    Leave a comment:


  • Andrew Musau
    replied
    Originally posted by Wei Chen Einstein View Post
    Hi,
    I tried the table1_mc command as suggested after installing the program, but received the error Invalid 'Chen". 'Chen' is my last name. I cannot figure out what the problem is. Help, please! Thanks!

    Wei

    . sysuse auto, clear
    (1978 Automobile Data)

    . generate much_headroom = (headroom>3)

    . table1_mc, by(foreign) vars(price conts \ price contln %5.0f %4.2f \ weight contn %5.0f \ rep78 cate \ much_headroom bine)
    invalid 'Chen'
    r(198);

    If Ruth-Alma's suggestion doesn't fix it, you probably have to run the command with

    Code:
    set trace on
    to trace where the error occurs. See a similar thread for potentially how to diagnose and fix the issue.

    https://www.statalist.org/forums/for...rror-diagnosis

    Leave a comment:


  • Ruth-Alma Turkson-Ocran
    replied
    Perhaps "price contln" should be
    Code:
    price contn

    Leave a comment:


  • Wei Chen Einstein
    replied
    Hi,
    I tried the table1_mc command as suggested after installing the program, but received the error Invalid 'Chen". 'Chen' is my last name. I cannot figure out what the problem is. Help, please! Thanks!

    Wei

    . sysuse auto, clear
    (1978 Automobile Data)

    . generate much_headroom = (headroom>3)

    . table1_mc, by(foreign) vars(price conts \ price contln %5.0f %4.2f \ weight contn %5.0f \ rep78 cate \ much_headroom bine)
    invalid 'Chen'
    r(198);

    Leave a comment:


  • Mark Chatfield
    replied
    Hi Magnus

    It is possible. The key to seeing this is in . help table1_mc_dta2docx (Description).

    sysuse auto, clear
    table1_mc, by(foreign) vars(price conts \ weight contn %5.0f \ rep78 cate) extraspace clear
    rename N_* n_*
    order n_0, before(foreign_0)
    order n_1, before(foreign_1)
    table1_mc_dta2docx using "H:\example Table 1.docx", replace

    BW,
    Mark

    Leave a comment:


  • Magnus Lyngbakken
    replied
    Hi,

    This is a really great extension, thank you for the time and work invested. Is there a way to include number of valid observations (N) directly to the table output? Like this:

    Click image for larger version

Name:	table.png
Views:	1
Size:	46.1 KB
ID:	1525480


    I manage to compile two separate tables, one with N_0, N_1, m_0 and m_1, and one with the actual data, but it would save time and editing if these could be combined.

    Best regards,
    Magnus

    Leave a comment:


  • Mark Chatfield
    replied
    help tabulate twoway explains that the syntax in my program (or in a simple . tab cat1 cat2, exact command) needs to be something like . tab cat1 cat2, exact(2). To quote: The optional positive
    integer # is a multiplier on the amount of memory that the command is permitted to consume.
    The default is 1. This option should not be necessary for reasonable r x c tables. If the
    command terminates with error 910, try exact(2). The maximum row or column dimension allowed
    when computing Fisher's exact test is the maximum row or column dimension for tabulate (see
    limits).

    Leave a comment:


  • bln tfte
    replied
    hi Mark,
    When I use "cate" in table1_mc for Fisher's test incase categories have small numbers, I am getting an error meassage that says " exceeded memory limits using exact(1); try again with larger #;........"
    Any advice?

    Leave a comment:


  • Steven Spivack
    replied
    Ok thanks so much for this tip.

    Leave a comment:


  • Ruth-Alma Turkson-Ocran
    replied
    Steven Spivack Sorry for the delayed response. I used the option display while running the tabxml command. This lets you see the output for all the different tests being run to create the table. In the output window, I just scrolled through to find the test I was looking for and its associated p-value and put the p-value in my table - yes tedious, but was the only option I saw.

    Unfortunately, I have not yet used the testparm command, so I cannot comment on that.

    Leave a comment:


  • Steven Spivack
    replied
    Originally posted by Ruth-Alma Turkson-Ocran View Post
    [USER="18711"]I find that when I examine continuous variables, I do not get the p-values (I can get them from the output window when I use the display command). I get the codes with the categorical/dichotomous variables. I also have to sometimes run it a few times differently to get what I want because some variables end up missing in the Excel output--To expand: I run it once with only continuous variables, then I run it again with only categorical variables and then copy/paste/rearrange in the Excel output, and save.
    I am not getting p values for any continuous variables either with tabxml. Instead, do you just regress each IV on the DV and then use the testparm command to get a p value, that is what I am doing now but it is not super efficient.

    Leave a comment:


  • Ruth-Alma Turkson-Ocran
    replied
    Steven Spivack No; I did not use the osvy option. My dataset is a survey with pweights so I svyset the data prior to using, so I left out the osvy option.

    UPDATE: I also believe I fixed my issue. I think the sex variable was tripping me up as I was trying to examine sex differences. So the code that worked for me was:

    Code:
    tabxml, dv(sex_r) ivc(age_p) ivd(married edu_cat poor2 emp_stat notcov usupl) order(age_p married edu_cat poor2 emp_stat notcov usupl) save("/location_filename_$datentime") display bold justify(c) subcond(black_african==1) pval sp
    I also like Table1, but its huge disadvantage is that it just does not work with weights.

    Regarding tabxml, I find that when I examine continuous variables, I do not get the p-values (I can get them from the output window when I use the display command). I get the codes with the categorical/dichotomous variables. I also have to sometimes run it a few times differently to get what I want because some variables end up missing in the Excel output--To expand: I run it once with only continuous variables, then I run it again with only categorical variables and then copy/paste/rearrange in the Excel output, and save.

    Leave a comment:


  • Steven Spivack
    replied
    Originally posted by Ruth-Alma Turkson-Ocran View Post
    What am I doing wrong?
    Did you use the osvy option? Have you installed dm49 which is required for tabxml?
    Last edited by Steven Spivack; 23 Oct 2018, 23:45.

    Leave a comment:


  • Steven Spivack
    replied
    Thanks again Ruth-Alma. I like the Table1 and tabout commands because they are so efficient and allow for ANOVA and Chi2, so I was hoping they would allow the use of aweights. It looks like tabxml does not allow for weights either when the data are not svyset.

    I am aware of these other commands but they are so much more tedious since I have to create 5 distinct descriptive tables which are quite long.
    Last edited by Steven Spivack; 23 Oct 2018, 23:44.

    Leave a comment:

Working...
X