benjann / estout

Stata module to make regression tables
http://repec.sowi.unibe.ch/stata/estout/index.html
MIT License
71 stars 18 forks source link

how to use rename option for factor variables? #55

Closed fredericky123 closed 1 year ago

fredericky123 commented 1 year ago

No matter what I set, the factor variable is not be wrapped to one row

sysuse auto,clear
gen foreign1=foreign+1
eststo clear
eststo:reg price mpg i.foreign
eststo:reg price mpg i.foreign1
esttab, rename(foreign foreign1) label nobaselevels
esttab, rename(foreign foreign1) nobaselevels
NilsEnevoldsen commented 1 year ago

The rename option takes individual coefficients, not variables.

Try this:

esttab, rename(1.foreign 2.foreign1) label nobaselevels
fredericky123 commented 1 year ago

Thanks a ton! If I still have a 3.foreign2 need to be wrapped, how to set it?

NilsEnevoldsen commented 1 year ago

Did you check out http://repec.sowi.unibe.ch/stata/estout/help-estout.html#stlog-1-rename? You'd do

rename(1.foreign 2.foreign1 1.foreign 3.foreign2)

If you have several models, none of which has the obviously correct coefficient names, then it may be most readable or intuitive to invent an entirely new coefficient name and rename everything to that, e.g.

rename(foo 1.foreign foo 2.foreign1 foo 3.foreign2)
fredericky123 commented 1 year ago

I see, thanks! Sorry not to understand the manaual correctly.