## Ordering variables in a nested regression table of asdoc in Stata

Category:asdoc,BlogIn this blog entry, I shall highlight one important, yet **keep() i**n nested regression tables of asdoc. If you have not used asdoc previously, this half-page introduction will put on

## Option keep()

There are almost a dozen options in controlling the output of a regression table in asdoc. One of them is the **keep**(*list of variable names*). This option is primarily used for reporting coefficient of the desired variables. However, this option can also be used for changing the order of the variables in the output table. I explore these with relevant examples below.

### 1. Changing the order of variables

Suppose we want to report our regression variables in a specific order, we shall use option keep() and list the variable names in the desired order inside the brackets of

### An example

Let us use the auto dataset from the system folder and estimate two regressions. As with any other Stata command, we need to add asdoc to the beginning of the command line. We shall nest these regressions in one table, hence we need to use the option nest. Also, we shall use option replace in the first regression to replace any existing output file in the current directory. Let’s say we want to variables to appear in this order in the output file **_cons trunk weight turn**. Therefore, the variables are listed in this order inside the keep() option. The code and output file are shown below.

sysuse auto, clear

asdoc reg mpg turn, nest replace

asdoc reg mpg turn weight trunk, nest keep(_cons trunk weight turn)

### 2. Reporting only needed variables

Option keep is also used for reporting only needed variables, for example, we might not be interested in reporting coefficients of

sysuse auto, clear

asdoc reg mpg turn, nest replace

asdoc reg mpg turn weight trunk, nest keep(_cons trunk weight)

Off course, we could also have used option **drop(turn)** instead of option **keep(_cons trunk weight)** for dropping variable turn from the output table.

## 8 Comments

## Fa

February 2, 2019at 3:52 pmTwo queries

1. Some time we are interested in F-Stat value and it’s P-Value. To identify the overall significance of model. Both asdoc and outreg do not report it in table. If you can guide please.

2. Can we add t-test or any other test for mean difference with in same regression table. For example, if we regress 5 portfolios and at last we are interested in testing mean difference of Port-1 and Port-5.

## Attaullah Shah

February 2, 2019at 8:37 pmFa:For your first query, I would refer you to the help file of asdoc, Section 4. Regressions, subsection 4.10 option

`stat()`

. You can use optionstat()for reporting any statistic from the`e()`

macro. These statistics are usually revealed by typingafter the regress command. The macro for F-statistic is

`e(F)`

. So if you wish to report it with asdoc, you can use option`stat(F)`

. e.g,For your second query, I would refer you again to the help file of asdoc, Section 4, subsection 4.8, option

`add()`

. You can use option`add()`

to add up to three lines of additional text and statistics. This option adds text legends to the bottom cells of the nested regression table. The text legends should be added in pairs of two, each one separated by a comma. So to add mean of a variable to the regression table, see how I use this option. First, I create the mean with`sum`

command, write it to a local named as`mean1`

, and then add additional text and the local in the`add()`

option.Right now this option needs some additional tweaks as it deletes decimal points, therefore, I have written the above macro with zero decimal points. I shall work on it sometime in future.

## Paul Schumann

February 14, 2019at 7:16 pmDear Mr. Shah,

First of all, I’d like to thank you for introducing the asdoc package to Stata. This is a great addition and I used it successfully many times. However, there seems to be a problem with asdoc when using a mixed model for analyzing panel data. For some reason, it gives me an error message.

command “

`befristetwithin`

” is unrecognizedBefristetwithin is part of my analyses, which im trying to estimate as a random effect. I think there could be an issue with the highlighted part of my regression. Maybe asdoc does not know how to handle this part, since it involves some “unsual” signs. It would be great and i really appreciate it, if you could give me any advice on how to solve this issue.

my regression:

Kind Regards,

Paul Schumann

## Attaullah Shah

February 14, 2019at 7:24 pmDear Paul SchumannThanks for the feedback. I have changed asdoc and uploaded a new version to SSC. Please install it by

I hope it will solve the problem. Please do cite asdoc in your research.

In-text citationTables were created using asdoc, a Stata program written by Shah (2018).

BibliographyShah, 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.

## Farah Zamir

March 5, 2019at 3:47 amHi Dr Shah

Can w replace tstat instead of standard errors while reporting our results in Stata?

I mean use “tstat in paranthesis” instead of “Standard errors are in parenthesis” ???????

## Attaullah Shah

March 5, 2019at 7:17 amFarah ZamirThe option

`rep(t)`

can be used for reporting t-statistics when making a nested regression table.## Bram Hogendoorn

April 15, 2019at 5:23 pmDear Mr. Shah,

Thank you for your dedicated introduction of asdoc. Its user friendlyness and concise helpfiles make it a great addition to Stata.

I have a question regarding the significance stars. When using the “eform” option of cloglog, the significance stars seem to be reported incorrectly. I think that this is because the regression coefficients are exponentiated while the standard errors are not; hence the stars are reported over the wrong franction – but this is just a guess.

It would be great if you could have a look at this. Thank you very much.

## Attaullah Shah

April 15, 2019at 6:21 pmDear Bram HogendoornThanks for your kinds words and pointing out this bug. The problem occurs in cloglog regression when using option

`eform`

and`nest`

together. I shall rectify the error soon.