Add normal distribution to kernel density plot in Stata

This might be already implemented in the most recent version of Stata, but I just came across the problem that there seems to be no straightforward way to combine a kernel density plot (i.e. kdensity) with a normal distribution of the underlying variable.

Continue reading “Add normal distribution to kernel density plot in Stata”

Information about Stata macros: number of elements and order within locals and globals

Especially when running loops (see our posts here), it can be important to get more information about a macro, such as the length, or its first or last element.

Continue reading “Information about Stata macros: number of elements and order within locals and globals”

Useful string functions in Stata (updated list)

Most often when I search the internet for help on Stata, it is probably when I need to work with string variables (such as names). There are some very good summaries that cover aspects of string variables (e.g., this page). In this post –which will be continuously updated– we present random string functions that we think are extremely useful for Stata users.

Continue reading “Useful string functions in Stata (updated list)”

#StataTip: to format output in your log file or results window in @Stata, you can print text in red (–di as error “Text in red”–) or bold (–di as result “Text”–). If you are using black background use “as text” (green), “result” (yellow), “error” (red), and “input” (white)