## How to use asdoc : a basic example

Category:asdoc## How to use asdoc

Using asdoc is pretty easy. You need to add just asdoc as a prefix to Stata commands. For example, we use sum command to find summary statistics of all numeric variables in the dataset. We shall add just asdoc as a prefix to sum. Let us load the auto.dta set for practice and find summary stats of all numeric variables and send the output to MS Word with asdoc

sysuse auto asdoc sum

And voila, a beautiful table of descriptive statistic is ready [click here to see it].

And for correlations, we shall use asdoc cor. If we were to append the results to the same file, we shall just add append after the comma or leave it (append is the default, you can use replace to replace existing file)

asdoc cor OR asdoc cor, append

See also the following resources related to asdoc.

YouTube Video: Descriptive / Summary Statistics from Stata in Word with asdoc

YouTube Video: Create publication quality table of correlation in Stata with asdoc

YouTube Video: Writing all statistics to a single Word file from Stata with asdoc

YouTube Video: Create publication quality regression tables in Stata with asdoc

See a Table of Contents that shows what else asdoc can do

## 26 Comments

## Julia Schmidt

May 22, 2018at 11:20 amThis is such a useful program, it saved a lot of my time. A great breakthrough for all Stata users.

## Dr. Yasir Bin Tariq

May 28, 2018at 3:57 pmThank you very much. I must tell you this asdoc program has made getting output from STATA very easy. You are a an academic Saint ❤ 😍

## Alberto Otete

June 19, 2018at 2:59 pmI have used asdoc sum, with very good tables in Word. I have thus learnt from this forum.

## Myo Win

June 19, 2018at 2:59 pmThank you very much Attaullah Shah. asdoc command can create summarize table, corr table and regression tables easily in words doc. This command safe my time a lot.

## HCB

August 21, 2018at 4:33 pmThank you. This is completely genius and I was able to create descriptive tables in a few clicks. Saved so much time.

Can asdoc be used with imputed logistical regression as well?

## Attaullah Shah

August 26, 2018at 10:45 amDear HCB, Thanks for your comments. Can you please provide an example data set and the format in which results are required. I will look into the possibility of doing it with the current version of asdoc. If not available in the current version, I will consider it for the next version

## Poe Bitra

August 26, 2018at 10:55 amFirstly, I would like to thank you for the wonderful ASDOC package for Stata! It has been a tremendous help in my studies and it made me think about contributing to the Stata community when I have better understanding of the field.

Recently I have updated the package and the commands “asdoc, cells” no longer work. This is why I wondered if there were any big changes to the code and whether I could retrieve an earlier version of the asdoc.ado file. Thank you in advance!

## Attaullah Shah

August 26, 2018at 10:58 amDear Poe

Thanks for the kind words. Version 2 of asdoc is not yet out for public testing. Perhaps you updated it from my website where I upload only trial versions for testing. Recently, I replaced option

cellwith the optionrow. Try optionrowinstead ofcellsand tell me whether it solves the issu. Please do cite asdoc in your research.## Suman Kanougiya

September 14, 2018at 4:23 pmDear Attaullah,

The asdoc command is indeed very useful. But, I get two different results with and without asdoc commnad.

e.g

and

Would you please guide me what have I been doing wrong?

## Attaullah Shah

September 14, 2018at 5:22 pmDear Suman Kanougiya

Thanks for pointing this out. Yes, there was an omission of adding

condition in the asdoc code forifcommand. I have corrected it and shall send version 2.1 soon to SSC.pwcorIn the meanwhile, you can do the following to get correct results

## Matthew Millard

September 22, 2018at 2:18 amI 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.

## Sumeet Malik

October 3, 2018at 1:52 pmI came across your website through the youtube videos on ASDOC programme, which I think is very helpful and exponentially better than the OUTREG programme. If you could include p-values instead of stars, it would make the program even more useful since some of the top management journals now don’t want the asterisks in the tables.

## Attaullah Shah

October 10, 2018at 12:03 amDear Sumeet Malik

That is on my agenda for the next update. Thanks for your suggestion.

## Jannik Helweg-Larsen

October 10, 2018at 12:06 amSuch a brilliant and extremely useful and most impressive Stata program!

## Terence

October 18, 2018at 10:45 amThis is wonderful. Thank you!

## Million Tadesse

October 19, 2018at 4:28 amExcellent command, asdoc!. Almost ten years ago (approximate) I asked Prof Baum of esttab estout etc author if he can do the same for descriptive stat. results be exported to word. Now time has come! I just started using STATA again (more frequently) with lots of change (in STATA 15).

## Million Tadesse

October 25, 2018at 11:58 pmLooking more options after regress command with asdoc. Example, Age as “Age in years” as we used to do in estout command after regress. Estout has several other options. Where are those with asdoc after regress? Sorry if I missed your posts.

## Attaullah Shah

October 26, 2018at 12:09 amMillion Tadesse: Thanks for your comments. I would need some details on what are you proposing. Do you mean to append additional statistics to the regression table? The default option in asdoc for outputting regression tables is the detailed regression type, and there asdoc produces some additional statistics such as the mean of the dependent variables, the standard deviation of the dependent variable etc. In the nested tables, these statistics are not reported. I would appreciate if you give a link to any table that you have in mind for asdoc or email me some examples at attaullah.shah@imsciences.edu.pk

## Nicola Deghaye

October 26, 2018at 4:20 pmI have installed your new asdoc code. Thanks – it looks very promising.I am having a challenge using it with tabstat. Here is the code:

This is what I get:

I am getting the mean, not the other stats. Here is what it should look like:

I have tried a lot of different ways of writing the code, but keep getting the same thing.

## Attaullah Shah

October 26, 2018at 4:24 pmDear Nicola Deghaye

There are two issues with your code. First, there is a space between

statand(N mean median sem). This space should not exist. Second, the allowed statistics issemean, notsem. So the correct code would bePlease do tell me whether the problem you are referring to is solved?

## Nicola Deghaye

October 29, 2018at 10:02 pmThank you so much! I am new at this and these little things trip me up so often. Thanks for taking the time to respond and for the great new code

## Million Tadesse

November 6, 2018at 11:28 amDear Dr Shah,

This is a follow up of my question on your website pasted below.

I was wondering for “varlabel” option to get my dummy variables (e.g. 2.Farmtyp, etc as shown above) shown in full:

Fruit crops instead of 2.farmtyp as shown above.

As you know esttab command has the capacity to write this variable in full.

Example:

regress y x1 x2

estimate store m1

regress z x1 x3

estimate store m2

esttab m1 m2,replace drop (“_age”) cells(b(star fmt(3)) bla bla

legend varlabels(_cons Constant CR “Access to credit”, etc etc. basically all variables in short form can be written in full here.

So I am missing lots of useful options with asdoc for a regress command. Can we store estimates as in the above example (m1 m2) and run/display them as in esttab command?

Thanks for the excellent work on asdoc.

benfpaid

Coef.

St.Err

t-value

p-value

Sig.

AccruaAllowRevn

-0.149

0.016

-9.60

0.000

***

AccruaAllowExpn

0.151

0.019

7.97

0.000

***

RML

0.066

0.009

7.18

0.000

***

1b.Farmtyp

0.000

.

.

.

2.Farmtyp

-11600.000

3456.754

-3.36

0.001

***

3.Farmtyp

94.207

8363.845

0.01

0.991

4.Farmtyp

-52600.000

14660.636

-3.59

0.000

***

5.Farmtyp

-3761.678

13938.630

-0.27

0.787

7.Farmtyp

-33400.000

8160.412

-4.10

0.000

***

8.Farmtyp

-44600.000

16514.566

-2.70

0.007

***

9.Farmtyp

74530.888

8088.643

9.21

0.000

***

10.Farmtyp

5177.118

20400.808

0.25

0.800

11.Farmtyp

-18500.000

13459.766

-1.37

0.170

12.Farmtyp

-17700.000

7798.791

-2.27

0.024

**

_cons

17447.843

2836.525

6.15

0.000

***

Mean dependent var

21275.009

SD dependent var

61990.793

R-squared

0.381

Number of obs

1142.000

F-test

53.366

Prob > F

0.000

Akaike crit. (AIC)

27923.777

Bayesian crit. (BIC)

27994.344

*** p<0.01, ** p<0.05, * p<0.1

Note that I did not read everything on asdoc yet. Sorry if you already answered this.

## Attaullah Shah

November 6, 2018at 11:47 amMillion Tadesse: Thanks for the detailed reply. If I have correctly understood your point, you want to show variable labels instead of variable names. In the recent release of asdoc, I have added the option label, that will show variable labels instead of variable names. For example, see the two regressions

Reporting variable namesReporting variable labelsFor the factor variables, you are right the option label does not work yet, and I have noted your suggestion. Since you said you have not read the asdoc help file yet, I would recommend exploring three important options that can be used with asdoc.

Detailed regression (default)

Nested regressions

Wide regressions

These are discussed with examples in post 38 on this thread on Statalist https://www.statalist.org/forums/forum/general-stata-discussion/general/1435798-asdoc-an-easy-way-of-creating-publication-quality-tables-from-stata-commands/page3

## Scandinaven

November 21, 2018at 11:11 pmDear Professor

Thank you so much for a great program for Stata. We are currently having big problems with Nordic characters such äöå when using label outputs. Is it something you are planning to remediate?

## Attaullah Shah

November 21, 2018at 11:17 pmScandinaven: I replied to a similar query on Statalist here – posts 45-46, where Chen Samulsion asked about the possibility of passing Chines characters from Stata to a Word file using asdoc. My reply was that getting Chinese characters in an RTF file is a pain in the neck. Usually, getting Chinese characters programmatically into an RTF file does not seem straightforward, one has to first convert the letters to Unicode and then render it properly in the RTF file.

I think similar is the case with Nordic characters. Right now, I am struggling with finding a way out.

## Mior Faizmie Bin Yusof Za Ba

December 4, 2018at 8:28 pmDear Attaullah Shah,

Thank you for stata command. May Allah bless you here and hereafter.