Useful Commands in Stata
A list of commands I have found useful in empirical projects
-
kountry
: Command for getting country names and codes in different formats (ssc install kountry
). -
wbopendata
: Download data from World Bank directly from STATA (ssc install wbopendata
). -
reghdfe
: Generalization of areg for multiple level of fixed effects and multi-way clustering (ssc install reghdfe
). -
gtools
: Faster Stata for big data. Includes faster equivalents to collapse, reshape, egen and many more. Just need to addg
to the command (e.g.gcollapse
). To install all just typessc install gtools
. -
sumup
: Summarize data by groups -
texdoc
: Latex tables directly on STATA. Longer (but worth it) way to get results into latex tables directly from STATA (ssc install texdoc
) -
binscatter2
Faster binned scatterplots. It allows for multi-way fixed effects, unlikebinscatter
(ssc install binscatter2
). -
mdesc
: STATA module to tabulate missing values (ssc install mdesc
). -
winsor2
New version of commandwinsor
. Useful when you need to winsorize or trim outliers. Additional features include the possibility to winsorize on different levels at both ends of the distribituion. (ssc install winsor2
). -
compress
: Attempts to reduce the amount of memory used for the data. Important when working with large datasets. For an efficient way of generating new variables usegen [data type] varlist = exp
, for examplegen int N_obs = _n
-
levelsof
: transforms values of a string into local macros. -
tokenize
: Divide strings into tokens -
grc1leg2
: Add a common legend to combined graphs (findit grc1leg2). -
sendtoslack
: Send message to inform the code finished. Very helpful when working with large administrative data. -
codebook
: Command to describe data.