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, cross-tabs, regressions, t-tests, flexible 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

 


 

119 Comments

  1. Nicole Martin January 10, 2018 at 8:37 am - Reply

    Firstly, thank you for making your Stata package available – it’s really speeding up my workflow compared to the other options available. I’m writing to make a suggestion that you consider adding an option that value labels can be reported in regression tables as well as variable labels.

  2. Joanna Dipnall June 1, 2018 at 3:42 am - Reply

    I was very excited to find your wonderful asdoc Stata command. However, I am having some issues when wanting to create some tables. The Stata value labels not being copied in tab2.

    For example the value labels with foreign are not copied into my Word file:

    • Attaullah Shah July 27, 2018 at 6:23 pm - Reply

      In version 2 of asdoc, I have included value lables with all tabulation commands, i.e. tabulate, tabulated2, tab1, tab2, etc. Thanks for your suggestion.

    • Attaullah Shah August 26, 2018 at 11:06 am - Reply

      Dear Joanna
      In version 2.0 of asdoc, option label has been added for the following Stata commands when using asdoc.
      1. tabulate
      2. tabulate2
      3. tab1
      4. tab2
      5. regress and all other variants of regressions in Stata

      You can update asdoc from SSC by:
      ssc install asdoc, replace

  3. Oscar Briones June 10, 2018 at 3:35 pm - Reply

    Many thanks indeed for the “asdoc” asdoc command stata
    it has helped me alot.

  4. Richell Onnel June 19, 2018 at 10:18 pm - Reply

    Thanks very nice blog

  5. Matthew Millard September 22, 2018 at 2:16 am - Reply

    I have been telling everyone about the asdoc package who uses Stata. Several people told me how much they absolutely love it. One’s exact words were that it is “game changing” for convenience.

  6. Parek Agustino October 7, 2018 at 10:47 pm - Reply

    Found this absolutely helpful. Any chance of a MacBook version(Numbers)?

  7. Attaullah Shah October 8, 2018 at 4:29 am - Reply

    Parek Augustino: asdoc can be installed on any platform where Stata is installed.

  8. HN Panta October 13, 2018 at 4:52 pm - Reply

    Hello Dr. Shah,
    Thank you so much for making stata help available publicly. I am trying to create a mean and median difference between two groups with test statistics (including starts). Could you help me with this?

  9. HN Panta October 13, 2018 at 11:19 pm - Reply

    Thank you so much! I’ll send you my query soon.

  10. Ruth-Alma Turkson-Ocran October 24, 2018 at 1:08 am - Reply

    I was wondering if your asdoc program can handle survey data. I do not see the info on your blog regarding using it with the survey command (there is no hyperlink for it here: http://fintechprofessor.com) In addition,
    Only one output gets put into the table when I try the following command:

    foreach v of varlist married edu_cat poor2 emp_stat notcov usupl stay_us{ 
    asdoc svy, subpop(if black_african==1): tab `v' sex_r, count col format(%12.0g), append
    }
    • Attaullah Shah October 24, 2018 at 1:14 am - Reply

      Ruth-Alma: Yes asdoc can work with svy commands. Please update asdoc and it will likely solve the problem you are referring to.

      ssc install asdoc, replace
  11. Gemechis Mersha November 6, 2018 at 3:06 pm - Reply

    I would like to say thank you for your asdoc work. I found it very helpful. But I get difficulty in applying asdoc to transfer Marginal Effect result to MS Word. All the command for regression is not applicable for Marginal Effect.

    For example

    asdoc reg x y, replace dec(3))

    …..the command dec(3) works here
    but didn’t work in

    asdoc margins, dydx(*), replace dec(3)

    is there any asdoc special command for transferring Marginal Effect result to Word?

  12. Dr.Öğr.Üyesi Erkan Alsu November 23, 2018 at 1:35 pm - Reply

    Hi Mr. Shah I congratulate you for your asdoc program. Very nice program. I am grateful to you for bringing such a program to the world of science. Where can I find the text file on Youtube video? Where can I find the asdoc Stata codes? Thank you. Yours truly.

    • Attaullah Shah November 23, 2018 at 1:39 pm - Reply

      Thanks for your kind words. asdoc can be installed from within Stata when you are connected to the internet. Type the following in the Stata command window

      ssc install asdoc

      After installation, you can find all the help and examples in the help file. To access the help file, type

      help asdoc
  13. Joyce Lee November 30, 2018 at 12:48 pm - Reply

    Hi Dr. Shah,
    I absolutely love your program, and I cannot thank you enough! I just only would like to ask how I might be able to adjust the number of stars for significance level. I would like to add asterisks with regression coefficients such that

    *** are added for p<0.05, 
    ** for p<0.01%, and 
    * for p<0.001 level of significance

    . It would be of great help. Thank you!

    • Attaullah Shah November 30, 2018 at 12:52 pm - Reply

      Joyce Lee: I am working on a dozen of options to add to asdoc in its next update. I have noted your suggestion and would consider it in the next update.

  14. Rully December 10, 2018 at 1:43 am - Reply

    Hi Professor, thank you for the great program. Quick question. When I try the following command (to include year dummy):

    asdoc xi: xtabond var var

    , the program says no variable named xtabond. Doesn’t the program support ‘xi:’ command yet? Thank you.

  15. Attaullah Shah December 10, 2018 at 3:17 am - Reply

    Rully: Thanks for reporting this bug. I shall try to find a workaround in the next update.

  16. Rully December 10, 2018 at 6:41 am - Reply

    Thank you Professor. It’s a great program.

  17. Jo February 12, 2019 at 3:13 pm - Reply

    Hi Professor,
    Is it possible for asdoc command to be in the foreach loop?

    • Attaullah Shah February 12, 2019 at 5:17 pm - Reply

      Jo
      Yes, asdoc can be used in foreach loop. Please elaborate what do you want to get at the end of the loop?

  18. Embaye February 23, 2019 at 5:07 pm - Reply

    Hi Attaullah,

    Thank you very much for your help. What is the stata code when we want summary statistics by year (for a panel data) using asdoc command? How can also export the asdoc document to any directory we wanted?

  19. Embaye February 23, 2019 at 5:07 pm - Reply

    Hi Attaullah,

    Thank you very much for your help. What is the stata code when we want summary statistics by year (for a panel data) using asdoc command? How can also export the asdoc document to any directory we wanted?

    • Attaullah Shah February 23, 2019 at 5:31 pm - Reply

      Embaye
      If you want to repeat the summary statistics by year, you can use the bysort prefix. see the following example,

      webuse grunfeld, clear
      bys year: asdoc sum, replace

      For your second query, you can use the save() option of asdoc. So assume that you have a directory in C:/results and you want to save the output to this directory. You would use the save option as shown below.

      webuse grunfeld, clear
      bys year: asdoc sum, replace save(C:/results/Myfile.doc)
  20. Abdul Hameed Leghari February 23, 2019 at 5:26 pm - Reply

    I hope you are doing great and feeling healthy. I’m writing this to congratulate to you on your STATA Program (asdoc). I have been utilizing STATA for a long time. This is such a major achievement in STATA history. It appears to be extremely valuable for me and it has tackled a significant number of my issues. I have been working in the development sector throughout the previous five years. I have performed several nationwide survey analysis, for example, Pakistan Panel Rural Household Survey, Pakistan Agriculture Survey, Pakistan Household Skills Measurement Survey and Operational Review of the Waseela-e-Taleem Programme, and so on. As of now, I have used it with many STATA commands and it effectively sends STATA yield to MS Word in extraordinary looking tables. I again acknowledge and compliment you for this work and pray for your successful and effective future.


    Regards
    Abdul Hameed Leghari
    Senior Economic Analyst

  21. SANNI OLAWALE March 9, 2019 at 3:05 pm - Reply

    How can I remove the compounded exported output by asdoc from STATA? Thanks

    • Attaullah Shah March 9, 2019 at 4:13 pm - Reply

      SANNI
      Can you please elaborate your query?

  22. SANNI OLAWALE March 9, 2019 at 4:18 pm - Reply

    Good day sir, I exported output from Stata using asdoc and subsequently I attempted to export new output from different data, but even all those ones I initially exported were included in with new output.
    I only want the exportation to be solely on a particular Data at a time, not a combination of previous data output in the ms word

    • Attaullah Shah March 9, 2019 at 4:32 pm - Reply

      OK, there are two way in which you can separate outputs from differet Stata commands:

      (1) Use replace option, that will replace the existing file. However, you should have copied or renamed the file otherwise the contents of the existing file will be replaced.

      (2) A better option would be to use the save(file_name) option. This way you can save each output in a sseparate file.

      See this example

      sysuse auto, clear
      
      asdoc sum, save(summary)
      
      asdoc cor, save(cor)
      

      The above code would generate two files one with the name summary.doc and the second with the name cor.doc

      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.

  23. Liz March 10, 2019 at 1:57 am - Reply

    Hello
    I’m trying to use asdoc to save a collection of tables made with bysort and sum but it says to many variables are specified. Is it possible to use asdoc on something like
    bysort 1 2: summarize 3 4 5 6 7 8
    thanks

    • Attaullah Shah March 10, 2019 at 10:07 am - Reply

      Liz
      If you want to use more than one variable in the bysort prefix, then you can first group those variables into one using the group function of egen command. Then use the new variable in the bysort prefix. In the following example, I have grouped the variables rep78 and foreign and find summary statistics for all numeric variables using the new variable grouped as grouping variable.

      sysuse auto, clear
      egen grouped = group(rep78 foreign)
      bysort grouped : asdoc sum
      

      If you find asdoc useful, please cite it 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.

  24. Roland March 21, 2019 at 7:56 pm - Reply

    Dear Professor,

    I am trying to use “asdoc” with tabulate command. I obtain the following error:

    . asdoc tabulate implementing_jurisdiction, replace

    option matrow() not allowed
    r(198);

    • Attaullah Shah March 21, 2019 at 8:17 pm - Reply

      Can you please a sample of your data at attallah.shah@imsciences.edu.pk
      Please also send the following info:
      the version of asdoc, which can be found by typing

      which asdoc

      2. Which operating system do you use? i.e. windows, MacOs or other
      3. Which Stata version

    • Attaullah Shah March 24, 2019 at 11:02 pm - Reply

      Thanks for providing the dataset. It seems the variable implementing_jurisdiction is a string variable. If a variable does not have value labels, the mentioned error is returned by asdoc. In order for asdoc to work, we first need to conver the variable to a numeric format with value labels. The good news is that we can do that in one line of code. In the following code, I convert the mentioned variable to numeric format and generate a new variable, called num_ij, then use asdoc with the new variable

      encode implementing_jurisdiction , gen(num_ji)
      asdoc tabulate num_ji, replace

      And there you go.

      Please cite asdoc in your research:

  25. Anderson March 24, 2019 at 9:26 pm - Reply

    Dear Attaullah Shat

    I am getting the same error as Roland citing “Roland
    March 21, 2019at 7:56 pm
    Dear Professor,

    I am trying to use “asdoc” with tabulate command. I obtain the following error:

    . asdoc tabulate implementing_jurisdiction, replace

    option matrow() not allowed
    r(198);”

    I am also getting this error: https://www.statalist.org/forums/forum/general-stata-discussion/general/1467744-using-asdoc-with-loop
    astable(): 3301 subscript invalid
    : – function returned error

    I am using Windows 10, Stata MP 64 bit, asdoc version is -> 2.3.3.3:

    • Attaullah Shah March 24, 2019 at 11:08 pm - Reply

      Anderson
      I hope the solution I presented above will also work for you. In the future updates, I shall try to add support for string variables inside asdoc, but for time being, the workaround of encode should effectively solve the problem.

    • Attaullah Shah July 13, 2019 at 3:32 am - Reply

      Anderson
      I have fixed the error. The new version of asdoc can be installed from my site. Copy and past 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.

  26. Daniel April 5, 2019 at 8:08 pm - Reply

    Hi Sir,

    Does the label option works for logit? I tried to use the label option with logit, but it doesn’t work…

    • Attaullah Shah April 5, 2019 at 10:51 pm - Reply

      Daniel:
      I have checked and option label works fine with logit. I am using version 2.3.3.4 of asdoc. You can check your version of asdoc by

      which asdoc

      An example of option label with logit is given below.

      webuse lbw
      asdoc logit low age lwt i.race smoke ptl ht ui, replace label
  27. Daniel April 6, 2019 at 1:13 am - Reply

    I am using 2.3.3.3. How could I update it ?

  28. Daniel April 6, 2019 at 1:15 am - Reply

    I used ssc install asdoc, replace, but still getting 2.3.3.3

  29. Daniel April 6, 2019 at 7:46 am - Reply

    I think the question was wrong. I get the label for continuous variables but not for categorical variables (I mean about the independent variables). Also I tried the code you provided, but I got the label values for the continuous variables, but not for the race.

    • Attaullah Shah April 6, 2019 at 8:17 am - Reply

      Daniel
      Can you please send your data and Stata code at attaullah.shah@imsciences.edu.pk
      Also, please indicate in your email what is not working for you and is going against your expectations.

  30. Kostas April 9, 2019 at 6:37 pm - Reply

    Dear Professor Shah,

    I installed the latest version of the ‘asdoc’ ADO file. I am using Stata offline due to data confidentiality. So, the asdoc file is called from a folder in C drive.

    The problem is that when I try to run different Stata commands, I keep receiving the following error:
    ” astable(): 3001 expected 5 arguments but received 12
    : – function returned error”

    In particular, the commands (e.g. “asdoc table” or “asdoc tabulate”) are executed normally by Stata and tables are created in the Stata window. However, instead of showing the “Click to Open File: Myfile.doc” line, the abovementioned error appears, so I cannot extract the tables in Word. Could you please explain why this happens and provide possible remedies? With the previous version of asdoc (November 2018), I did not face such issues.

    Thank you and best wishes,
    Kostas

    • Attaullah Shah April 9, 2019 at 6:42 pm - Reply

      Kostas
      Since you installed asdoc manually, now it seems there are two versions of asdoc on your system, one old and new. The function library gets confused among these versions. You should first uninstall asdoc completely using the following code, then reinstall asdoc and then restart your Stata.

      net install uninstall_asdoc, from(http://fintechprofessor.com) replace
      
      uninstall_asdoc
      
      ssc install asdoc, replace
  31. Kostas April 9, 2019 at 7:27 pm - Reply

    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

    • Attaullah Shah April 9, 2019 at 10:49 pm - Reply

      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.

  32. Finja May 14, 2019 at 2:34 pm - Reply

    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

    • Attaullah Shah May 14, 2019 at 2:47 pm - Reply

      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 and asdoc.sthlp files will go in the following folder

      C:/ado/plus/a

      The third file lasdoc.mlib will go into the following folder

      C:/ado/plus/l

      Where the last letter is small L.

  33. Jo May 30, 2019 at 9:56 am - Reply

    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.

    • Attaullah Shah May 31, 2019 at 2:56 pm - Reply

      Jo
      Please post the full Stata code, i.e what did you write and what did Stata say?

  34. Jas June 5, 2019 at 6:38 pm - Reply

    Dear Professor Shah,
    Is it possible to use asdoc using 3sls regression?

    Looking forward to your reply.

    Regards
    Jaskaran

    • Attaullah Shah June 7, 2019 at 8:47 pm - Reply

      I have added support for 3sls regressions in asdoc.

      This beta version can be installed from my site.

       net install asdoc, from(http://fintechprofessor.com) replace

      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.

      webuse klein, clear
      reg3 (consump wagepriv wagegovt) (wagepriv consump govt capital1)
      asdoc replay, nest replace
      reg3 (consump wagepriv wagegovt) (wagepriv consump  capital1)
      asdoc replay, nest
  35. Esteban Arellano June 10, 2019 at 8:02 am - Reply

    Dear professor Shah,

    I am using svy with asdoc, but I am creating weighted tables with

    asdoc svy: tabulate cedad csexo, count format(%14.3gc)

    and I get this answer “option count not allowed”, help with this issue please.

  36. Attaullah Shah June 10, 2019 at 11:24 am - Reply

    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.

  37. Mike June 25, 2019 at 2:01 pm - Reply

    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.

    • Attaullah Shah June 25, 2019 at 2:16 pm - Reply

      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.

      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.

  38. Joseph N July 13, 2019 at 2:53 am - Reply

    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 !!!

  39. Dr. Eric Melse July 15, 2019 at 2:41 pm - Reply

    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.

    sysuse auto
    asdoc sum , save(sum.doc) replace

    does save to sum.doc, but after that:

    asdoc sum

    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:

    sysuse auto
    asdoc sum , save(sum.doc) replace

    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):

    asdoc sum , nbrow

    It is very nice to have the option tzok, like (see attached MydocTzok.docx):

    *asdoc - current set up (all statistics have trailing zeros except N)
    asdoc sum , dec(2) tzok replace

    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):

    *asdoc - suggested code to only tzok selected statistics
    asdoc sum , dec(2) tzok(mean sd) replace

    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):

    *asdoc - suggested code to add a note row to the result table
    asdoc sum , dec(2) tzok note("{added row for note}"), replace

    Maybe this is helpful (certainly for me it would).

    Best regards,
    Dr. Eric Melse
    Amsterdam University of Applied Sciences

    • Attaullah Shah July 17, 2019 at 4:13 am - Reply

      Dear Dr Eric

      I’ve added 6 options for:

    • Text alignment in cells
    • Decimal points
    • Trailing zeros
    • and text formatting including bold and italics etc
    • last empty row removed
    • notes
    • 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

      asdoc sum, c2_fmt(\b)

      Format column 5 in italics

      asdoc sum, c5_fmt(\i)

      use two decimal points for column 3

      asdoc sum, c3_dec(2)

      Align column 5 text in the center

      asdoc sum, c5_align(\qc)

      Use trailing zeros with column 2

      asdoc sum, c2_tzok

      These options are then remembered until reset. To reset

      asdoc, reset_colfmt

      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

      asdoc sum, replace notes(\i \b My first ever note is in bold and italics)

      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.

      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.

  • Yasir July 31, 2019 at 7:30 am - Reply

    Please narrate to install VAR in STATA

  • Lex August 7, 2019 at 5:58 pm - Reply

    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);

    • Attaullah Shah August 9, 2019 at 12:43 pm - Reply

      Yes, asdoc works perfectly with Stata 16. In your installation command, you have to add option replace

      ssc install asdoc, replace
  • Lex August 10, 2019 at 2:22 am - Reply

    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…

    • Attaullah Shah August 10, 2019 at 2:56 am - Reply
      ssc install asdoc, replace

      The above shall install asdoc and replace any existing copy. But you have to restart Stata.

  • Ameer Muhammad September 13, 2019 at 12:39 am - Reply

    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

    • Attaullah Shah September 13, 2019 at 12:43 am - Reply

      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.

  • Fos September 16, 2019 at 2:21 pm - Reply

    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:

     asdoc svy :tabulate var, ci

    Where I’m doing something wrong?
    Thank you

  • Attaullah Shah September 17, 2019 at 8:26 am - Reply

    Fos
    The ci option is not yet available with svy tabulate command.

  • Félix Quiñones September 26, 2019 at 7:43 pm - Reply

    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:

     asdoc tabulate var1 var2, chi2 replace ///
           title(This is my Tittle)  ///
           notes(\i \b My first ever note is in bold and italics)

    or

    asdoc tab var1 var2, missing ///
          notes(Pearson chi2 =  10.3936   Pr = 0.006) ///
          save(today_2019.doc) title(This is my Tittle col chi2  

    I realized that chi-square and notes does not work with the tabulate command and asdoc.

    Any workaround?

    Thanks,
    Felix.

    • Attaullah Shah September 26, 2019 at 9:30 pm - Reply

      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.

      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.

  • Elena S. September 28, 2019 at 3:26 am - Reply

    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.

    • Attaullah Shah September 28, 2019 at 6:35 pm - Reply

      Elena
      Yes asdoc does not support date formats with tab command, but converting dates to string should work. See

      clear
      set obs 20
      gen date = mod(_n, 4)
      format date %td
      tostring date, gen(date2) u force
      asdoc tab date2, replace
  • Sheila Marilyn October 8, 2019 at 6:55 pm - Reply

    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:

    as doc sum,append

    and get this error:

    something required
    r(100);

    Kindly advise

    • Attaullah Shah October 9, 2019 at 12:16 am - Reply

      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

      sysuse auto, clear
      asdoc sum
  • Yunzhi November 5, 2019 at 5:22 am - Reply

    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

  • Edoardo November 18, 2019 at 2:29 am - Reply

    beautiful package, extremely helpful.. thanks a lot Dr. Shah

  • GSingh December 3, 2019 at 2:54 pm - Reply

    Request: Notes with nested regression table please. Or can you suggest an alternative?

    • Attaullah Shah December 3, 2019 at 6:24 pm - Reply

      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,

       sysuse auto, clear
      asdoc reg price mpg rep78, nest replace
      asdoc reg price mpg rep78, nest notes(These are new notes using asdoc)

      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.

  • GSingh December 5, 2019 at 9:48 am - Reply

    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.

  • Félix Quiñones December 5, 2019 at 11:17 pm - Reply

    Hello Dr. Shah,

    I’m using Notes for the two way tabulation. Can you make it available for one-way tabulations?

    Thanks,

    Félix.

  • Attaullah Shah December 5, 2019 at 11:34 pm - Reply

    Félix Quiñones
    I shall do that. Please tell me how you came to know about notes option?

  • Félix Quiñones December 9, 2019 at 7:15 pm - Reply

    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.

    • Attaullah Shah December 10, 2019 at 7:18 pm - Reply

      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

  • Dr. Christine Dauth December 14, 2019 at 7:47 am - Reply

    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?

    • Attaullah Shah December 14, 2019 at 7:50 am - Reply

      Dear Dauth Christine

      The error message implies incomplete installation. Please follow these steps.
      Try to install it again from SSC, using the following command

      ssc install asdoc, replace

      You may also try the latest beta version of asdoc from my site. For that, you may try:

      net install asdoc, from(http://fintechprofessor.com) replace

      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.

  • MS December 18, 2019 at 6:40 pm - Reply

    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!!

    • Attaullah Shah December 19, 2019 at 10:43 am - Reply

      MS
      Let me see it, I shall post the updates here.

  • MS December 20, 2019 at 5:56 pm - Reply

    Thank you! Looking forward to it!

  • Felix Quinones December 20, 2019 at 7:07 pm - Reply

    Hello Dr. Shah,

    I just discover that column options in tabulations are not allow anymore. Anything that we can do for that?

    Felix.

    • Attaullah Shah December 20, 2019 at 7:12 pm - Reply

      Felix Quinones
      Please post the actual command that you are using so that I can replicate the error.

  • Rodrigo Badilla January 1, 2020 at 4:59 am - Reply

    Dear professor,

    I would like report a bug that continually I get in a three way table using asdoc:

    sysuse auto, clear
    
    set seed 123
    gen rbi=rbinomial(1,.5)
    asdoc table rep78 foreign rbi, c(count mpg) sc col row 

    Total (row) not agree with stata results.

    Thanks

    • Attaullah Shah January 1, 2020 at 10:14 am - Reply

      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.

      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.

  • Rodrigo Badilla January 3, 2020 at 10:16 pm - Reply

    Dear Attaullah Shah

    Thanks for you reply and fix this issue! I will cite Asdoc of course!

    Regards
    Rodrigo.

  • Deonette February 1, 2020 at 2:25 pm - Reply

    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!

    • Attaullah Shah February 2, 2020 at 8:46 am - Reply

      You can specify the file name inside option save. See this example

      sysuse auto, clear
      asdoc sum, save(My Own File Name) replace
  • Siri February 3, 2020 at 5:11 pm - Reply

    Hi,

    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

  • Bishal Bharadwaj February 13, 2020 at 6:49 am - Reply

    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.

    func_nested_reg():  3001  expected 25 arguments but received 29
                     :     -  function returned error

    I might have made some mistakes.
    Thank you
    Regards
    Bishal

    • Attaullah Shah February 13, 2020 at 7:30 am - Reply

      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

      net install uninstall_asdoc, from(http://fintechprofessor.com) replace
      
      uninstall_asdoc

      2. Then re-install the latest version from my site with this code

      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.

      ssc install asdoc, replace

  • Liv February 27, 2020 at 9:35 am - Reply

    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.

    • Attaullah Shah February 27, 2020 at 1:25 pm - Reply

      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.

  • IM March 6, 2020 at 4:11 pm - Reply

    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

  • George March 9, 2020 at 6:41 am - Reply

    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.

  • Louis Boakye-Yiadom March 29, 2020 at 4:18 am - Reply

    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.

  • DP April 1, 2020 at 12:24 am - Reply

    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 ;

    asdoc areg YVAR c.XVAR1##c.XVAR2  DYEAR* DLT* DPP*, a(INDUS)  cl(PERMNO), ///
         add(Industry FE, Included, Firm FE, No, Package FE, No) rep(t) cnames(YVAR) fs(10) ///
         font(Times New Roman) fhr(\i) nest reset drop(DYEAR* DLT* DPP* _cons) label;

    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.

  • Shrikrishna Bhat K April 11, 2020 at 8:57 am - Reply

    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

    asdoc tab dist_code fourwheeler  [iw = trimweight], nofreq row title(Household - Row Wise Percentage)

    is not exporting the correct table. but the following code is working

    asdoc tab dist_code fourwheeler  [iw = trimweight], nofreq col title(Household - Column Wise Percentage)

    Please help me

    Thank you

  • Sarah April 15, 2020 at 10:43 am - Reply

    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:

    ----------------------
                   Coef
    =====================
    0bn
    Red             a
    Blue            b
    Yellow          c
    --------------------
    
  • Attaullah Shah April 15, 2020 at 1:30 pm - Reply

    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.

    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.

    Here is an example

    sysuse auto, clear
    asdoc reg price turn trunk i.foreign , nest replace nofvlabel

    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.

  • Víctor Coronel April 28, 2020 at 2:44 am - Reply

    Thanks, a very useful command, but how can i add graphics in the sheet results?

  • Aga April 28, 2020 at 12:20 pm - Reply

    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

  • Relindis Tapang April 29, 2020 at 8:35 pm - Reply

    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

     asdoc mlogit delivery ib(0).religion, baseoutcome(1) vce(robust) rrr, replace nest 

    thanks

  • Raj Iyengar May 27, 2020 at 10:03 am - Reply

    Attaullah,

    Thanks for the ASDOC stata command. Really appreciate it.

    Great job!

    Best,

  • Steph June 27, 2020 at 12:30 am - Reply

    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.

  • Leave A Comment