zondag 4 januari 2015

Stata user command -eurostat- for downloading Eurostat data

Note: feel free to use the program but you may want to follow up on the developments as I'm merging the job with some work Sébastien Fontenay is doing. Basically, we will add labels and allow datasets with monthly or quarterly data (something Diego José Torres already included in his syntax).

I have written a simple program to bulk download Eurostat data from http://ec.europa.eu/eurostat/data/bulkdownload. The output is a file with the same name as the data set. Flags are erased from the data. Execution could take a while because of the reshape command that is used if you don't specify the wide option (and you shouldn't).

Syntax

eurostat namelist [, long wide keep tab excel save clear]

namelist should include one Eurostat data file to be downloaded, unzipped and processed. You should just specify the name, not the .tsv or .gz extension.

Options

keep  saves the original .tsv file in the active folder
long  creates output in the long format (time in rows) - default
wide  creates output in the wide format (time in columns) - when saving 'wide' is added as a suffix to the filename
tab   saves output in a tab separated text (.txt) file
excel saves output in an Excel (.xlsx) file
save  saves output in a Stata data (.dta) file - default when tab nor excel are entered
clear clears data memory before proceeding

Install

Download the following file: eurostat.ado and put it in your personal ado folder (on Windows this is generally C:\ado\personal\). Put it in the subfolder e\ to keep the folder orderly. Stata will now search this directory for programs and have the command ready when you call it.

If you use Windows you also need to install 7-zip into the program files directory (C:\Program Files\7-Zip\7zG.exe). If you install it elsewhere, the ado needs to be changed - you can do that. Mac users don't need to do anything, a Linux shell should also be straightforward to add but it is not in the ado.

Please, after a few weeks of using the program, send me a mail with your remarks in order to improve the code and help out bugs. My address is in the ado file.