asdoc makes some elegant tables when used with tabstat command. There are several custom-made routines in asdoc that creates 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.
Tabstat Without-by
If statistics are less than variables, the table is transposed, i.e. statistics are shown in columns, while variables are shown in rows
Example 49 : One variable, many stats, including t-statistics
sysuse auto, clear asdoc tabstat price , stat(min max mean sd median p1 p99 tstat) replace
Example 50 : Many variables, one statistic
asdoc tabstat price mpg rep78 headroom trunk weight length foreign , stat( mean) replace
Example 51 : Many variables, many statistics
asdoc tabstat price mpg rep78 headroom trunk weight length foreign , /// stat( max mean sd median p1 p99 tstat) replace
Tabstat with-by
Example 52 :
bysort foreign: asdoc tabstat price mpg rep78 headroom trunk weight length, stat(mean) replace
OR
asdoc tabstat price mpg rep78 headroom trunk weight length, /// stat(mean) by(foreign) replace
Example 53 : By with many variables and many statistics
bysort foreign: asdoc tabstat price mpg rep78 headroom trunk weight length, /// stat(mean sd p1 p99 tstat) replace

Dear Attaullah,
Firstly thanks so much for the asdoc program and for the help you have given those who are using the resources of your site and youtube channel to export stata data to word!
I am trying to make descriptive statistics similar to the ones attached.
Currently I am running the command
asdoc tabstat Distance Cost Document Trust Religion Income Family Need, by(economy) stats(count mean sd) format(%9.3g) long, save
When I run without the asdoc command, I get the variable names as the column headings , however with asdoc, the column headings are always the statistics (N, sd, count). What would be the best way to generate descriptive statistics like those attached (row with both N, count sd etc, and row above with variable name)
I have attached my dataset (from Global Findex 2017).
Many thanks,
Joe Stanley
Joe Stanley
Thanks for your feedback. currently, flipping the tabstat table is not allowed in asdoc. I shall consider it in the future updates.
It has not been updated yet, right?
Hi Dr. Attaullah Shah,
First off, let me thank you for writing asdoc, it’s very helpful! I’ve ran into an issue using asdoc and tabstat with multiple conditions. For replicability, I’ll illustrate the issue using the auto.dta file:
I am getting the type mismatch error with my data when I do multiple conditions in the tabstat statement. You’ll notice that without the asdoc prefix the command behaves as expected. Is this something you could look into.
Other relevant information:
Version :
*! Version 2.3.4.1: Changes made June 15, 2019: option label added to list command; Fixing bys sum in MacOS
I am using MacOS, and have tried this with both Stata 15 and 12.
That was a command parsing error. 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.
Hey,
Your command has been such a bi contribution and has made things so much easier. I wanted to ask if we can add labels when using tabstat such as:
asdoc tabstat polio, by(year) label
so that it reports variable label instead of variable name as in case of summ and corr.
Also do asdoc support exporting graphs of these stats in stata too?
Best,
Hi, Thanks for creating the command. It has been very useful. I was wondering if you can advise what could be causing the error “astable(): 3301 subscript invalid : – function returned error” when I run the asdoc command. This is only happening to certain data combination. Your thoughts are appreciated.
Tolu
Can you please provide a dataset to produce the said error?
Dear Attaullah,
I have been using tabstat to create simple tables of summary statistics but my problem is that the total is printed in the stata console but when the word document is opened the total is not included in the table printout. Is it possible to have it available in the word document too?
Many thanks,
Ashma
Dear Attaullah,
Your program has been pretty useful so far. I want to know ¿how can i save graphics?
Thank you
Víctor Coronel, thanks for the kind words. asdoc does not have support for graphs and charts. asdocx will have this option. asdocx is almost complete. You can check the details of asdocx here https://fintechprofessor.com/stata-programs/asdocx/
Dear Attaullah,
I have been playing around with asdoc a bit and so far very much like the simplicity of the syntax in combination with the elegance of the output. So first of all, thanks for that!
I was wondering though if there is some way to use the ‘nest’ function in combination with ‘tabstat’? I am trying to create a table that displays the means of three variables in columns for several categorical variables in rows. The code that I am using now is:
This gives me the table (below) on the left, but what I am aiming for is something like the table (below) on the right, in which the column headers are not repeated and the names of categorical variables are included.
Any help in getting there would be much appreciated!
On a side note: When I tried to get the table to show commas instead of periods for decimals (via ‘set dp comma’), I get a conformability error. Is it possible that asdoc does not support the use of commas?
Thanks,
Fieke
I see that it didn’t quite display the tables the way I hoped for. Sorry for that. I hope my question is still somewhat clear.
Fieke
Thanks for your kind words. This is not possible in asdoc. Though it can be easily added to adocx (http://fintechprofessor.com/asdocx)
Dear Attaullah
I have been using table and tabstat to create tables of summary statistics, but I have 2 problem:
First with table. In example:
the console throws the message “invalid something: unmatched open parenthesis or bracket
Second, with tabstat, the labels of a factor variable is cut off, for example “Boston General Hospital” –>”Boston General H”
Any help is appreciated!
bysort is not allowed with table, only by() is allowed. Therefore, try something like this:
asdoc table var2, contents(mean var3) by(var4) concise
Hi,
As Ashma mentioned earlier, the total is printed in the stata console but when the word document is opened the total is not included in the table printout. Is it possible to have it available in the word document too?
Many thanks,
Hi,
Thank you for the package, as always, on point.
I am having trouble in replicating the univariate sorts kind of tables (High-Low) but I am not sure how to put that on Stata syntax.
Many thanks,
https://www.researchgate.net/figure/Univariate-Sorted-Portfolio-Performance-based-on-EPU-beta-in-different-sentiment-periods_tbl2_344137481