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

  • Willem Boorsma
    replied
    Great, it worked!

    Thanks for your help and for your great command.

    Leave a comment:


  • Attaullah Shah
    replied
    Seems to me the problem is caused by your university account, possibly interfering with the installation. The three asdoc files are given in this zipped folder https://www.dropbox.com/s/terpqll6ev...asdoc.zip?dl=1 . Files asdoc.ado and asdoc.sthlp should be placed in
    Code:
     c:/ado/plus/a
    And lasdoc.mlib file should be placed inside


    Code:
    c:/ado/plus/l
    The last letter is small L

    Leave a comment:


  • Willem Boorsma
    replied
    I already tried reinstalling obviously, however that does not work for me.

    I am currently using Stata 15.1 on Windows 7 Enterprise (University account).

    Leave a comment:


  • Attaullah Shah
    replied
    Please reinstall asdoc by
    Code:
    ssc install asdoc, replace
    If the problem persists, then please send the following information:
    Your Stata version
    Operating system

    Leave a comment:


  • Willem Boorsma
    replied
    Hi,

    asdoc was very useful for me so far, however I encountered a problem lately.

    Code:
    sysuse auto, clear
    asdoc sum price
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
           price |         74    6165.257    2949.496       3291      15906
                    
    <istmt>:  3499  asdocsum() not found
    
    r(3499);
    It seems Stata does not recognise the asdoc command and combines it with sum.
    Furthermore, I can't find myfile.doc anywhere.

    Leave a comment:


  • Cooper Felix
    replied
    Thanks for the great command, which saved me tons of time.

    Leave a comment:


  • Attaullah Shah
    replied
    The new version of asdoc has been uploaded to the SSC. Details of the updates are given in this post
    https://www.statalist.org/forums/for...ord-from-stata

    Leave a comment:


  • Attaullah Shah
    replied
    A big update is around the corner. It will significantly upgrade asdoc, including the option for setting the font style. Do check back in a week or two.

    Leave a comment:


  • Sang-Bum Park
    replied
    Thank you for your reply, Attaullah Shah. Can font also be changed into other types such as Times New Roman?

    Leave a comment:


  • Attaullah Shah
    replied

    Here is one example of using asdoc with the Hausman test

    Code:
    * Use the grunfeld dataset in the example
    webuse grunfeld
    
    * Estimate the fixed effect model
    xtreg invest mvalue kstock, fe
    
    * Store the estimates of the fixed effect model. 
    estimates store fixed
    
    * Estimate the random effects model
    xtreg invest mvalue kstock, re
    
    * Store the estimates of the random effects model
    estimates store random
    
    * Apply the Hausman test and write its results to Word file using asdoc
    asdoc hausman fixed random
    Click image for larger version

Name:	hausman.png
Views:	1
Size:	7.0 KB
ID:	1484976

    Last edited by Attaullah Shah; 22 Feb 2019, 01:24.

    Leave a comment:


  • Sang-Bum Park
    replied
    Can asdoc also produce a result table of Hausman test?

    Leave a comment:


  • Attaullah Shah
    replied
    Thanks for your feedback.

    Leave a comment:


  • Kiran Abro
    replied
    Attaullah Shah yes i got it and copied table to my results doc and closed it. however, this is really great you have done marvelous job.

    Leave a comment:


  • Attaullah Shah
    replied
    Kiran Abro Sounds great that you have solved your problem. However, the error message that you have reported "
    File Myfile.doc already exists, option append was assumed)
    file Myfile.doc could not be opened for read/write"
    occurs when the file is open and you are trying to write to it. When you run asdoc and save to the same file which is currently open, it will not work. Either, you have to close the file or use a different file name using the option save(File_name).

    Leave a comment:

Working...
X