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 Attaullah Shah
Thanks for you reply and fix this issue! I will cite Asdoc of course!
Regards
Rodrigo.
Dear Attaullah Shah:
Excellent program!
I am trying to save my correlation table using my own name instead of MyFile, but the save option is invalid. Can you assist?
Thank you!
You can specify the file name inside option
save
. See this exampleHi,
Asdoc was working perfect for me, but then suddenly i am getting this message:
asdoc_tab_twovars(): 3200 conformability error
: – function returned error
r(3200);
My STATA code is:
asdoc tab boligproblemer lavinntekt, nokey row nofreq replace
(the names of the variable are in norwegian: boligproblemer = housing issues, lavinntekt = low income)
Do you know what the problem can be?
Regards
Siri
Dear Professor Shah,
First time I am using asdoc. When I tried to export multiple tables I found the exported doc contained scripts instead of the tables. And when I updated it using the link you provided, the same command gave an error message.
I might have made some mistakes.
Thank you
Regards
Bishal
Bishal, please post the command that generated the above error. It will help me debug the issue if any. For the second issue, it seems that the previous installation was not completely overwritten, therefore, the previous files conflict with the new ones. Please do the following:
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.
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.
ssc install asdoc, replace
Good morning. Asdoc is not providing the actual N, I am receiving variable names instead. Thank you for this program!
Hi!
Thank you so much for creating such an awesome program. I have greatly benefited from using asdoc (and plan to cite it in my upcoming paper).
I have a problem I have not been able to solve, however. In one my datasets/analyses, it doesn’t matter how many times I uninstall and reinstall asdoc or delete the generated .doc file – my computer repeatedly tells me that the Word document is corrupted (no matter how many times I make a new one). If I use any other dataset/do file, asdoc works fine. I’ve tried setting the working directory to something else and that doesn’t help. This all started when I accidentally tried to use asdoc before closing the open file. I assume it got corrupted somehow, but now I cannot figure out how to fix it. Any help you can offer would be most appreciated. I’m using a Mac and the latest version of asdoc.
Liv, thanks for your appreciation and feedback. Yes, once is file is corrupted, some integral parts of the RTF commands are deleted, which then makes it impossible for Word to read the file correctly. What you can do is to delete the file and regenerate it using the asdoc codes.
Please note that files can be corrupted also by opening them in Word and making changes in them. The reason is that once opened in MS Word, it will change the file format which cannot be reused in RTF format again. If if you have to make changes in a file using MS Word, make sure that you are making a change in a final file which will not be further processed by asdoc.
Dear Professor Shah,
I have been following some of your videos. I found command asdoc quite useful. But I am facing a problem regarding drop. I have two dummy variables: year which contains six year numbers 2014 to 2019 and industry containing names of industries (30 in total). Industry is coded as: tab industry, gen(ind) . I included year (i.year) and industry ( i.ind) in my estimation. But I don’t want coefficients in the table. When I tried drop(i.year i.ind), it does not work. Could you please help! I shall highly appreciate. Thanks, IM
I had replied to your comment on this page https://fintechprofessor.com/2018/03/22/asdoc-options-examples/
I find this function incredibly powerful and useful. Thank you Dr. Shah. Is it possible to change it to export to MS Excel or XML instead of Word. Most of the researchers prefer their tables formatted in Excel.
I am planning to add support for Excel in the asdocx version, see details here http://www.FintechProfessor.com/asdocx
Prof. Shah, thanks for your highly useful programme. I’m using Stata 15, and I’m trying to use the asdoc command to produce a nested table of marginal effects after executing the -probit- command. Can you please guide me to do this? Thanks.
Prof, first of all, let me say thanks for this outstanding package. The ability to compile all results into a neat and single word file has greatly improved my workflow.
There is some functionality that I am missing relative to other options and I was wondering if anyone could help with this.
1 – The output struggles with labels when using interaction terms, for example if I run:
#delim ;
The output shows a set of empty labels for the coefficients of
c.XVAR1, c.XVAR2, c.XVAR1#c.XVAR2 ...
With other options, code like this would report a neat set of interaction terms and their labels and allows to select what symbol we want for the interaction:
Is there anything like this for asdoc?
2 – Is there any way to lift the restriction in the number of ‘dummies’ that we can add at the bottom of the table. As we can see from the esttab code above I’d actually want to add 5.
3 – Is there any way to lift the restriction in the number of characters in the label, when there are triple interaction terms, more space would be helpful.
Either way thanks for this amazing package.
Hi Professor,
Can I get the older version of .ado file of asdoc? because new version asdoc ado is not able to generate row-wise percentage tables with iweights. Please it will be a great help for us if you share the file to skbhat.mids@gmail.com.
FYI I am trying to run this which is exporting abnormal table
is not exporting the correct table. but the following code is working
Please help me
Thank you
Dear Professor Shah,
Asdoc is such a powerful package, especially in creating nested tables. I would be very grateful if you could help me solve this issue: My interested variable is a categorical dummy (4 categories), so I have to keep it in the table. However, there is always 1 row named 0bn above the rows of the categories in the table. How can I drop that unnecessary row (meaning 0bn)?
Below is the example of my issue:
Sarah
I have added the option
nofvlabel
to suppress the base level category in factor variables when creating nested tables. 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.
Here is an example
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. Shah,
Thanks for producing such a wonderful STATA command for researchers, which is making the work so convenient. As a quick question, I wrote the following code
tsset Day_con
asdoc newey CSSD_MD Rmt Rmt2 , lag(4) wide t(below) stat(r2_a, N) add(Full sameple) tzok stars save(CCR_wide)
but it comes with the error
sparse_table(): 3201 vector required
: – function returned error
even if it runs, the resulting MS Word table comes in machine language. I wonder if you could spot the problem in my code.
Many thanks in advance!
Kind regards,
Rubbaniy
Thanks, a very useful command, but how can i add graphics in the sheet results?
Dear Prof. Shah,
First thank you so much for a fantastic package, making life much easier.
I recently tried again and experienced issues (similar to some I had before but solved with re-install) with exporting correlation matrix. I use Stata 16 and just re-installed asdoc on my Pc.
Here is the code I use:
asdoc pwcorr Monitoring PricingAForships PricingCFortrucks StandardAForships StandardBForterminalequipme StandardCFortrucks LowemissionsfuelsforPDCssh Modalshifttargets ALNG BBiofuels DOnshorepower EBatteriesforportvehicles Portlocation Portsize GovernanceModel WEFscore GDPpercapitaUSD UncertaintyAvoidanceUA PowerDistancePD Containerport Drybulkport Liquidbulkport OwnershipPublicvsPrivate, label save(henrikc) replace
And the error message:
>=1 invalid name
r(198);
end of do-file
I actually see that a document with the given name is created in the default location (Documents) but I can’t open it. When I clear the code , delete the file and re-do everything again, I keep on getting the same message with an additional: (note: file henrikc.doc not found).
Thanks a lot for helping me out!
Best
Aga
I am having the exact same issue–any advice would be greatly appreciated!
Can you please send your data file and code to reproduce the error?
Dear Prof Shah
thank you for the asdoc command I just recently discovered.
I am using the multinomial regression for categorical independent variables. I use the asdoc to export my document to word. however, I notice that the result of Word and Stata output are different. is there something I am doing wrong?
here is the command used
thanks
Attaullah,
Thanks for the ASDOC stata command. Really appreciate it.
Great job!
Best,
Dear Dr Shah,
Thanks for the fascinating asdoc package! I just have a quick question regarding “notes”. I notice that when I have a super lengthy notes, only a portion of the notes is display. and the width of displayed notes is only 1/2 of the width of the table. I am wondering is there any remedy for it? It doesn’t seem like someone else has risen this question before. I apologize, if someone else did ask.
Hi sir,
I am very happy with your program!
But since Stata 16, there appears to be a problem:
: 3499 asdoc_tab_twovars() not found
I reinstalled asdoc and I restarted Stata, but still get this error.
What do you think is the matter?
greetings
ruben
Ruben
Please post your command that you are using with asdoc.
Can be anything:
asdoc tab education gender
asdoc logit educationhigh i.gender, or
Point is: exact the same command worked before (Stata 14).
The help function (help asdoc) works.
Maybe, just maybe it is a problem of our upgrade towards W10?
Thanks a lot,
ruben
Sorry, it is no Stata 16 problem as we already updated to 16 before this occured.
I have fixed it. 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.
Great thanks! Can I dowload the files somewhere, as our institite does not allow Stata to contact the internet directly.
I have email the files to you.
Hi Professor Shah,
I am facing the same issue with Ruben. Would you please kindly email the updated files to me? Many thanks!
Hi – I’m having trouble with asdoc pwcorr. I’ve run a set of variables in asdoc tabstat and these results turn out fine. However, when I put the same variable list in asdoc pwcorr, I get the following error:
rtf_maker(): 3301 subscript invalid
: – function returned error
Here’s the code:
Any help would be greatly appreciated!
The recent version of asdoc has this problem when the variables exceed 20. I shall fix it in a day or two.
Dr. Shah,
#1 When I run corr with asdoc for more than 15 variables I get the following error:
rtf_maker(): 3301 subscript invalid
: – function returned error
Basically, it does not produce the table. Please help to fix the issue.
#2 is there a way to bold the correlation results with let’s say 5% or less significance level rather than using stars?
#3 is there a way to bold the correlation results using corsp – let’s say 5% or less significance level rather than using stars?
Dear Shah,
The command “asdoc” is very cool.
But a problem that I faced is unknown symbols /like ÐÐУ/ when I send the results with variables/values in Mongolian Cyrillic to the MS word.
I tried the “unicode” command, but it doesn’t help me.
Could you provide a solution to that?
Dear Dr.Attaullah Shah, in case of two mean tests (paird), we get only one digit for t-value and p-value. how can we increase the number of decimals to make p-value for example p=0.1020 in place of p=.0? I gave the following example
Code:
sysuse auto, clear
asdoc ttest mpg==price, replace
Hi Dr. Shah,
I am curious if the asdoc does report the number of observations in a pwcorr command. I tried it and it did everything except that.
Hi Salem
You are right, observation cannot be exported with asdoc. I have been working on asdocx now to make all these missing features available in it. You can
read this table
that outlines all the features that asdocx has over asdoc.
Hi Dr. Shah,
I just recently made the purchase and filled the details for asdocx. I forgot to actually check back!
Thank you for your response and for the package!
Best,
Salem
Dear Prof. Shah,
asdoc is a very helpful tool! I really like it. I would like to use it with the Stata package -fre-, another helpful Stata tool (in Stata-Version 14).
This returns the following error:
invalid something: unmatched close parenthesis or bracket
Any chance this might be fixed in a future version?
I think
fre
can be added in the asdocx program. asdocx is more powerful and flexible than asdoc. You can compare the features here https://fintechprofessor.com/asdocx/difference-between-asdocx-and-asdoc/Dear Attaullah, I find this function incredibly powerful and useful. Thank you . At this moment I’working on this command, but I have some problem with asdoc. Could you help me to generate an asdoc table? The command : eststo: mlogit multi_repertoire confederal autonomous ns_tu selforgworkers workers_only unemployed professional cso students informal pp othercategories laborissue exclusionissue politicalissue managers professionals technicians clerks services agricultural trades machine elementary localedition ib7.region i.government police2 [aw=weight2] if tin(2008m1,2018m12).
Thanks
Sabrina
I used ASDOC perfectly the first time, but when I try and create a second table the document is neither appended to overwritten.
this is my code:
1st table:
asdoc cor ETR ScaledCash Leverage Size Intangibles PPE RD specialitems
2nd table – doesn’t work
asdoc cor ETR ScaledCAPX ScaledCash SalesGrowth Leverage Size Profitmargin Intangibles PPE RD SGA specialitems, replace
I also tried
asdoc cor, replace ETR ScaledCAPX ScaledCash SalesGrowth Leverage Size Profitmargin Intangibles PPE RD SGA specialitems
Any help would be greatly appreciated
Hello there,
Thank you so much for you program. i have the oddest problem, when I try to asdoc a simple table I get the following error :
astable(): 3301 subscript invalid
: – function returned error
r(3301);
the command is
asdoc table docc03 pubsec, c(mean rw)
which presents a table with just 23 lines and two data columns. I have followed your advice on this and other threads such as reinstalling the program straight from your webpage but nothing has worked. Could you kindly advice?
Can you please send the data at attaulah.shah@imsciences.edu.pk so that I can trace the problem.
Hi Professor,
I have a problem with the weights for descriptive statistics. When I use:
asdoc sum q44_1 q44_2 q44_3 q44_4 q44_5 q44_6 q44_7 q44_8 [aw=weight] , append
the table returned is not weighted. Any solution? Thanks,
I think I added this functionality to asdocx, that has several other big improvements over asdoc. See details here https://fintechprofessor.com/asdocx/wp-admin/