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

 


10 Comments

  1. Joe Stanley August 14, 2019 at 6:01 pm - Reply

    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

    • Attaullah Shah August 14, 2019 at 10:27 pm - Reply

      Joe Stanley
      Thanks for your feedback. currently, flipping the tabstat table is not allowed in asdoc. I shall consider it in the future updates.

  2. Justin N August 14, 2019 at 10:24 pm - Reply

    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:

    sysuse auto, clear 
    
    replace make = "AMC Concord” 
    
    asdoc tabstat price , stat(min max mean sd median p1 p99 tstat) replace
    
    tabstat price if foreign == 1 & make == "AMC Concord", ///
    stat(min max mean sd median p1 p99)
    
    asdoc tabstat price if foreign == 1 & make == "AMC Concord", ///
    stat(min max mean sd median p1 p99 tstat) replace 

    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.

    • Attaullah Shah August 14, 2019 at 10:29 pm - Reply

      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.

      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.

  3. Maira Aamir October 29, 2019 at 12:06 pm - Reply

    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,

  4. Tolu November 5, 2019 at 8:10 am - Reply

    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.

    • Attaullah Shah November 5, 2019 at 10:55 am - Reply

      Tolu
      Can you please provide a dataset to produce the said error?

  5. Ashma Krishan March 9, 2020 at 3:03 pm - Reply

    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

  6. Víctor Coronel June 20, 2020 at 11:06 am - Reply

    Dear Attaullah,

    Your program has been pretty useful so far. I want to know ¿how can i save graphics?

    Thank you

    • Attaullah Shah June 23, 2020 at 10:53 am - Reply

      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/

Leave A Comment