How to export high-quality table of correlations from Stata to MS Word

  • 24

How to export high-quality table of correlations from Stata to MS Word

Category:asdoc Tags : 

For creating a high-quality publication-ready table of correlations from Stata output, we need to install asdoc program from SSC first.

ssc install asdoc, update

Once the installation is complete, we shall add the word asdoc to the cor or correlate command of Stata. Since we estimate correlations among all numeric variables of a dataset with just cor, we shall add asdoc as a prefix to the cor command. For our example, purposes, let us load the auto.dta data from the Stata example files.

Example 1: Make a table of correlation for all variables.

sysuse auto, clear
asdoc cor

Example 2: We can report variable labels instead of variable names

asdoc cor, label replace

Further, it is possible to write names of the variables in the column headings instead of sequential numbers. For this, we shall invoke the option nonum. Therefore, see example 3.

Example 3: Write variable names in column headers

sysuse auto, clear

asdoc pwcorr, nonum replace

Read also : 

Table of contents of asdoc

Generate a correlation table with significance/stars

Generate a table of descriptive statistics

Generate a table of customized descriptive statistics


Zhang Huang

November 12, 2018at 2:48 pm

I can’t download asdoc from the stata. Can you help me and sent the asdoc.ado and asdoc.sthlp to me?
Thank you.

    Attaullah Shah

    November 12, 2018at 2:50 pm

    To download, type
    ssc install asdoc

    If you receive any error message, then please share that.

Zhang Huang

November 12, 2018at 2:53 pm

Sorry. It always replies like this in Stata:

ssc install asdoc, replace

checking asdoc consistency and verifying not already installed…
connection timed out -- see help r(2) for troubleshooting
could not copy
(no action taken)

I think maybe because I am in China, so the download action is defined.

Attaullah Shah

November 12, 2018at 2:55 pm

OK, copy the attached files to the mentioned directories

copy asdoc.ado and asdoc.sthlp to this folder


2. Copy the lasdoc.mlib to this folder


The last letter is L in small.


December 25, 2018at 5:44 pm

Hi Attaullah,

How can I get the star sign in the correlation number? Is it possible to get it using the asdoc command.

    Attaullah Shah

    December 25, 2018at 6:50 pm

    Simon: The significance stars can be reported using the sub-command pwcorr. For example

    sysuse auto
     asdoc pwcorr price headroom mpg displacement, star(.01) replace


December 28, 2018at 5:33 pm

Hi Attaullah,

Many thanks for your reply. can we get also 0.05 and 0.10. I have tried with the given code but it does not work.



    Attaullah Shah

    December 28, 2018at 6:55 pm

    Simon: Reporting stars for showing statistical significance at .05 or 0.1 level works the same way as shown above. For example,

    sysuse auto, clear
    * At 5% level
     asdoc pwcorr price headroom mpg displacement, star(.05) replace
    * At 10% level
     asdoc pwcorr price headroom mpg displacement, star(.1) replace


January 1, 2019at 6:11 pm

Many thanks Attaullah. I understand your point. But actually, my query was in one table, how we can generate all star sign for 0.1, 0.5, and 0.01. Similar like the correlation table published in the article. Sometimes, in one table, some variables may be significat at 1%, some at 5% and some at 10%.

Appreciate your help.

Thanks again.


January 25, 2019at 7:32 pm

Thank you very much Attaullah. I have one question:

I have a lot of independent variables (41) in my correlation matrix. How can i prevent that asdoc exports them and needs more than the breadth of one page in word? In an ideal case i can tell asdoc to continue the correlation matrix at the next page.

Do you know if there is such an opportunity?

Thank you in advance!


    Attaullah Shah

    January 27, 2019at 8:34 am

    Thanks for the suggestion. I never thought that one might need a correlation table for so many variables. I shall keep this in mind and work on it when I have some time.


January 28, 2019at 8:46 pm

Dear Attaullah. No worries. I dont want to estimate all of the variables within one model. With the large variable list i can show that for several combinations of variables serious issues of multicollinearity arise. Thereby i can justify my choosen model better.

Professor Michael Glencross

March 19, 2019at 9:13 am

Dear Professor Shah

I have recently come across your excellent addition to Stata in the form of asdoc. Is there any way that it can be made compatible with Stata 11?

Kind regards

Michael Glencross

Attaullah Shah

March 19, 2019at 9:15 am

Dear Michael Glencross
The only reason asdoc does not support Stata 11 is that the Stata Corp. introduced the r(table) with regression commands in Stata 12 and onwards. Since asdoc creates regression tables from r(table) matrix, therefore, I restricted it to version 12 and onwards. Still, if you do not use asdoc for regressions, it can still work with Stata 11. So find asdoc.ado on your computer, open it with notepad or Stata do editor and delete the line version 12.
Restart Stata and it will work with Stata 11.

Professor Michael Glencross

March 21, 2019at 12:45 pm

Dear Professor Shah

I have another query and hope you don’t mind me asking for your help again.

I have done as you said and removed the line version 12 from my asdoc.ado file.

I ran: asdoc tab gender and received the following error message:

asdoc_tab_onevar() in lasdoc, compiled by Stata 11.1, is too new to be run by this version of Stata and so was ignored

Is there something I can do to overcome this?

Your help will be much appreciated.

Kind regards

Michael Glencross

Chris Boulis

April 13, 2019at 1:26 pm

Dr. Attaullah Shah .

I have just downloaded asdoc and am planning to capture the results from three pairs of regressions. Each pair regresses the same control variables, but changes the dependent variable (I have 2 measures of my depvar). Each pair works the same, but in each pair I assess the impact of a slightly different life event.

I’ve watched your youtube video which shows how to keep adding variables, but I was wondering how I do that in my case?

I’d like to produce a table where the rows included all the control variables (which as I said are the same for each regression) and across the columns have the three different life events – with two separate columns below each life event to show the results of my two measures of my depvar.

I would really appreciate your guidance on how I can do this using your package asdoc. I tried using outreg but copying the table to word in html format leaves a mess that will require a lot of time to make it presentable.

Kind regards,

    Attaullah Shah

    April 13, 2019at 1:52 pm

    Chris Boulis
    It seems you need a wide regression table. In the help file of asdoc, which you can access by typing:

    help asdoc

    Go to Section 4.3.1 where I have shown all options and related examples of wide regressions. See the following example for quick start.

    sysuse auto
    asdoc reg price mpg rep78, replace wide
    * Add another regression where the dependent variable is trunk
    asdoc reg trunk mpg rep78, wide
    * Add third regression where the dependent variable is weight
    asdoc reg weight mpg rep78, wide

    Please cite asdoc in your work:
    In-text citation
    Tables were created using asdoc, a Stata program written by Shah (2018).

    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.

Chris Boulis

April 14, 2019at 3:50 am

Dr Attaullah Shah.

Thank you for your response. However, after I tried that, it moved all independent variables wide and only had the two measures of the depvar in rows, which results in the table being too wide. I need all the indepvars in the rows and each pair of depvars for each of the three life events across the columns.

The following is an example of the table I am trying to obtain from my six regressions (e.g.

Life event1 – depvar1, Life event1 – depvar2, Life event2 – depvar1, Life event2 – depvar2, Life event3 – depvar1, Life event3 – depvar2).

Variables                    Life event 1                                    Life event 2                                   Life event 3
                              depvar1       depvar2                   depvar1       depvar2                    depvar1       depvar2
                                0.003             0.004                         0.25               0.21                            0.32              0.28
Control vars

Sex                               0.22           0.19                          0.25              0.36                           0.38                0.42
Age                               0.65           0.54                          0.32              0.45                           0.62                0.49                
Emp Status                 etc

Kind regards,

    Attaullah Shah

    April 14, 2019at 6:23 am

    Chris Boulis
    It seems you need a nested table, not a wide table. For nested tables, you need something like this. It would be much easier for me to code this if you can send me your data and regression commands at

Chris Boulis

April 15, 2019at 6:30 pm

Dear Dr Attaullah Shah.

Thank you for your assistance. Unfortunately, I am using a very large panel dataset and not permitted to share sorry.

I used the following code and added several other regressions and was able to get close to what I wanted but I had to do a fair amount of formatting as it carried over the pre-recoded (original) variables names, but that’s ok. I need to finalise this for tomorrow. The output I have I have now is much better than using ‘outreg’.

asdoc xtreg relat b100.time_marr_sep b10.rel b1.age b1.empstat b9.edlev ///

b1.Inc if reli ! = . & wave > = 4 & wave < = 14  & time_marr_sep  96, fe nest replace


asdoc xtreg reli b100.time_marr_sep b10.rel b1.age b1.empstat b9.edlev ///

b1.Inc if relat ! = . & wave > = 4 & wave < = 14  & time_marr_sep  96, fe nest append



What do you think?

Kind regards,


    Attaullah Shah

    April 15, 2019at 6:33 pm

    Dear Christopher
    That’s OK if you canncot share your data. The commands you have typed seems in good shape. Just one comment on your line ” it carried over the pre-recorded (original) variables names, but that’s ok. ” If you want you can replace variable names with variable labels using option label.

    asdoc xtreg relat b100.time_marr_sep b10.rel b1.age b1.empstat b9.edlev ///
    b1.Inc if reli ! = . & wave > = 4 & wave < = 14  & time_marr_sep < 104 & ///
    time_marr_sep > 96, fe nest replace label
    asdoc xtreg reli b100.time_marr_sep b10.rel b1.age b1.empstat b9.edlev ///
    b1.Inc if relat ! = . & wave > = 4 & wave < = 14  & time_marr_sep < 104 & ///
    time_marr_sep > 96, fe nest append label

Nighat Seema

April 15, 2019at 8:03 pm

Dear Sir

Hope you are fine. I am facing some issue in output of corr matrix via asdoc. I am using the command

asdoc cor f_con f_con2 f_man exp own_foreign bank_loans audit web exports f_age, label replace

The output table attached below does not include the names of all the variables. Kindly suggest something in this regard. I will be really thankful to you.


    Attaullah Shah

    April 15, 2019at 8:05 pm

    Nighat Seema
    The variable names are abbreviated to save space. If you do not want abbreviated names, then use extend the allowed abbreviated characters with the option abb(). For example, in your command, I am attaching abb(72), that will accommodate up to 72 characters in the variable names

    asdoc cor f_con f_con2 f_man exp own_foreign bank_loans audit web exports f_age, label replace abb(72)

Leave a Reply

13 − 8 =