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
    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:


  • Kiran Abro
    replied
    issue resolved i just copied that table in another word doc and unsaved it from my.doc

    Leave a comment:


  • Kiran Abro
    replied
    this is very useful command. i was in search of this command and after days this post solved my problem. this is highly appreciated Professor Ataullah Shah. i just tried it for descriptive statistics and worked. then i tried it for correlation but stata issued an error message.

    (File Myfile.doc already exists, option append was assumed)
    file Myfile.doc could not be opened for read/write
    fopen(): 603 file could not be opened
    append(): - function returned error
    <istmt>: - function returned error
    r(603);

    Leave a comment:


  • Attaullah Shah
    replied
    Wawan Sugiyarto Today, I had some time so wrote this blog post to show the use of asdoc with ttest. The post uses your data. The output shown there is the standard output generated by asdoc with ttest command. If you need a more customized table, you can explore the row() option of asdoc, further details can be found in the help file of asdoc and in this blog post.

    Leave a comment:


  • Wawan Sugiyarto
    replied
    Dear Professor Shah,

    Thank you so much for your sharing. Your program is useful.

    I have problem with tabulate ttest ( Return=0) result in one table such as below (I input result manually one by one).

    ttest R0==0 if Y==2009
    ttest R1==0 if Y==2009
    ttest R2==0 if Y==2009
    ttest R3==0 if Y==2009

    ttest R0==0 if Y==2010
    ttest R1==0 if Y==2010
    ttest R2==0 if Y==2010
    ttest R3==0 if Y==2010

    ttest R0==0 if Y==2011
    ttest R1==0 if Y==2011
    ttest R2==0 if Y==2011
    ttest R3==0 if Y==2011

    ttest R0==0 if Y==2012
    ttest R1==0 if Y==2012
    ttest R2==0 if Y==2012
    ttest R3==0 if Y==2012

    Year Simulation Return (R)
    0 1 2 3
    2009 3 0.60 0.64 0.46 0.71
    (4.55) (3.72) (1.04) (3.26)
    2010 24 0.71 0.90 0.21 0.47
    (1.29) (1.64) (0.87) (2.67)
    2011 12 0.76 1.15 1.32 1.43
    (1.1) (1.77) (1.98) (1.84)
    2012 37 0.14 -0.13 -0.28 -0.26
    (0.74) (-0.63) (-1.04) (-0.99)
    Could you give some advices how to make it automatically?

    This is the dataset:
    R0 R1 R2 R3 Y
    0.004425 0.004425 -0.00405 0.003564 2009
    0.008808 0.010064 0.007259 0.006972 2009
    0.005156 0.005156 0.010822 0.011238 2009
    3.86E-05 -0.00165 -0.00303 -0.0049 2010
    0.009852 0.009852 -0.00301 -0.00524 2010
    0.0015 0.0015 -0.00666 -0.01387 2010
    -0.00061 -0.00045 -0.00055 0.000237 2010
    0.000747 0.000111 9.55E-05 0.001138 2010
    0.000771 -0.00015 -0.00031 0.003995 2010
    -0.00045 -0.00103 -0.00058 -0.00058 2010
    0.135216 0.135216 -0.00072 -0.00072 2010
    0.00053 0.000837 0.001047 -0.00249 2010
    0.001989 0.003614 0.001432 0.001534 2010
    0 0 0.008254 0.004437 2010
    -0.00266 -0.00559 -0.00494 -0.00229 2010
    0.005174 0.005418 0.015735 0.006711 2010
    0.004269 0.004468 0.004966 0.005369 2010
    0.008148 0.00438 -0.0419 0.005287 2010
    0.003946 0.007096 0.009817 0.015561 2010
    -0.00291 -0.00168 0.013342 0.019813 2010
    -0.00099 0.000613 0.003765 0.005096 2010
    -0.00095 -0.0005 0.007085 0.005976 2010
    0.003266 0.004288 0.007994 0.007191 2010
    0.006183 0.013831 -0.00515 0.003334 2010
    -0.00122 0.008168 0.008705 0.01362 2010
    -0.00036 0.011534 0.011966 0.017126 2010
    0.000918 0.0157 0.016885 0.021647 2010
    -0.01485 -0.01605 -0.01102 -0.00409 2011
    0.000353 0.002384 0.007114 0.017022 2011
    1.17E-05 -0.00186 0.009004 0.019676 2011
    -0.00164 0.000718 -5.2E-05 -0.00014 2011
    -3.51E-06 0.007894 0.003445 0.002757 2011
    -0.01009 0.016026 0.008748 -0.0063 2011
    -0.01611 -0.01043 -0.01148 -0.02287 2011
    0.003555 0.005695 0.011899 0.015045 2011
    0.011543 0.011453 0.013921 0.013737 2011
    0.022187 0.019799 0.020925 0.022505 2011
    0.018536 0.022491 0.019312 0.02012 2011
    0.059238 0.057683 0.063242 0.070793 2011
    0.008285 -3.1E-05 0.008224 0.00866 2012
    -0.00331 -0.0031 -0.00147 0.000799 2012
    -0.00205 -0.00235 0.003518 0.004122 2012
    0 0.003083 -0.0041 -0.00099 2012
    -0.01974 -0.02148 -0.02653 -0.0282 2012
    0.011725 0.002618 0.006607 0.004391 2012
    -0.01294 -0.02402 -0.02916 -0.02916 2012
    -0.00598 -0.01672 -0.03051 -0.03051 2012
    -0.0296 -0.03694 -0.05805 -0.05805 2012
    0.002149 -0.01434 -0.03187 -0.03187 2012
    -0.01341 -0.02352 -0.02146 -0.01403 2012
    0.011682 0.005818 -0.00138 0.004351 2012
    0.011756 0.011676 0.009072 0.006166 2012
    -0.00031 0.000313 -0.00034 -0.0019 2012
    0.000194 -0.00158 -0.00173 -0.00393 2012
    7.53E-05 -0.00208 -0.0017 -0.0035 2012
    0.000211 0.002246 0.001557 -0.00141 2012
    -0.00077 -0.00075 0.004118 0.000237 2012
    0.004429 0.004351 0.001652 0.001553 2012
    3.74E-05 -0.0042 -0.00712 0.000216 2012
    -0.00048 -0.00667 -0.00961 -0.00332 2012
    0.027808 0.029803 0.030471 0.026713 2012
    0.001292 -0.00982 -0.01935 -0.02156 2012
    0.034735 0.035506 0.036004 0.029923 2012
    -4E-05 0.000618 0.00168 0.004501 2012
    -0.00413 0.001406 0.003677 0.005576 2012
    -0.00017 -0.00331 -0.00124 0.002687 2012
    -0.00647 -0.00068 -0.00055 -0.00151 2012
    0.025387 -0.00014 0.000211 -0.00081 2012
    -0.00044 0.000535 -0.00017 0.001077 2012
    0.000138 0.000409 0.000608 0.003371 2012
    -0.01455 -0.00714 -0.00626 -0.00299 2012
    0.002515 0.005503 0.005963 0.005356 2012
    -0.00048 0.010277 0.013698 0.011827 2012
    0.022686 0.010046 0.009247 0.004038 2012
    0.011724 0.012328 0.006248 0.000934 2012
    0.001843 0.004669 0.011857 0.016241 2012

    Thank you.

    Kind regards,
    Wawan Sugiyarto

    Leave a comment:


  • Nick Cox
    replied
    EdieMMM Thanks for using your real name Eileen Díaz McConnell as signature.

    Back in #48 you said "I registered this account a long time ago, and I can't change my user name to my real name without setting up a new account". It is true that you can't do that unilaterally, but we explain what to do in your situation in the FAQ Advice which all are asked to read before posting.

    https://www.statalist.org/forums/help#realnames

    You are asked to post on Statalist using your full real name, including given name(s) and a family name, such as "Ronald Fisher" or "Gertrude M. Cox". Giving full names is one of the ways in which we show respect for others and is a long tradition on Statalist. It is also much easier to get to know people when real names are used.

    If you overlook this on first registration, it is easy to fix. Click on “Contact us” located at the bottom right-hand corner of every page.
    -- and send a message to the list administrators

    Leave a comment:


  • EdieMMM
    replied
    Professor Shah:

    Thanks so much for looking into this! I was on another project and just came back to check on this now. Yes, in the interest of providing a simple example, I didn't provide all that was needed. Sorry.

    However, I appreciate your taking the time to discover how to do this with another example. It worked perfectly!

    Also, running "asdoc mi estimate, append" also works so that I can just append rather than replace.

    Asdoc is such a time saver. Thank you.
    Eileen

    Leave a comment:

Working...
X