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.

  • Ruth-Alma Turkson-Ocran
    replied
    Hi Bhaskar,

    I haven't been successful in getting the observations for each category. Even using the labrown or labcoln options you see in the help documentation for tabxml. (If anyone has figured that out please let me know how it works)

    What I usually do, and I don't believe fully answers your question is to find the column weighted or unweighted Ns using syntax like this:

    Code:
    svy, subpop(if dropped_depression==0): tab new_depression, obs format(%12.0g) //unweighted number and proportion  
    svy, subpop(if dropped_depression==0): tab new_depression, count format(%12.0g) //weighted number and proportion
    note dropped_depression is a variable that includes those who are either generally included or excluded from your analysis

    Leave a comment:


  • Bhaskar Thakur
    replied
    Hi Ruth & Mark,

    I am using "tabsml" in Stata 18.0. While using the following code,

    Code:
    tabxml, dv(new_depression) ivd(female marital2 age_cat new_ethnicity education smoke ever_alc income_c pa obesity) percent(row) save(table1) tf(2) chi2 display bold justify(r) pval sp
    I have estimated n for each category of the independent categorical variables at the population level. However, I'm interested in knowing the number of observations for those categories at the sample level. Am I missing something here?

    Leave a comment:


  • Ya Chen
    replied
    Originally posted by Ruth-Alma Turkson-Ocran View Post
    On another note, I am using tabxml in Stata 14.2 and trying to do another Table 1 by sex. When using variations of this code:

    Code:
     tabxml, ivc(age_p) ivd(sex_r married racreci3 edu_cat poor2 emp_stat notcov usupl) order(age_p sex_r racreci3 married edu_cat poor2 emp_stat notcov usupl) save("/location_filename_$datentime") split(sex_r) options(n per) display bold justify(c) pval sp
    I keep getting errors such as: "invalid subpop() option" when I try using the subcond option. I also get this error:

    Code:
    Table contains a zero in the marginals.
    Statistics cannot be computed.
    conformability error
    r(503);
    when I use this code:

    Code:
     tabxml, ivc(age_p) ivd(sex_r married racreci3 edu_cat poor2 emp_stat notcov usupl) order(age_p sex_r racreci3 married edu_cat poor2 emp_stat notcov usupl) save("/location_filename_$datentime") split(sex_r) options(n per) display bold justify(c) pval sp
    What am I doing wrong?
    Hi, it seems tabxml can not output p value for continuous variables? Right?

    Leave a comment:


  • Ya Chen
    replied
    Thanks, Mark. table1_mc is a great update to table1. Could you please add a function that could allow us to add the statistics, such as t value, chisq value. Thank you!

    Leave a comment:


  • Ya Chen
    replied
    Thank you! Better than table1! Hope table1_mc could show statistics like chi-square value, t value.

    Leave a comment:


  • Fiona Caristo
    replied
    Originally posted by Fiona Caristo View Post

    Hi Wei,

    Did you resolve this? Using table1_mc for the first time and I am having a similar problem. I believe it is due to a space in my directory path (\Fiona IMPROVE\Bisphos\Bladder), and getting 'invalid 'IMPROVE' as my error (the first string after a space in a folder name). Other than changing my folder names to have no spaces, is there another solution? I am using Stata 16.0.

    Fiona
    Resolved following contact with Mark Chatfield. Solution is to change to a directory without spaces in any folder names.
    Fiona

    Leave a comment:


  • Fiona Caristo
    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);
    Hi Wei,

    Did you resolve this? Using table1_mc for the first time and I am having a similar problem. I believe it is due to a space in my directory path (\Fiona IMPROVE\Bisphos\Bladder), and getting 'invalid 'IMPROVE' as my error (the first string after a space in a folder name). Other than changing my folder names to have no spaces, is there another solution? I am using Stata 16.0.

    Fiona

    Leave a comment:


  • 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:

Working...
X