Announcement

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

  • asdoc: An easy way of creating publication quality tables from Stata commands

    I am really excited to announce the launch of my new program asdoc that sends Stata output to MS Word or RTF format. asdoc creates high-quality, publication-ready tables from various Stata commands such as summarize, correlate, pwcorr, tab1, tab2, tabulate1, tabulate2, tabstat, ttest, regress, table, amean, proportions, means, and many more. Using asdoc is pretty easy. We need to just add asdoc as a prefix to Stata commands [See this short blog entry for quick start]. asdoc has several built-in routines for dedicated calculations and making nicely formatted tables.

    Installation
    The program can be installed from SSC by typing the following in Stata command window:

    Code:
    ssc install asdoc, replace
    Once installed, you can read the help file with
    Code:
    help asdoc
    The help file is very generous in providing examples and discussions. It has 79 examples.



    Key Features
    Though the help file and my website page provide sufficient details on different aspects of the program, let me highlight the key features of the program below:

    1. Nicely formatted tables for frequently used statistics
    asdoc has dedicated routines for producing nicely formatted tables of most frequently used statistics such as summary statistics, correlations, regressions, frequency tables, and t-tests. Users can easily specify the number of decimal points, font size, table titles, column titles, and other aspects of these statistics.

    2. Full and nested regression tables
    asdoc can create two types of regression tables. The first type (call it detailed) is the detailed table that combines key statistics from the Stata's regression output with some additional statistics such as mean and standard deviation of the dependent variable etc. This table is the default option in asdoc. The second table is a compact table that nests more than one regressions in one table (call it nested). There also a YouTube video that shows how to create nested regression tables with asdoc. Both types of tables are publication-quality and can be directly used in research papers and theses, etc.

    3. Writing all statistics to one document
    asdoc provides the convenience of writing all statistics to a single document with its option append. Even it allows the construction of tables in pieces with its option rowappend. Further, it allows adding text or paragraphs with an option text. This is useful when we want to add details or comments with the Stata output.

    4. Formatted tables of t-tests
    The primary challenge in reporting results of the ttest command is what statistics to report and in which format to report. The format should be such that it occupies minimum space possible. Over many other possibilities, I preferred the format of a single line for all types of t-tests. Therefore, whether it is one-sample t-test or two-sample or other forms, asdocmanages to report the results line by line for each test. asdoc also allows accumulating results from different runs of t-tests. For this purpose, the option rowappend of asdocreally comes handy.

    5. Frequency tables
    asdoc has several built-in routines for reporting properly formatted frequency tables. As with other commands, we need to just add asdoc as a prefix to the tabulation commands that includes tabulate, tabulate1 tabulate2, tab1, and tab2, etc.

    6. Compact tables
    asdoc makes some elegant tables when used with tabstat command. There are several custom-made routines in asdoc that create clean tables from tabstat command. asdoc fully supports the command structure and options of tabstat. And, yes asdoc allows one additional statistics, that is, t-statistics alongside the allowed statistics in tabstat. For reporting purposes, asdoc categorizes tabstat commands in two groups: (1) stats without a grouping variable (2) stats over a grouping variable.

    7. Flexible tables
    Exporting tables from table command was the most challenging part of asdoc programming. Nevertheless, asdoc does a pretty good job in exporting table from table command. Therefore, asdoccan export one-way, two-way, three-way, and four-way tables.

    8. Exporting dataset
    Stata's list command displays the values of variables. asdoc can export these values to a file in form of a nicely formatted table. asdoc implements the most basic version of list command and might not accept some of its options such as mean, sum, etc. However, the [if] [in] qualifiers are accepted.

    9. Exporting Stata matrix
    asdoc can export a Stata's matrix to a file in form of a nicely formatted table.

    10. List of unique values
    To report one value per group or unique values of varlist, we can use the aslist command of asdoc

    11. Export variable names and labels to a table
    asdoc can be used with the Stata describe command to make a table of variable names, labels, etc.

    12. Other Stata commands
    Stata commands that have some output in the result window can also be used with asdoc . Even when a command does not have an output and asdoc is unintentionally added as a prefix, asdoc will just pass the command to Stata without generating any output. asdoc might come up with a less than pretty output if it is used with a Stata command that does not have a standard table format. If a user-written command that estimates regression model is used with asdoc, option isregcan be used to tell asdoc that the command is a regression command.


    Acknowledgment

    Professor River provided helpful suggestions on improving the display format of the correlation tables.

    Since this is the first version, programming bugs are likely to exist. I shall really appreciate comments and suggestions for improving asdoc. You can reach me at attaullah.shah@imsciences.edu.pk

    Support website: www.FinTechProfessor.com

  • Attaullah Shah
    replied
    joel hicks I have update asdoc. There are several updates including fixing the labeling issue with factor variables. Other fixes include:

    *! Version 2.3.5.0: Changes made July 13 , 2019: tab command with string variables

    ! Version 2.3.4.9: Changes made July 12 , 2019: Label now works with factor variables in regressions

    *! Version 2.3.4.8: Changes made July 03 , 2019: Significance stars customizable using setstar() option.

    *! Version 2.3.4.8: Changes made June 29 , 2019: weights added to the table command

    *! Version 2.3.4.7: Changes made June 25 , 2019: aweights added

    *! Version 2.3.4.6: Changes made June 25 , 2019: stat() option of nested reg improved

    *! Version 2.3.4.5: Changes made June 24 , 2019: Total row added to the tab command

    *! Version 2.3.4.4: Changes made June 24 , 2019: Table command now supports date/time variables

    *! Version 2.3.4.3: Changes made June 19, 2019: File saving made easy. Just use
    Code:
    global save "Whatever file name"
    or use option save() first time with asdoc, then asdoc will remember the file name until Stata is closed or another name is written to the global save macro

    *! Version 2.3.4.2: Changes made June 19, 2019: Support for empty value in accum option, used with row option: 2. Integers do not have decimal points now in option row()

    *! Version 2.3.4.1: Changes made June 15, 2019: option label added to list command;

    *! Fixing bys sum in MacOS

    *! Version 2.3.4 : Changes made June 6, 2019: eform() logistic p-values correction in nested table

    *! Version 2.3.3.9: command replay added. This is used with bootstrap or other regressions that have complex syntax

    *! Version 2.3.3.8: Adding significance level for multi-levels using the setstars() option.

    The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
    Code:
    net install asdoc, from(http://fintechprofessor.com) replace
    Please note that the above line has to be copied in full. After installation of the new version, then restart Stata.

    Please do remember to cite asdoc. To cite:
    In-text citation
    Tables were created using asdoc, a Stata program written by Shah (2018).

    Bibliography
    Shah, A. (2018). ASDOC: Stata module to create high-quality tables in MS Word from Stata output. Statistical Software Components S458466, Boston College Department of Economics.
    Last edited by Attaullah Shah; 12 Jul 2019, 17:12.

    Leave a comment:


  • Attaullah Shah
    replied
    Moritz Scheidenberger Thanks for your feedback. Means a lot.

    Leave a comment:


  • Moritz Scheidenberger
    replied
    After all these hours of searching, you saved my day Sir!
    From the bottom of my heart, thank you!
    hope you have a great day, you deserve it!

    Leave a comment:


  • Attaullah Shah
    replied
    joel hicks Thanks for reporting this. I shall come back with a fix.

    Leave a comment:


  • joel hicks
    replied
    I am having problems with using the "label" command with factor variables in regressions. Although the reg command displays my label names associated with factor variables, the asdoc reg command does not. It just lists "1" "2", etc. with the variable name.

    Leave a comment:


  • Attaullah Shah
    replied
    asdoc has been updated on SSC, thanks to Prof. Kit Baum. This is Version 2.3.4.1: Changes made June 15, 2019:

    The updated version has fixed several issues and added all those features which were requested in the above posts or on my website. I shall post details in a later post. The updated version can be installed by
    Code:
    ssc install asdoc, replace
    help asdoc

    Leave a comment:


  • River Huang
    replied
    Dear Attaullah, Thanks a lot. It works well.

    Leave a comment:


  • Attaullah Shah
    replied
    River Huang I have added p95 statistics to the stat option. Please check and let me know if there is any issue
    To install this new version, please use the following line of code
    Code:
     
     net install asdoc, from(http://fintechprofessor.com) replace

    Leave a comment:


  • River Huang
    replied
    Dear Attaullah, Could you please add an extra option in your helpful asdoc? In particular, the option p95 is not available.
    Code:
     asdoc sum, stat(N mean sd p5 p25 p50 p75 p95) replace

    Leave a comment:


  • River Huang
    replied
    Dear Attaullah, Thanks for the suggestions. I will give it a try.
    Last edited by River Huang; 02 Jun 2019, 18:16.

    Leave a comment:


  • Attaullah Shah
    replied
    This can be done with one click inside MS Word. I can do it programmatically but would need some time. Till then, the quick fix is shown below in a picture. These are the steps"
    1. Click inside the given table
    2. The Table tools menu appears
    3. Click on Layout
    4. Click on Autofit
    5. Click on Autofit Contents
    Click image for larger version

Name:	Untitled.png
Views:	1
Size:	145.1 KB
ID:	1501239

    Leave a comment:


  • River Huang
    replied
    Dear Attaullah, I ran the following code (I have also updated the asdoc code via net install asdoc, from(http://fintechprofessor.com) replace)
    Code:
    sysuse nlsw88.dta, clear
    asdoc pwcorr age ttl_exp hours grade race wage, star(all) nonum replace
    and got this result in Word format
    Click image for larger version

Name:	asdoc-all.png
Views:	1
Size:	23.3 KB
ID:	1501234

    I wonder if the stars can be aligned some ways? Thanks.

    Leave a comment:


  • Liu Qiang
    replied
    Originally posted by Attaullah Shah View Post
    Dear Liu Qiang
    I have added support for bootstrap regressions in asdoc.

    This beta version can be installed from my site.
    Code:
    net install asdoc, from(http://fintechprofessor.com) replace
    An Example

    Since the bootstrap command has a complex syntax structure, I have separated it from asdoc. So first we shall enter the full bootstrap command and then use replay command with asdoc. See the following example.

    Code:
    clear all
    sysuse auto, clear
    bootstrap _b, reps(100): qreg price weight length, quantile(10)
    
    asdoc replay, nest save(result1) replace cnames(Q10)
    
    bootstrap _b, reps(100): qreg price weight length, quantile(20)
    asdoc replay, save(result1) nest cnames(Q20)
    [ATTACH=CONFIG]n1501131[/ATTACH]
    Many thanks. This is extremely helpful and what I really want!

    Leave a comment:


  • Attaullah Shah
    replied
    Dear Liu Qiang
    I have added support for bootstrap regressions in asdoc.

    This beta version can be installed from my site.
    Code:
      
     net install asdoc, from(http://fintechprofessor.com) replace
    An Example

    Since the bootstrap command has a complex syntax structure, I have separated it from asdoc. So first we shall enter the full bootstrap command and then use replay command with asdoc. See the following example.

    Code:
    clear all
    sysuse auto, clear
    bootstrap _b, reps(100): qreg price weight length, quantile(10)
     
     asdoc replay, nest save(result1) replace cnames(Q10)
     
     bootstrap _b, reps(100): qreg price weight length, quantile(20)
     asdoc replay, save(result1)  nest cnames(Q20)
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	41.6 KB
ID:	1501131

    Last edited by Attaullah Shah; 01 Jun 2019, 13:02.

    Leave a comment:

Working...
X