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

  • Shoummo Sen Gupta
    replied
    Originally posted by Attaullah Shah View Post
    Shoummo Sen Gupta Support for the IN and IF conditions has been added. 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.
    Thank you.

    Leave a comment:


  • Attaullah Shah
    replied
    Shoummo Sen Gupta Support for the IN and IF conditions has been added. 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.

    Leave a comment:


  • Shoummo Sen Gupta
    replied
    Dear Professor Shah,

    First of all thank you for this excellent programme.

    I was running this:

    sysuse auto,clear
    asdoc table price mpg foreign if mpg>20, replace

    But there is some issue with this command, the if condition is not being taken into the account and the output shows all the values of mpg.

    Leave a comment:


  • carole fantini
    replied
    Hello
    thanks a lot for this amazing tool. is there a way to use asdoc with robust regression? the followinng syntax report an error : asdoc nestreg:regress HADSDEP (Age Sexe) (c.rmssdc c.dersc) c.DERSXHRV, vce(hc3) beta replace

    error : option hc3 not allowed
    thanks a lot for your help

    Leave a comment:


  • Attaullah Shah
    replied
    Youshida Koki the mentioned feature has been added to asdoc. You can try the new version. 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.

    Leave a comment:


  • Youshida Koki
    replied
    Is there a way to export value labels of factor variables when creating the detailed regression table?

    Leave a comment:


  • Attaullah Shah
    replied
    Mario Sum thanks for the appreciation.

    Leave a comment:


  • Mario Sum
    replied
    Dear @Attaullah Shah,
    thank you so much for even posting a workaround - this is the icing on the cake.

    Leave a comment:


  • Attaullah Shah
    replied
    The mixed command has a complex syntax structure. To simply parsing the syntax, asdoc offers the replay sub-command. So first we shall run the mixed command without asdoc, and then run asdoc with sub-command replay. See this example

    Code:
    webuse nlswork
    
    mixed ln_w grade age c.age#c.age ttl_exp tenure c.tenure#c.tenure || id:
    
    asdoc replay, replace  nest

    Leave a comment:


  • Umito Takao
    replied
    Dear @Attaullah Shah
    I have been trying to export the results of mixed (multilevel models) with asdoc.
    However, an error
    Code:
    func_nested_reg():  3200  conformability error
                     <istmt>:     -  function returned error
    r(3200);
    appeared when I tried this:
    Code:
    asdoc mixed cci opeind_lag1w gdpcapitaw fhouseprw rentsw ///
    opeind_lag1_mean cgdpcapita_mean cfhousepr_mean crents_mean cconflict_mean ///
    ccomlaw_mean clandlock_mean cprotestant_mean || cntrynum: opeind_lag1, vce(robust), ///
    save(Table4.doc) title(Table 4. Effect of political/operational independence on CCI) ///
    nest append stars cnames(Model 8) add(Operational independence, YES, Random slope, YES)
    I would really appreciate it if you could tell me what's wrong with my code! Thank you.

    Leave a comment:


  • Attaullah Shah
    replied
    Mario Sum
    Thanks for your kind words. And I like the suggested use of asdoc as a verb. So to asdoc summary statistics using two variables in the bysort prefix, there is a workaround, though this approach is not a preferred one due to additional lines of coding. I have this on my agenda for the next update of asdoc to add support for more than one variable in the bysort prefix. The workaround is to create a grouping variable from two or more variables and then use the grouping variable in the bysort prefix.

    Code:
    egen group = group(foreign  id)
    label define idl 1 "domestic - small" 2 "domestic - big" 3 "Foreign - small" 4 "Foreign - big"
    label value group idl
    bys group : asdoc sum trunk, replace
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	27.5 KB
ID:	1511596

    Leave a comment:


  • Mario Sum
    replied
    Thank you for the hint.
    This results in the stratification only by id, though. The presort by foreign invoked by
    Code:
    (foreign)
    is not considered for the calculation of statistics.

    Leave a comment:


  • Chen Samulsion
    replied
    Mario Sum perhaps you can try
    Code:
    bysort id (foreign): asdoc sum trunk

    Leave a comment:


  • Mario Sum
    replied
    Only by chance I came across this wonderful program - thank you so much!

    However, I encounter an issue when trying to asdoc (it even became part of the vocabulary) summary statistics by two subgroups.
    Code:
    sysuse auto, clear
    generate id = (price<=5000)
    sort                id    foreign
    asdoc by            id    foreign:    sum trunk
    Code:
    asdoc sum trunk, by(id    foreign)
    bys id    foreign: asdoc sum trunk
    do not work neither.

    But that is just marginal; I am so glad and thankful for this piece of art.

    Leave a comment:

Working...
X