Stata – Exporting dates in filenames

A key feature of writing long do-files is to export various outputs, logs, excel files, etc. at the end of your run. More often than not, it is useful to capture changes over time as data analysis progresses. It is therefore useful to export files and version control them with dates. A good practice is to save them in the format:


for example:


Continue reading

Stata to Latex – Part 1: Exporting customized tables

Anyone writing an empirical paper eventually has to deal with the issue of exporting Stata outputs to a Latex file. While standard statistics and regressions are easy to handle, as soon as customized outputs are required, it quickly becomes messy, requiring significant head scratching. Making tables by hand is not really advisable, since one is likely to tweak the outputs several times. In this entry, we look at a simple example of stacking standard errors from different regression outputs which have the same beta coefficient but different significance levels. The main aim is to create a compact table where multiple regression results can be neatly displayed using the custom “estout” package in Stata.

Continue reading

Automating EUROSTAT in Stata – Part 1: Downloading files

Eurostat is a great database covering various socio-economic, environmental, and regional indicators in Europe. On the other hand, navigating the database can be daunting; similar variables exist across various different datasets, several subsets of meta datasets exist, and some datasets contain derived variables. Given these combinations, it is not unusual to extract and collate information from different dataset and combine them in one database for analysis. Unless you are a database specialist who can automate this using softwares like R, Python, Java, SQL, etc., you will spend a lot of time checking for new versions, downloading files, unzipping them, putting them together, and fixing them before you are anywhere near analysis.

This three part guide gives a step-by-step process to automating the downloading, extracting, and cleaning of Eurostat datasets such that they end up in a user-friendly format that is ready for analysis.

Continue reading