1
votes

Say I have this data:

eststo clear
sysuse auto2, clear

I perform a regression:

reg mpg price turn

I would like to use esttab's rename functionality to rename the variables. However, when I do:

esttab, rename("price" "(1,2)" "turn" "(3,5)")

the commas disappear.

And when I do:

esttab, rename("price" "Var1: (1,2)" "turn" "Var2: (3,5)")

I get an error message.

I have tried creating a local and using that in rename, but I get an error there too.

local a "(1,2)"
display "`a'"
esttab, rename("price" "`a'")

But this just reproduces the comma problem.

How can I fix these two problems (especially the first one)?

esttab is a community-contributed command.

1

1 Answers

2
votes

It looks like that both , and : are used for internal parsing, so you are out of luck if you want to use the rename() option.

However, you can fix both problems by doing the following:

eststo clear
sysuse auto2, clear

label variable price "(1,2)"
label variable turn "(3,5)"

reg mpg price turn
esttab, label

------------------------------------
                              (1)   
                     Mileage (m~)   
------------------------------------
(1,2)                   -0.000534** 
                          (-3.38)   

(3,5)                      -0.835***
                          (-7.89)   

Constant                    57.69***
                          (14.32)   
------------------------------------
Observations                   74   
------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

And:

label variable price "Var1: (1,2)"
label variable turn "Var2: (3,5)"

reg mpg price turn
esttab, label

------------------------------------
                              (1)   
                     Mileage (m~)   
------------------------------------
Var1: (1,2)             -0.000534** 
                          (-3.38)   

Var2: (3,5)                -0.835***
                          (-7.89)   

Constant                    57.69***
                          (14.32)   
------------------------------------
Observations                   74   
------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

EDIT:

The help file of estout confirms:

rename(matchlist) changes the names of individual coefficients, where
        matchlist is

            oldname newname [oldname newname ...]

        oldname can be a parameter name (e.g. price) or a full name including
        an equation specification (e.g. mean:price)...

The comma is probably used as a delimiter.