For installation and other uses of asdoc, please see this short blog post.
Tabulation and Cross-tabs with asdoc
Exporting tables created by Stata commands such as tab, tabulate1, tabulate12, table, tabsum, tab1, tab2, and others to MS word is super easy with asdoc. As with other commands, we need to just add asdoc as a prefix to the tabulation commands that includes tabulate, tabulate1 tabulate2, tab1, tab2, etc. Since frequency tables in Stata can assume different structures, asdoc writes these tables from log files.
One-way table
Example: One-way table
sysuse auto, clear asdoc tabulate rep78, replace
Please note that replace is asdoc option to replace the existing file. If we were to write to the existing file, we would then use option append, instead of replace.
Two-way table of frequencies
webuse citytemp2, clear asdoc tabulate region agecat, replace
Example: Include row percentages
asdoc tabulate region agecat , nokey row replace
Note nokey suppresses the display of a key above two-way tables.
Example: Include column percentages
asdoc tabulate region agecat , nokey column replace
Example: Include row percentages, suppress frequency counts
asdoc tabulate region agecat, nokey row nofreq replace
One- and two-way tables of summary statistics
Example: One-way tabulation with summary statistics
sysuse auto, clear asdoc tabulate rep78, summarize(mpg) replace
Example: Two variables tabulation with summary statistics
generate wgtcat = autocode(weight, 4, 1760, 4840) asdoc tabulate wgtcat foreign, summarize(mpg) replace
Example: Suppress frequencies
asdoc tabulate wgtcat foreign, summarize(mpg) nofreq replace
Multiple-way tabulation (tab1)
tab1 produces a one-way tabulation for each variable specified in varlist.
Example: Multiple-way tabulation
sysuse nlsw88, clear asdoc tab1 race married grade, replace
Two-way for all possible combinations (tab2)
Example: Two variables tabulation with summary statistics
asdoc tab2 race south, replace
Dear Attaullah,
I have just downloaded your asdoc program. It is wonderful. MANY MANY THANKS FOR YOUR EFFORT!!
Nevertheless, I have found a problem in Including row percentages in the two-way table of frequencies. If I run the code included in the asdoc help (Example 41), I will not get row percentages
Otherwise, I get row percentages if I simply run
I’m wrong or there is a problem in your program? Thanks a lot in advance for any of your help!
Dear Mr Attaullah Shah
Thanks for the program asdoc in Stata it seems to work fine.
http://fintechprofessor.com/2018/06/18/exporting-tabs-and-cross-tabs-to-ms-word-from-stata-with-asdoc/
https://www.statalist.org/forums/forum/general-stata-discussion/general/1435798-asdoc-an-easy-way-of-creating-publication-quality-tables-from-stata-commands
I face a similar issue as reported by Febrico. I don’t get row percentages, see Example 41 in the asdoc help file.
Fedrico and Anne Marie:
You are right. This problem occurs due to a conflict of options of asdoc and tabulation. Option row is an option of asdoc, as well as the tabulate command, but asdoc has a preference and hence the option row is not passed to the tabulate command. As a solution, I have added option subopt() which will pass all such conflicting options to the relevant Stata commands. You can install this new beta version from my website first and then use this option.
I would appreciate if you can comment on asdoc youtube video.
https://www.youtube.com/watch?v=61ks3cMPz3c
Please do cite asdoc in your research.
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.
I have installed the beta version and now the row option works fine.
Greetings,
Thank for this wonderful STATA module. I have 2 issues;
1. Trying to use it with tabulate command and giving the following error message “option matrow() not allowed”
2. Its seems not to work with the graph command i.e. it can export graphs to Word
Many thanks
Richard Makurumidze: I have replied to your question in this blog post.
For your second query, yes asdoc is not able to send graphs to MS Word. However, I am trying to add this functionality in the next premium version of asdoc, which I would asdocx. For more updates, keep visiting this page.
Dear Attaullah, Many thanks for asdoc,
I have a question that if I want to do a 2*2 table with chi-square, how can I have the P value in the export doc. I tried different ways just can not have p-value exported
YZ
Currently, asdoc does not report additional statistics with tabulation commands. However, there is a workaround this issue. If you read the asdoc help file, you shall see in Section 1.9 that there is a
text()
option which can be used for reporting text or any additional statistics from the r() and e() macros. Since tabulation command leaves the Chi2 and its P-value in r() macros, therefore, they can be written to the existing document using the text option. See the following examplesThank you so much for providing asdoc. It is very useful!
But I have a question. I just used your data and an example (for example 44 in the help asdoc) to run the following,
and got the error message:
Do you know what’s wrong with it?
Thank you!
Sincerely,
Susan
Associate Research Professor of Biostatistics
Center for Outcomes Research
Houston Methodist DeBakey Heart & Vascular Center
Houston Methodist Research Institute
Dear Susan
You are right, when I revamped asdoc to report better quality tabulation results, the task was so exhausting that I decided to skip the summarize option with tabulate. If I find enough motivation in the future, I shall work on that.
Many Thanks Dear Pro Attaullah for this useful command!
I have one concern with 2×2 table and the use of text option to report Chi2 and p value. Is there any way to round or specify decimal points of the Chi2 and p value to be reported in MS word file?
Jeff
Here is one example
Thank you! It works perfectly !!
Best regards !
Hi
how to convert the following output on STATA in proper tables these are t-tests results and I want to report for both type of households
The help file of asdoc provides a largen number of example to generate elegant tables from ttest command. To see these example, type
and then navigate to the section 8
Dear Prof. Attaullah,
Thank you so much for providing us this wonderful command. I have been using esttab for years and asdoc is much better.
I ran into this problem and I haven’t seen similar cases in the discussion here.
When I output my crosstab, Word separates each row and add an empty row in between. Each row becomes a separate table. And the last column do not line up.
here is a simple example
Could it be my Word’s problem? I use traditional Chinese on my computer.
Michael
This should not happen as asdoc creates aesthetically pleasing tables from tabulation commands. To see what might be going on on your computer, can you please send the following to my email attaullah.shah@imsciences.edu.pk
1. The dataset
2. The command you used
3. The output generated by asdoc
Hi Professor Shah,
Thank you for asdoc. It really saves me time. I was wondering if there is a way to include a question mark in a title
It gives me a nice table but there is no question mark in the title. Any suggestions on how to fix this?
The problem is not with the question mark, it is with the parentheses. Since asdoc uses opening and closing parentheses for parsing, they are not directly allowed as a text. So if you type the command like this, it will export the question mark
Please cite asdoc in your research.
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.
Can I use asdoc with mrtab?
Dear Attaullah,
Thank you for releasing and maintaining asdoc. When I use asdoc to report frequency, tabulate option ‘sort’ cannot be recognized by asdoc. Here attached is the codes.
. asdoc tabulate var1, sort save(draft.rtf) append
option sort not allowed
same problem :/
Thanks for reporting it, I shall work on it and update asdoc.
Hello, very many thanks for providing this program, and I have noted the request to cite its use.
A small issue which might interest you to look at is that ‘if’ following the ‘table’ command doesn’t seem to be recognised. eg ‘asdoc table mv if sales>1000000, contents(mean assets)’ tabulates all the observations, not the subset required. I might be doing something wrong but I’ve tried various versions of this with the same result. I can obviously deal with the problem by creating appropriate new variables but I thought it might be an easy one to fix in the program.
Daniella Acker
Please check the updated version of the asdoc. I checked it and did not find an 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.
Many thanks – so sorry to have picked up the wrong version.
Just so you know, even in the latest version on SSC, when svy is used asdoc will only produce cell and col output not row with two-way tabulations. E.g. asdoc svy, subpop(rural): tab sex race, row percent format(%9.3g) will produce cell percentages instead of row percentages
I was wondering just like someone else did, can asdoc be used with mrtab? its quite a pain when using mrtab because most cases the tables are cut into 3 pieces.
Currently, there is no specific routine in asdoc to make report from mrtab. This can be done using asdocx
Dear Attaullah,
Please whenever I try to use asdoc for crosstabulation, I get this error message: ”asdoc_tab_twovars(): 3001 expected 16 arguments but received 17
: – function returned error”.
Can you please help?
You old installation interferes with the new one. Please uninstall asdoc complete and re-install
1. Completely uninstall asdoc using the following lines of code
2. Then re-install the latest version from my site with this code
Please note that the above line has to be copied in full. After installation of the new version, then restart Stata.
hello Attaullah.
I want to buy asdocx and would like to know if it integrates the export of graphics.
Thanks.
I am working on that, asdocx will integrates graphs and charts. Once you buy it, you shall be entitled to all future updates and improvements, so you can place the order now.
Hi Dr Attaullah,
A big thanks for your package “asdoc”. It took away more time which i spend to creating tables.
I would like to know is there any way i could append the frequency tables from multiple variabes in one single table and same for teh crosstabs with uniform column variable or row variable.
Thanks in advance!!
Yes, this is possible in asdocx, that is a premium version of asdoc and is currently available for nominal fee of $9.99. See this thread for
tabmany
https://www.statalist.org/forums/forum/general-stata-discussion/general/1586168-creating-a-single-table-from-tabulation-of-many-similar-variables-using-asdocasdocx has a large number of features that are not available in asdoc. Please see this introduction page https://fintechprofessor.com/asdocx/ for quick details.
Hi Dr.Attaullah,
Thanks for this amazing program. I was wondering how to add comma every 1,000 in summary statistics generated by -asdoc tab-.
Hello Jae
This feature is available in asdocx, see asdocx details here https://fintechprofessor.com/asdocx/
Hi,
I’m experiencing problems when trying to export. When I try to export as .doc i get some sort of code, which I’m usually not getting. If I change to docx I’m only getting the header but no table. Can you help?
Hi,
Thanks for the asdoc Command It is really helpful. But I have a nother question about other issue in data management. I have transformed data from Long to wide because I want each individual to be in one raw. Now I have many variables values for the same individual in the same year but in different times (each column for one occassion). I want to reduce the number of columns to start the analysis while it is still in the wide format. Hope I clarify my question.
thanks
Thank you for your help.
May I export several cross tabulation at once in one table ( at one go)
asdoc svy: tabulate v1 v2 v3 v4 v4 v5,
where the last variable, v5, is my outcome variable and the others are exposure variables . In stead of having many tables appended one after the other, I would like to do this in one big table.
Thank you.