asdocx: Export from Stata to Word, Excel, LaTeX & HTML Forums asdocx Forum Template Table1 Notreatment Option Not Working (And Adding Median/IQR)

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • Kevin Blaine
    Participant
    Post count: 50

    Hi Dr. Shah — I believe the Table1 template has a couple of coding errors pertaining to the “NOTReatment” option being invoked. I took a look at the source code, and I believe the issue lies either in the global/local “treat_groups_count” or the local “TreatmentExists”. A forvalues loop gets stuck when the treat_groups_count is missing. I tried to remedy the issue myself by inserting some if statements, but I couldn’t get it to successfully work well, often getting hung up on the categorical and continuous getstat sub-program, which doesn’t seem to take TreatmentExist into account; both programs just dive right into the forv z=1… loop, which will throw an error when the “treat_groups_count” is blank.

    Even after all that, I still found a way to make it work for factor variables, but when those worked, the continuous variables didn’t. Anyway, hopefully that gives some context for debugging on your end.

    My current overall workaround is to manually create an “arbitrary” variable that categorizes randomly each observation into one of two groups. From there, I have just been deleting the P-Value and Group1/Group2 columns, leaving the “Total” column intact.

    I do wonder though: is there anyway to add median and IQR/p25/p75 to the allowed stats for continuous variables? I see it’s allowed for Factor and Binary, but not continuous, which I don’t quite understand. I work in medical research, and most of our continuous variables are not normally distributed, so presenting the mean/SD or CI doesn’t make sense.

    Thanks,
    Kevin

    Attaullah Shah
    Moderator
    Post count: 76

    Hello Kevin
    I have updated the table1 template. I hope the update fixes the errors you have mentioned. Here is a working example.

    
    asdocx_update
    
    * Use example data
    use http://fintechprofessor.com/asdocxAddins/table1.dta, clear
    
    * Export table1 with no treatment effect.
    asdocx tab immigrant bone_arthritis bone_backspin  bone_backother bone_neck /// 
           bone_fibro bone_lupus, template(table1) notreatment replace
    
                                 Table 1: Demographics
      0 |1                                                2 
    ----+----------------------------------------------------
      1 |Variables                             Total (1000) 
    ----+----------------------------------------------------
      2 |immigrant                                          
      3 | Non-Immigrant                       670 (86.118%) 
      4 | Immigrant                           108 (13.882%) 
      5 |Arthritis                                          
      6 | No arthritis                        165 (17.387%) 
      7 | Arthritis                           784 (82.613%) 
      8 |Back pain due to s~s                               
      9 | No back pain due ~n                 918 (96.733%) 
     10 | Back pain due to ~i                   31 (3.267%) 
     11 |Back pain due to o~s                               
     12 | Back pain due to ~s               1000 (100.000%) 
     13 |Neck pain                                          
     14 | No neck pain                        803 (84.615%) 
     15 | Neck pain                           146 (15.385%) 
     16 |Fibromyalgia                                       
     17 | No fibromyalgia                     923 (97.260%) 
     18 | Fibromyalgia                          26 (2.740%) 
     19 |Lupus                                              
     20 | No lupus                            944 (99.473%) 
     21 | Lupus                                  5 (0.527%) 
    ----------------------------------------------------------
    
    

    With regards to the inclusion of new statistics, I’ve taken note of your recommendations and will take them into account as soon as my schedule allows.

    Kevin Blaine
    Participant
    Post count: 50

    I deeply appreciate all your work on this. Thank you!

    Kevin Blaine
    Participant
    Post count: 50

    Hi Dr. Shah — it looks like continuous variables aren’t being reported when notr is invoked. Here’s the output:

    
    asdocx tab age, template(table1) replace notr save("/Users/default/Downloads/Table")
    
    
      here
       
                                   Table 1: Demographics
      0 |1                                            2                             3                 4               5 
    ----+----------------------------------------------------------------------------------------------------------------------------------------
      1 |Variables                             0 (n=37)                      1 (n=37)        Total (74)         P-value 
    ----+----------------------------------------------------------------------------------------------------------------------------------------
      2 |Age                           24.086 (± 6.247)              24.194 (± 6.210)                                   
    ---------------------------------------------------------------------------------------------------------------------------------------------P-values by t-test for continuous variables and Chi2 test for binary/categorical variables. 
      
    
    
      here
       
                                   Table 1: Demographics
      0 |1                                                  2 
    ----+-----------------------------------------------------------------------------
      1 |Variables                                 Total (74) 
    ----+-----------------------------------------------------------------------------
      2 |Age                                                  
    ----------------------------------------------------------------------------------
    P-values by t-test for continuous variables and Chi2 test for binary/categorical variables. 
    
    
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.