Alright folks, buckle up. Here's another edition of @Stata tips & tricks.

Today's topic is estimates - how to access them, how to save them, and how to change them
1) The easiest way to access a regression coefficient in your code is _b[varname]

sysuse auto
reg price mpg
di _b[mpg]
di _se[mpg]

This, btw, also works with factor variables:
reg price i.mpg
di _b[14.mpg]
2) If you want to access the t-statistics, p-values and CIs, they can be found in r(table)

sysuse auto
reg price mpg
matrix list r(table)

H/T @DeNewJohn
3) This one may be obvious for many, but bear with me.
To view other estimation details corresponding to your model, type:

ereturn list

This is the information that is saved when you type

estimates save my_estimates_1
4) This is also the information that is used when you export your results to TeX / Excel using commands such as 'esttab', 'outreg', etc.

Knowing that is handy when working with super-large datasets, because exporting results straight after running each model takes AGES.
Better approach is to save estimates for all your models into .ster files (using 'estimates save xxxx'), then use a smaller version of your dataset (say, by parsing 'sample 1'), and export your results all at once, fast and easy.
^ though I should mention that you should be careful with this shrinkage if you're using factor variables. Make sure that the observations in your smaller dataset still contain all the possible values of your factor variables.
6) If you need to add non-standard info to your estimates, you can use a simple 'eclass' function, such as:

program define EstAdd, eclass
syntax, Add(real) [Name(string)]
ereturn scalar `name' = `add'
end
EstAdd, add(3.14) name(pi)
ereturn list
Combining points 5 & 6 can make your code very efficient and scalable.

I use 6 to store the titles of my regression table columns, or append marginal effects & other relevant statistics.
7) as for the commands that export output to TeX or Excel, I do not have a strong preference.

I use outreg2. It is flexible, supports both sumstats & regression tables, and is able to produce a single XLS file with multiple tabs.

Happy to hear about your preferences, though!
Previous batch of tips & tricks for large data can be found here: https://twitter.com/JanKabatek/status/1303209197576663040
Let's put it to vote! Which @Stata command for exporting tables do you prefer?
You can follow @JanKabatek.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: