Get online data directly through Stata

Basic steps (1) fixed adress to data, (2) use the .copy command in Stata, (3) and if needed use .shell to unzip data. Here is an old post from Asjad Naqvi on how to download from Eurostat (bulk info page here with fix web adresses), that got me started. You may also use .xteurostat.

Bulk downloads are also available from AMECO, info & fixed links here. Here’s some commands for Stata to download, unzip, import & generate a graph of unemployment data from AMECO.

cd "yourdirectory"
copy "http://ec.europa.eu/economy_finance/db_indicators/ameco/documents/ameco1.zip" "ameco1.zip", replace
*** Call compression software, e=unzip, -y=replace
shell "C:\Program\7-Zip\7zG.exe" e -y ameco1.zip
*** Import the data that we downloaded
import delimited AMECO1.TXT, delimiter(";") varname(1) clear
* Choose variable
keep if title=="Unemployment rate: total :- Member States: definition EUROSTAT "
* Fix names, make numeric & drop some variables
rename v* unempl#, renumber(1960)
destring unempl*, replace force
drop code subc title unit *2016 *2017 *2018
* From wide to long data
reshape long unempl, i(country) j(yr)
* Encode string for the use of .xtline
encode country, gen(cty)
* The graph
xtline unempl if ///
inlist(country,"Sweden","Norway","Finland","Denmark"), ///
t(yr) i(cty) overlay leg(pos(3) cols(1)) xtitle("") ///
ylabel(,angle(0)) title("Unemployment rate total, def: Eurostat")

 

unempl

More instructions here & here.

Advertisements

One thought on “Get online data directly through Stata

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s