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

Category:asdoc

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

Generate correlation table with significance/stars

Generate a table of descriptive statistics

## 24 Comments

## Zhang Huang

November 12, 2018at 2:48 pmI 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 pmTo download, type

ssc install asdoc

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

## Zhang Huang

November 12, 2018at 2:53 pmSorry. It always replies like this in Stata:

checking asdoc consistency and verifying not already installed…

`connection timed out -- see help r(2) for troubleshooting`

could not copy http://fmwww.bc.edu/repec/bocode/a/asdoc.sthlp

(no action taken)

r(2);

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

## Attaullah Shah

November 12, 2018at 2:55 pmOK, 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.

## Simon

December 25, 2018at 5:44 pmHi 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 pmSimon: The significance stars can be reported using the sub-command pwcorr. For example

## Simon

December 28, 2018at 5:33 pmHi 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.

Regards,

Simon

## Attaullah Shah

December 28, 2018at 6:55 pmSimon: Reporting stars for showing statistical significance at .05 or 0.1 level works the same way as shown above. For example,

## Anonymous

January 1, 2019at 6:11 pmMany 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.

Regards,

Simon

## Philipp

January 25, 2019at 7:32 pmThank 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!

Philipp

## Attaullah Shah

January 27, 2019at 8:34 amPhilippThanks 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.

## Philipp

January 28, 2019at 8:46 pmDear 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 amDear 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 amDear Michael GlencrossThe 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 pmDear 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

## Attaullah Shah

March 21, 2019at 12:47 pmasdoc Meta library was compiled with Stata 11.1, you can update your Stata for free to version 11.1

https://www.stata.com/support/updates/stata11.html

## Chris Boulis

April 13, 2019at 1:26 pmDr. 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,

Chris

## Attaullah Shah

April 13, 2019at 1:52 pmChris BoulisIt seems you need a wide regression table. In the help file of asdoc, which you can access by typing:

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.

Please cite asdoc in your work:

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.## Chris Boulis

April 14, 2019at 3:50 amDr 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).

Kind regards,

Chris

## Attaullah Shah

April 14, 2019at 6:23 amChris BoulisIt 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 attaullah.shah@imsciences.edu.pk

## Chris Boulis

April 15, 2019at 6:30 pmDear 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’.

etc.

What do you think?

Kind regards,

Chris

## Attaullah Shah

April 15, 2019at 6:33 pmDear 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.## Nighat Seema

April 15, 2019at 8:03 pmDear Sir

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

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.

Regards

## Attaullah Shah

April 15, 2019at 8:05 pmNighat SeemaThe 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