Forum Replies Created

Viewing 15 posts - 16 through 30 (of 80 total)
  • Author
    Posts
  • Attaullah Shah
    Moderator
    Post count: 80

    Hello Kevin
    The poly option was not previously supported in asdocx. I have added it now. You can update the mrtab package using the following link. Also update asdocx, then try the following example.

     net install asdocx_mrtab, from(http://fintechprofessor.com) replace
    asdocx_update
    
    * Load some example data
    . use http://fmwww.bc.edu/RePEc/bocode/d/drugs.dta
    
    * export the mrtab output with asdocx
    asdocx  mrtab inco1-inco7, include title(Sources of income)  poly by(city) replace
    
                |  City in which the interview was   
     Sources of |             conducted              
         income |      Basel        Bern      Zurich |      Total
    ------------+------------------------------------+-----------
     0       no |        348         288         336 |        972 
     1      yes |        346         284         333 |        963 
    ------------+------------------------------------+-----------
          Total |        694         572         669 |       1935 
          Cases |        348         288         336 |        972 
    
    Valid cases:        972
    Missing cases:        0
    
    Attaullah Shah
    Moderator
    Post count: 80

    The algorithm behind tabdisp is quite complex. Initially, I did not intend to include a by() option. However, in response to your request, I have now added this feature. Please note that the output might slightly deviate from what is produced by Stata. This is currently the best achievable result. After updating asdocx, you can try the following example

    
    asdocx tabdisp when, c(bp) by(sex) concise replace
      
                                 Tabulation of bp : sex = 1
      0 |1                                                   2 
    ----+-----------------------------------------------------------------------------
      1 |Status                                             bp 
    ----+-----------------------------------------------------------------------------
      2 |Before                                            143 
      3 |After                                             153 
    ----------------------------------------------------------------------------------
    Notes:
      
       
                               Tabulation of bp : sex = Male
      0 |1                                                   2 
    ----+-----------------------------------------------------------------------------
      1 |Status                                             bp 
    ----+-----------------------------------------------------------------------------
      2 |Before                                            152 
      3 |After                                             149 
    ----------------------------------------------------------------------------------
    Notes:
    
    Attaullah Shah
    Moderator
    Post count: 80

    Hello Isabel
    I have resolved a syntax parsing issue that was present in the previous version. In the future, when reporting an issue, it would be helpful if you could also share a dummy dataset. This would allow me to replicate the issue more efficiently. To update to the most recent version, please type

    asdocx_update

    . To demonstrate that the updated version is functioning correctly with the mixed command, I have used a dataset from Stata.

    
    * Get the example dataset
    webuse productivity
    
    * Make the nested regression table with asdocx
    asdocx mixed gsp private emp hwy water other unemp || state: if unemp >5 & region == 2 , mle replace nest
    asdocx mixed gsp private emp hwy water  unemp || state: if unemp >5 & region == 2 , mle  nest
    asdocx mixed gsp private emp  water  unemp || state: if unemp >5 & region == 2 , mle  nest
    
    * The output 
    
                               Table: Regression results
      0 |1                                        2                 3                 4 
    ----+-----------------------------------------------------------------------------------------
      1 |                                       (1)               (2)               (3) 
      2 |Variables                              gsp               gsp               gsp 
    ----+-----------------------------------------------------------------------------------------
      3 |private                              0.068             0.138           0.197** 
      4 |                                   (0.095)           (0.087)           (0.093) 
      5 |emp                               1.326***          1.243***          0.974*** 
      6 |                                   (0.163)           (0.149)           (0.132) 
      7 |hwy                              -0.705***         -0.257***                   
      8 |                                   (0.095)           (0.086)                   
      9 |water                              -0.099*            -0.037            -0.003 
     10 |                                   (0.058)           (0.043)           (0.043) 
     11 |other                               0.3***                                     
     12 |                                   (0.079)                                     
     13 |unemp                                0.001                 0           -0.005* 
     14 |                                   (0.004)           (0.003)           (0.003) 
     15 |Intercept                         4.849***           2.79***           1.511** 
     16 |                                   (0.226)           (0.628)            (0.61) 
     17 |lns1_1_1:Intercept                 -13.121         -2.922***         -2.494*** 
     18 |                               (64553.719)           (0.463)           (0.446) 
     19 |lnsig_e:Intercept                -3.685***         -3.778***         -3.721*** 
     20 |                                   (0.104)           (0.109)           (0.109) 
     21 |Observations                            46                46                46 
    ----------------------------------------------------------------------------------------------
    Notes:  Standard errors are in parentheses. *** p<.01, ** p<.05, * p<.1
    
    Attaullah Shah
    Moderator
    Post count: 80

    I have fixed the issue reported by Keiji Muramatsu. This will hopefully also fix the other issues reported by Kevin. If the update does not solve the other issues, Kevin may like to post an example.

    asdocx_update
    webuse citytemp2, clear
    
    gen group=mod(_n, 3)
    
    asdocx tab region agecat if tempjan >22, by(group) replace
    
                         Tabulation of region agecat : group = 0
      0 |1                                2            3            4            5 
    ----+-----------------------------------------------------------------------------
      1 | Census Region              agecat                                        
      2 |                             19-29        30-34          35+        Total 
    ----+-----------------------------------------------------------------------------
      3 |NE                              11           28           12           51 
      4 |N Cntrl                          7           31           10           48 
      5 |South                           46           23           14           83 
      6 |West                            51           25            7           83 
      7 |Total                          115          107           43          265 
    ----------------------------------------------------------------------------------
    Notes:
      
       
                          Tabulation of region agecat : group = 1
      0 |1                                2            3            4            5 
    ----+-----------------------------------------------------------------------------
      1 | Census Region              agecat                                        
      2 |                             19-29        30-34          35+        Total 
    ----+-----------------------------------------------------------------------------
      3 |NE                              11           27           13           51 
      4 |N Cntrl                          7           30           10           47 
      5 |South                           47           22           15           84 
      6 |West                            51           24            8           83 
      7 |Total                          116          103           46          265 
    ----------------------------------------------------------------------------------
    Notes:
      
       
                          Tabulation of region agecat : group = 2
      0 |1                                2            3            4            5 
    ----+-----------------------------------------------------------------------------
      1 | Census Region              agecat                                        
      2 |                             19-29        30-34          35+        Total 
    ----+-----------------------------------------------------------------------------
      3 |NE                              10           28           12           50 
      4 |N Cntrl                          7           31           10           48 
      5 |South                           46           23           14           83 
      6 |West                            52           24            8           84 
      7 |Total                          115          106           44          265 
    ----------------------------------------------------------------------------------
    Notes:
    
    
    Attaullah Shah
    Moderator
    Post count: 80

    Here is something you can work with. I tried to find the colvector for variable names, but did not find. But I was in hurry, you may find it somewhere in the gtools documentations.

    sysuse auto, clear
    gstats tab price mpg, by(foreign strvar) matasave
    
    * Get the statistics matrix from the GstatsOutput class
    * Note: We need to convert the real matrix to string first
    mata stat_values = strofreal(GstatsOutput.output)
    
    * Get the names of the statistics
    mata stat_names = GstatsOutput.statnames
    
    * Combine the two matrices
    mata outtable = stat_names \ stat_values
    
    * Add the matrix to asdocx system
    flexmat reset
    flexmat addmat, matname(outtable) 
    
    * Export to word
    asdocx export
    
      0 |1            2             3          4          5             6 
    ----+------------------------------------------------------------------
      1 |n          sum          mean        min        max            sd 
    ----+------------------------------------------------------------------
      2 |4        19162        4790.5       3799       6486      1169.903 
      3 |4           93         23.25         19         26       3.40343 
      4 |2         9129        4564.5       4195       4934      522.5519 
      5 |2           42            21         18         24      4.242641 
      6 |8        47741      5967.625       3667      14500      3579.357 
      7 |8          153        19.125         14         24      3.758324 
      8 |27      178391      6607.074       3291      15906      3661.267 
      9 |27         513            19         12         29      4.085622 
     10 |9        52934      5881.556       3829       8814      1592.019 
     11 |9          166      18.44444         14         28      4.585605 
     12 |2         8409        4204.5       3984       4425      311.8341 
     13 |2           64            32         30         34      2.828427 
     14 |1        12990         12990      12990      12990             . 
     15 |1           14            14         14         14             . 
     16 |3        14486      4828.667       3895       6295      1285.613 
     17 |3           70      23.33333         21         26      2.516611 
     18 |9        56353      6261.444       3995       9735      1896.092 
     19 |9          224      24.88889         21         30      2.713137 
     20 |9        56634      6292.667       3748      11995      2765.629 
     21 |9          237      26.33333         17         41      9.367497 
    -----------------------------------------------------------------------
    
    Attaullah Shah
    Moderator
    Post count: 80

    The use of both \indent and \i directives simultaneously is currently not supported. However, it is on my to-do list for future updates. Additionally, the addition of formatting directives for table headers is also not yet available. The text formatting directives were added specifically for text and paragraphs, see [ details here ].

    Attaullah Shah
    Moderator
    Post count: 80

    Ozer Erdem
    I have updated asdocx. It now fixes the decimal points problem in the ttest results. You should now be able to see accurate decimal points in your results.

    Additionally, for very small values, using the c#_disfmt(%9.4e) format is a better way to report values in exponential format. For example, instead of seeing 0.00000009 , you would see 9.00e-08. This helps in making the results easier to read and understand.

    asdocx_update 

    Here is an example:

     * Create a dummy dataset
    clear
    input float group double score
    1 .0000012
    1 .000015
    1 .0000214
    2 .011
    2 .039
    2 .0610
    end
    
    * Report 7 decimal places for the column 4
    asdocx ttest score,  replace  c4_dec(7) by(group) stat(obs mean t)
                                     Table: Results
      0 |1                             2          3              4          5           6 
    ----+------------------------------------------------------------------------------------------
      1 |                          obs1       obs2          Mean1      Mean2      t_value 
    ----+------------------------------------------------------------------------------------------
      2 |score by group: 1 2           3          3      0.0000125      0.037      -2.556 
    -----------------------------------------------------------------------------------------------
    
    * Report exponential format for column 4
    asdocx resetfmt
    
    asdocx ttest score,  replace  tzok c4_disfmt(%9.4e) by(group ) stat(obs mean t)
    
    Two-sample t test with equal variances
    ------------------------------------------------------------------------------
       Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
    ---------+--------------------------------------------------------------------
           1 |       3    .0000125    5.96e-06    .0000103   -.0000131    .0000382
           2 |       3        .037    .0144684    .0250599   -.0252523    .0992523
    ---------+--------------------------------------------------------------------
    combined |       6    .0185063     .010501     .025722   -.0084873    .0454999
    ---------+--------------------------------------------------------------------
        diff |           -.0369875    .0144684               -.0771581    .0031831
    ------------------------------------------------------------------------------
        diff = mean(1) - mean(2)                                      t =  -2.5564
    Ho: diff = 0                                     degrees of freedom =        4
    
        Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
     Pr(T < t) = 0.0314         Pr(|T| > |t|) = 0.0629          Pr(T > t) = 0.9686
    
    
       
                                       Table: Results
      0 |1                             2          3             4          5           6 
    ----+----------------------------------------------------------------------------------------
      1 |                          obs1       obs2         Mean1      Mean2      t_value 
    ----+----------------------------------------------------------------------------------------
      2 |score by group: 1 2       3.000      3.000      1.25e-05      0.037      -2.556 
    ---------------------------------------------------------------------------------------------
    Notes:
    
    Attaullah Shah
    Moderator
    Post count: 80
    in reply to: number formatting #17605

    As mentioned here, permanent options are set only in the asdocx_defaults.ado file. Other options, such as decimal points, fonts, and number formatting, are either specific to a particular command or specific to the Stata session. These session-specific options will reset to the default values when Stata is restarted. If you’ve been running Stata for several days without shutting down your computer, these options might have remained in the memory. At any point in your Stata session, if you wish to reset these formattings to default, you may use the command

    asdocx resetfmt
    Attaullah Shah
    Moderator
    Post count: 80

    Support for confidence intervals with survey data has been added. Try this example after updating.

    asdocx_update 
    
    * Results from the Stata command  
    svy: tabulate  diabetes race  , row  ci 
    
    ----------------------------------------------------------------------
    Diabetes  |                            Race                           
    status    |         White          Black          Other          Total
    ----------+-----------------------------------------------------------
     Not diab |         .8812          .0931          .0257              1
              | [.8437,.9107]   [.0705,.122]  [.0111,.0586]               
              | 
     Diabetic |         .8203          .1647          .0151              1
              | [.7476,.8755]  [.1203,.2213]  [.0033,.0668]               
              | 
        Total |         .8791          .0955          .0253              1
              | [.8407,.9093]  [.0725,.1249]  [.0108,.0585]               
    ----------------------------------------------------------------------
    
    * In asdocx, we need to write the treatment variable first 
    asdocx svy: tabulate race diabetes, row  ci  template(table1) replace cat(% ci)  
    Table 1: Demographics
    Variables White (n=9065) Black (n=1086) Other (n=200) P-value
    Diabetes status 0.000
    Not diabetic
    88.121% (84.370 – 91.068) 9.308% (7.045 – 12.201) 2.571% (1.106 – 5.862)
    Diabetic
    82.028% (74.756 – 87.553) 16.467% (12.027 – 22.134) 1.505% (0.325 – 6.680)
    P-values by t-test for continuous variables and Chi2 test for binary/categorical variables. * Design-based Pearson Chi2 test p-value
    Attaullah Shah
    Moderator
    Post count: 80




    I have added the requested feature. First update asdocx with

    asdocx_update

    . Here is an example.

    * Create a toy example
    *generate random number of observations
    clear 
    set obs 200
    
    * create variable for using sleeping pills
    gen use_pills = round(runiform(0,1))
    label define use_pills 0 "Yes" 1 "No"
    label val use_pills use_pills
    label var use_pills "Used sleeping pills in the last month"
    
     *create variable for male and female
    gen gender = round(runiform(0,1))
    label define gender 0 "Female" 1 "Male"
    label val gender gender
    replace use_pills = 1 if gender == 1 & use_pills == 0 & runiform()<0.7
    replace use_pills = 0 if gender == 0 & use_pills == 1 & runiform()<0.3
    

    Row percentage with confidence intervals


    * if row percentages are required

    asdocx tab use_pills gender, template(table1) row cat(% ci) replace 
    Table 1: Demographics
    Variables Yes (n=79) No (n=121) Total (200) P-value
    gender 0.000
    Female
    64.444% (53.921 - 73.735) 35.556% (26.265 - 46.079) 100.000%
    Male
    19.091% (12.731 - 27.622) 80.909% (72.378 - 87.269) 100.000%
    P-values by t-test for continuous variables and Chi2 test for binary/categorical variables.
    * If the total column is not required, use option nototal
    * Add option table_layout(auto) for auto adjust columns for contents
    asdocx tab use_pills gender, template(table1) row cat(% ci) /// 
    replace nototal table_layout(auto)
    Table 1: Demographics
    Variables Yes (n=79) No (n=121) P-value
    gender 0.000
    Female
    64.444% (53.921 - 73.735) 35.556% (26.265 - 46.079)
    Male
    19.091% (12.731 - 27.622) 80.909% (72.378 - 87.269)
    P-values by t-test for continuous variables and Chi2 test for binary/categorical variables.

    Column percentages

    * If col percentages 
    asdocx tab use_pills gender, template(table1) col categorical(% ci) replace 
    Table 1: Demographics
    Variables Yes (n=79) No (n=121) Total (200) P-value
    gender 0.000
    Female
    73.418% (62.455 - 82.097) 26.446% (19.294 - 35.097) 45.0% (38.203 - 51.989)
    Male
    26.582% (17.903 - 37.545) 73.554% (64.903 - 80.706) 55.0% (48.011 - 61.797)
    P-values by t-test for continuous variables and Chi2 test for binary/categorical variables.

    Attaullah Shah
    Moderator
    Post count: 80

    I have not personally used table1 in my research. Can you advise me if it is appropriate to report confidence intervals for categorical variables?

    Attaullah Shah
    Moderator
    Post count: 80

    I was previously using an older version of missings that I downloaded from SSC. However, the latest version available on the Stata Journal website at dm0085_2 from http://www.stata-journal.com/software/sj20-4 has the new option identify(). To get the updated version that works with asdocx, type the following in Stata command window:

    net install asdocx_missings, from(http://fintechprofessor.com) replace

    After the update, the option identify() should work.

    webuse nlswork
    asdocx missings table, identify(race) replace
    Checking missings in all variables: 15082 observations with missing values
    race
    # of missing values white black other Total
    0 9604 3709 139 13452
    1 9672 3966 152 13790
    2 677 278 9 964
    3 199 89 3 291
    4 25 7 0 32
    5 1 1 0 2
    6 2 1 0 3
    Total 20180 8051 303 28534
    Notes:
    Attaullah Shah
    Moderator
    Post count: 80

    Please post the code that you used. I searched for the identify option in missings , but did not find anything related to it.

    Attaullah Shah
    Moderator
    Post count: 80

    I am happy to announce the missings is now supported in asdocx, see details here .

    Attaullah Shah
    Moderator
    Post count: 80

    This is one of the un-documented directive. When asdocx tries to convert flexmat file into MS Word or other formats, it examines each cell of the matrix for the \indent_# directive. Here, # represents the number of spaces that should be added before the text in that cell. For example, if a cell starts with \indent_4 , it will add four spaces before the text.
    You may also like to check text directors to format text, see this page.

    Example

    flexmat reset 
    asdocx setfile, save(indent.html) replace
    flexmat addrow, data(Variables, Frequencies)
    flexmat addrow, data(Gender :) row(2)
    flexmat addrow, data(\indent_4 Male, 655) row(3)
    flexmat addrow, data(\indent_4 Female, 745) row(4)
    asdocx export
    
    Table: Results
    Variables Frequencies
    Gender :
    Male
    655
    Female
    745
    Notes:
Viewing 15 posts - 16 through 30 (of 80 total)