About asdoc
asdoc is a Stata program that makes it super-easy to send output from Stata to MS Word. asdoc creates high quality, publication-ready tables from various Stata commands such as summarize, correlate, tabstat, tabulate (cross-tabs), regress (regressions), ttest, table, and many more.
Installation
The program can be installed by typing the following from the Stata command window:
ssc install asdoc, update
Table of contents
1. Introduction
1.1 asdoc: short introduction and examples
1.2 Commands for controlling asdoc
2. Summary Statistics
2. Summary statistics
2.1 Basic summary statistics
2.2 Customized summary statistics
3. Correlations
3.1 Correlations [Blog Post]
3.2 Correlations [YouTube Video]
3.3 Correlations with significance stars
4. Regressions
4.1 Full regression tables [YouTube Video]
4.1.1 Customizing the detailed table: Stars and CIS
4.2 Compact / nested tables (publication quality)
4.3 Regression over a grouping variable (YouTube Video)
4.4 Changing order of variables in the nested regression table
5. Frequency tables
5.1 One-way tabulation (tabulate1) Watch YouTube Video
5.2 Two-way tabulation (tabulate2) Watch YouTube Video
5.3 One- and two-way tables of summary statistics (tabsum)
5.4 Multiple-way tables (tab1)
5.5 All-possible two-way tables (tab2)
6. Compact tables (tabstat)
6.1 Without groups
6.2 With groups
7. Flexible table of statistics (table)
7.1 One-way table
7.2 Two-way table
7.3 Three-way table
7.4 Four-way table
8. T-tests
8.1 one-sample t-test
8.2 two-sample using groups
8.3 two-sample using variables
8.4 paired t-test
9. Table of means, std., and frequencies (tabsum)
10. Means
10.1 Arithmetic / harmonic / geometric means
10.2 Proportions
10.3 Ratio
10.4 Total
11. Exporting the Stata Data with the sub-command list
12. Writing matrix to a Word / RTF file
13. The survey prefix command
14. Customized tables with option row
15. Customizing Table Titles – Tips and Tricks
asdocx : Export Stata tables to Excel, LaTeX, or HTML
asdocx is an enhanced version of asdoc that provides an extensive list of improvements. It can also export to four different formats: docx, xlsx, tex, and html. To learn more about the differences between asdocx and asdoc asdocx, you may like to visit this page.
Dear Professor Shah,
Thanks for your prompt reply.
I am not the person who does the installation but the data providers do this (as I cannot access the internet from their server, but I only access the data remotely through their working space).
I can only see 2 files in the folder from which asdoc is called: 1. “asdoc.ado (ADO file)” and 2. “asdoc (Stata SMCL document)”.
Nothing is currently installed in my Stata. Every time I start Stata, I have to install Asdoc (by calling it from the folder mentioned above using the ‘findit’ command).
I was wondering whether perhaps not all necessary asdoc files are stored in that offline folder, so that is why the errors appear? For example, again when I run the “asdoc tabulate” command I receive the following error: “: 3499 asdoc_tab_onevar() not found”.
Could you please name the files that I need to have in place in order to have a complete installation of asdoc? I will then inform the data providers accordingly to download these files.
Thanks again,
Kostas
Actually, there are three files, which are
1. asdoc.ado
2. asdoc.sthlp
3. lasdoc.mlib
The last file is missing from your system and the same old file is used by Stata which has a different function structure than the updated one. Drop me an email at attaullah.shah@imsciences.edu.pk and I shall email you these files.
Dear Professor Shah,
for me, it is only possible to use Stata offline. Is it still possible to somehow install the asdoc command?
Thank you
Finja: You can download the installation files from RePEC IDEA page, second tab with the title Download. Once downloaded, then place these files in relevant folders: So the
asdoc.ado
andasdoc.sthlp
files will go in the following folderThe third file
lasdoc.mlib
will go into the following folderWhere the last letter is small L.
Hi, I love asdoc but am getting the following problem when trying to write estat class after logistic to a word file:
————————————————–
subinstr(): 3200 conformability error
asdocrest_custom(): – function returned error
: – function returned error
r(3200);
Also, is it possible to write the confidence intervals instead of se for my nested table?
Thank you.
Jo
Please post the full Stata code, i.e what did you write and what did Stata say?
Dear Professor Shah,
Is it possible to use asdoc using 3sls regression?
Looking forward to your reply.
Regards
Jaskaran
I have added support for 3sls regressions in asdoc.
This beta version can be installed from my site.
An Example
Since the 3sls command has a complex syntax structure, I have separated it from asdoc. So first we shall enter the full 3sls command and then use replay command with asdoc. See the following example.
Dear professor Shah,
I am using svy with asdoc, but I am creating weighted tables with
and I get this answer “option count not allowed”, help with this issue please.
Esteban Arellano
Adding weighted statistics to svy command would need some good amount of coding and hence I have postponed them until I find enough time for it. Thanks for reminding.
I am trying to obtain a weighted frequency for my variable. I issued the following command:
asdoc tab var1 [aw=weights]
the command returns error, that aweight is not allowed.
Mike:
I have revised asdoc and it accepts aweights now. The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
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.
Dear Prof Attaullah,
I would like to express my thanks for your valuable asdoc state command that I currently use for my data analysis. Very helpful and It’s saving valuable time !!
Thanks !!!
Dear Dr. Shah, Attaullah,
With great interest, I am exploring your Stata package asdoc.
It offers many great options to (quickly) create result reports and tables, which is a very nice additional tool to have available with Stata.
I have a minor bug report.
Once the option save(somename) is used, the default is set to the last save name used. E.g.
does save to sum.doc, but after that:
will again (try to) save to sum.doc and not switch back to the package default Myfile.doc
I assume that you are using a global instead of a local to set the save() option (something that is discouraged).
I have some minor but practical suggestions for additional controls of asdoc.
Just the first most simple format of the summary table, create with:
produces a table with an ’empty’ last row (see attached file sum.docx).
I am not sure why this is the case. Maybe to create some visual distance between the last row of data and the line drawn at the bottom of the table.
If that is the case, well, you could introduce options to control the formatting of the table in MSWord, using code to set Table Properties, but maybe that is ar odd’s with the simplicity & effectiveness of asdoc.
Nevertheless, to be able to set some Table Properties could be practical, like Specific Row Height and Vertical Alignment (Top/Center/Bottom).
I suppose, if the additional bottom row is intentional, it would be helpful to be able to have an option to used it or not, like (no bottom row, see attached file Myfile_Without_Empty_Row.docx):
It is very nice to have the option tzok, like (see attached MydocTzok.docx):
But, it would be nice to be to control which statistics have the get trailing zeros (given the fact that you already do this with N, like (see attached Myfile_Tzok_Selected_Statistics.docx):
It would be helpful to be able to have an option to include a row ‘below’ the table to include a note, like (see attached Myfile_Without_Last_Empty_Row_but_With_Footnote_Row.docx):
Maybe this is helpful (certainly for me it would).
Best regards,
Dr. Eric Melse
Amsterdam University of Applied Sciences
Dear Dr Eric
I’ve added 6 options for:
These options can be invoked by using the column key words such as c1 c2 c3 etc, with underscore the relevant options. For example, to format column 2 in bold, we would add
Format column 5 in italics
use two decimal points for column 3
asdoc sum, c3_dec(2)
Align column 5 text in the center
Use trailing zeros with column 2
These options are then remembered until reset. To reset
5. Further, the last empty row has been removed
6. And even better, option notes now can add notes to the end of the table
So far, I have added this functionality only with sum command.
The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
Please note that the above line has to be copied in full. After installation of the new version, then restart Stata.
Please narrate to install VAR in STATA
Dear,
Does asdoc work in Stata 16? It worked on Stata 15, but after upgrading tot Stata 16 I am receiving the following error:
ssc install asdoc
checking asdoc consistency and verifying not already installed…
the following files already exist and are different:
/Users/…../Stata/ado/plus/a/asdoc.ado
/Users/…./Stata/ado/plus/a/asdoc.sthlp
/Users/…./Stata/ado/plus/l/lasdoc.mlib
no files installed or copied
(no action taken)
r(602);
Yes, asdoc works perfectly with Stata 16. In your installation command, you have to add option replace
It worked, thanks! But only after I deleted manually all three files and re-run the ssc install asdoc command. For some strange reason, running the install command with ” , replace” didn’t solve the problem…
The above shall install asdoc and replace any existing copy. But you have to restart Stata.
Salam Attaullah Sir,
Hope you are doing well. Recently i just came across asdoc package which is helpful to create amazing, meaningful tables. I have Done MSc in Epidemiology & Biostatistics from Agha khan university. Currently working as Research Specialist. In my field such commands really help to obtain a data in specific way. Well coming to the point, i would like to ask how to use Asdoc command with loops . Such as there is one loop which actually run tabulation of whole sheet. Now question is that how to use asdoc with loop to send all tables together in one go?
And another question. Please if you can guide, link or refer any best stata notes or books. Please if you have any prepared material such as do file please possible kindly share.
I will remain thankful to you
Regards
Dear Ameer Muhammad
Thanks for your appreciation and kind words. asdoc can be used just like any other Stata command in a loop. If you have an example dataset and have an idea of using loop with it, just let me know and I shall show to use a loop with it.
Currently, I do not have ready material on Stata, I usually search the internet whenere the need arises.
Dear Dr. Shah
I’m trying to use asdoc with svy and tabulate, ci but I can’t find the way to show confidence interval.
using:
Where I’m doing something wrong?
Thank you
Fos
The ci option is not yet available with svy tabulate command.
Hello Dr. Shah,
I love to use asdoc, but I’m having problems seeing chi-square and notes in two-way tabulation (cross-tabs). I try to use something like:
or
I realized that chi-square and notes does not work with the tabulate command and asdoc.
Any workaround?
Thanks,
Felix.
Félix Quiñones
I am pleasantly surprised that you know about
notes
as no one else knows about this new feature, except Prof Eric Melse. Do you know him?Until today,
notes
option was not available with two-way tabulation commands. Upon your request, I have added this to asdoc.The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
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.
Hello! This is a great package, super useful for quick output for tab. It would be great if there was functionality to display Stata dates properly when their tabs are outputted, rather than showing the raw numerical value. Alternatively we also cannot use the string version of the date either.
Elena
Yes asdoc does not support date formats with tab command, but converting dates to string should work. See
Hi
I am new to as doc command. It is not working for me. I am using STATA 15 and Windows V 10
I type this:
and get this error:
Kindly advise
Sheila Marilyn
First of all, there is no space between as and doc, it’s a single word. Second, please note that there should a space between the , and append. On a side note, append is optional, so you do not need to use it. Here is an example
Hi,
Thanks for developing such an excellent command for table-exporting.
However, would there be any chance that -asdoc- support other regression commands, such as -ivreg2-, -reghdfe-? Or more generally, -esttab- ?
Thank you
Yunzhi
Yunzhi
asdocs works with reghdfe, as you may like to see an example here where I produce a nested table https://www.statalist.org/forums/forum/general-stata-discussion/general/1523309-asdoc-query
If you have any other specific issue, then please provide a dataset with a reproducible error.
beautiful package, extremely helpful.. thanks a lot Dr. Shah
Request: Notes with nested regression table please. Or can you suggest an alternative?
GSingh
The new beta version of the asdoc accepts notes. Please note that notes written in the last code will be posted to the given file. For example,
The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
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.
Thanks. This worked. But now the two sample t-test command is resulting in a one-sample t-test output in the word document (logfile results are correct). With the SSC version of asdoc I was getting the two-sample results. Please help.
Hello Dr. Shah,
I’m using Notes for the two way tabulation. Can you make it available for one-way tabulations?
Thanks,
Félix.
Félix Quiñones
I shall do that. Please tell me how you came to know about notes option?
Hello Dr. Shah,
I spent a lot of time looking for a way to add notes to tables automatically on Stata without using Latex. Currently, I work for a research center and sometimes we just need to run some codes to see how the data looks like. When I found ASDOC I read every single comment on your page and every one of your responses. Then, I came around an answer that you give to Dr. Eric in July 17, 2019. After that, I just started playing with the notes. I use notes to include the Chi-Square information of the Cross-Tabs in the table, because that is not a current option of ASDOC. Will be great if you can add notes to all the different tabulations, and add the chi2 option to tab that show in the table.
I know that I’m asking a lot.
Félix Quiñones
As always, thanks for your helpful suggestions. I have noted them and shall consider them when updating asdoc or asdocx, a premium version of asdoc (see updates here http://fintechprofessor.com/asdocx
Dear Mr. Shah,
I am a researcher at the German Institute for Employment Research (IAB). I recently discovered your new Stata ado-file asdoc, which seems very helpful. I have been trying to use it, but I always get error messages.
E.g., I get the error “: 3499 asdocsum() not found” when running the following code:
clear
set obs 100
gen x = uniform()
asdoc sum, detail replace dec(3)
Co-workers of mine get the same errors. Do you have any idea what the problem might be?
Dear Dauth Christine
The error message implies incomplete installation. Please follow these steps.
Try to install it again from SSC, using the following command
You may also try the latest beta version of asdoc from my site. For that, you may try:
Please note that the above line has to be copied in full and pasted in the Stata command window, then press Enter. 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.
hi, I am trying to use asdoc to output cross tabs with column percentages. asdoc tab2 y x, col nofreq works fine except when I want to add weights. tab2 does not allow weights and asdoc tabulate y x [aw=w], col nofreq gives an error. Is it possible to export tables with asdoc with column percentages AND using weights? Thanks!!
MS
Let me see it, I shall post the updates here.
Thank you! Looking forward to it!
Hello Dr. Shah,
I just discover that column options in tabulations are not allow anymore. Anything that we can do for that?
Felix.
Felix Quinones
Please post the actual command that you are using so that I can replicate the error.
Dear professor,
I would like report a bug that continually I get in a three way table using asdoc:
Total (row) not agree with stata results.
Thanks
Rodrigo Badilla
Thanks for reporting it. I have fixed the issue. The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
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.