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

  • 12

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 correlation table with significance/stars

Generate a table of descriptive statistics

 

 

 

 

 


12 Comments

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

OK, copy the attached files to the mentioned directories

copy asdoc.ado and asdoc.sthlp to this folder

C:/ado/plus/a

2. Copy the lasdoc.mlib to this folder

C:/ado/plus/l

The last letter is L in small.

Simon

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

Simon

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.

Regards,

Simon

    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
    
    				
    				
    				

Anonymous

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.
Regards,
Simon

Philipp

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!

Philipp

    Attaullah Shah

    January 27, 2019at 8:34 am

    Philipp
    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.

Philipp

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.

Leave a Reply

twenty − 1 =