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
command of Stata. Since we estimate correlations among all numeric variables of a dataset by typing cor
in Stata, we shall add asdoc as a prefix to the cor command. 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 a correlation table with significance/stars
Generate a table of descriptive statistics
Generate a table of customized descriptive statistics
I can’t download asdoc from the stata. Can you help me and sent the asdoc.ado and asdoc.sthlp to me?
Thank you.
To download, type
ssc install asdoc
If you receive any error message, then please share that.
Sorry. 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.
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.
Hi Attaullah,
How can I get the star sign in the correlation number? Is it possible to get it using the asdoc command.
Simon: The significance stars can be reported using the sub-command pwcorr. For example
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
Simon: Reporting stars for showing statistical significance at .05 or 0.1 level works the same way as shown above. For example,
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
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
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.
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.
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
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.
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
asdoc 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
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,
Chris
Chris Boulis
It 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.
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).
Kind regards,
Chris
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 attaullah.shah@imsciences.edu.pk
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’.
etc.
What do you think?
Kind regards,
Chris
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.Dear 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
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
Professor,
The command asdoc it’s not working on my Stata. The system shows as result: asdoc pwcorr lg lc ls ebitda roa roe etr nm ativt pl
(note: file Myfile.doc not found)
What’s wrong?
Thank you!
Anders
It seems an installation issue. Please install asdoc again by
If that does not solve the problem then please send me your data, the code that you used with asdoc and tell me whether you are using Windows or MaCOs. My email is attaullah.shah@imsciences.edu.pk
Dear Professor,
The command asdoc it’s not working properly on my Stata either. When I call for corr it works:
<pre>asdoc corr Q6_työ_paha Q36_vie_mukanaan , sig star(*0.10 **0.05 ***0.01) save(K:\My Documents/korrelaatiot.doc) append
(obs=5,757)
But when I call for pwcorr it doesnt work:
Could you please help me
Thank you!
Sanna
You are using the star() option incorrectly. If you want to report stars for statistical significance, then you need to type star(all). See
Sidenote: The sig option renders the table rather untidy, so if you are reporting stars, the sig option is really not needed.
Dear Dr. Shah,
this is a great addition to Stata and has helped me very much. I have one small question concerning the significance stars in the correlation matrix. Right now, if I use the star(all) command, it will add stars for significance at .1, .05 and .01 level. Is there any way I can change this so that it will add stars at .05, .01 and .001 level instead?
Thank you in advance for your time and help!
Dear Sir,
I have the same problem as Anders.
The command is working with corr, but for pwcorr I do get an invalid name error r(198).
pwcorr without asdoc is working however.
The weird thing is, that this worked just fine in the past and I din’t change the code.
Thanks for your help
Thomas
The error was fixed recently. The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
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.
Thanks for the quick response sir,
however I still get the invalid name error.
I am using Stata 15.1 if that makes a difference?
kind regards Thomas
Thomas
Can you please send your data and the code that you are using at my email attaullah.shah@imsciences.edu.pk
I have corrected the error.
The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
Please note that the above line has to be copied in full. After installation of the new version, then restart Stata.
asdoc with pwcorr currently does not report observations, I shall work on it sometimes in the future.
Hi,
Thanks for creating and sharing the asdoc command. When I try to use it for spearman results, it produces the results but they are not displayed correctly as it seems to produce the results as individual rows that are stacked together rather than as a single table. See example below. Is there a workaround for this?
Thanks,
I have added support for spearman command to asdoc.
The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
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.
Wonderful program. Thank you.
One problem I am having: the ‘label’ option is not working. Whether I use my own data, or ‘auto’, I get the var names, not the labels.
Stata 15. Is there a way to correct this?
Apologies for the earlier query. I had a mistake in my own code. I am getting the ‘label’ function to work.
Thank you for this wonderful resource!
Hello!
I use stata16.0, please help me. In the table exported by asdoc command, Chinese charactors are displayed as garbled codes. How to solve this problem?
Yes, Chinese characters present a Unicode problem which is currently not supported by asdoc. Please try this link if it solves your issue https://fintechprofessor.com/2019/05/23/asdoc-unicode-issue-stata-to-ms-word/
Hi Shah,
With the spearman results, how to include all stars for the significance levels?
Is it possible to export the correlation matrix with the p-value underneath the rs? I’m trying to export matrices generated by:
bysort groups: spearman var1 var2 var3 var4 var5 var6, pw stats(rho p obs) star(0.05)
Many thanks!
Hi,
Is it possible to change the format of the values using fmt() with asdoc?
You can use
dec()
option to control the number of decimal points. If two decimals are needed, then adddec(2)
Dear Attaullah Shah,
Hi,
Now, I am working on the difference in differences analysis and I would like to create a table for below commands but after running it, although I got the correct results, I got the wrong table with below commands. I would like a get a research paper style so I appreciate it if you can shed a bit more light on this issue and advise me on how to deal with this problem when you are available.
Thank you in advance for your precious help.
Best regards,
Catherine
Catherine
The diff package is a community-contributed package. Since it is not an official Stata program, asdoc tries to make a table out of the generated output using one of its generic routines. I shall add support for this in the asdocx version of asdoc, which is almost complete. You can check the details of asdocx here https://fintechprofessor.com/stata-programs/asdocx/
Dear professor,
Thanks for your excellent program.
I’m having a problem. When I try to export a correlation table using the command “asdoc pwcorr”, my Stata/MP 15.1 displays the following results:
rtf_maker(): 3301 subscript invalid
: – function returned error
r(3301);
It is because I have too many variables? How can I solve this problem?
Thanks a lot!
Best regards,
Kacy
Hello Kacy
Are you using the updated version of asdoc? The new version of asdoc can be installed from my site. Copy and paste the following line in Stata and press enter.
Please note that the above line has to be copied in full. After installation of the new version, then restart Stata.
If the problem still exists, then please send me your data and the code you are using at attaullah.shah@imsciences.edu.pk
Please also check asdocx here that is more powerful and flexible than asdoc.