clear all set more off #delimit; set mem 500m; /************************************************************************************************************* This do-file reads in European bond yields. The data are downloaded from the bulk download facility: http://epp.eurostat.ec.europa.eu/NavTree_prod/everybody/BulkDownloadListing 1. Read in data 2. Merge with documentation files 3. Save Note: the file takes a (very!) long time to execute the reshape command, but it will run *************************************************************************************************************/ do paths; tempfile data; set maxvar 12000; /************************************************************************************************************* 1. Read in data *************************************************************************************************************/ local rawdata irt_lt_mcby_d.tsv; copy "http://epp.eurostat.ec.europa.eu/NavTree_prod/everybody/BulkDownloadListing?sort=1&file=data%2F`rawdata'.gz" `rawdata'.gz, replace; gunzip `"`c(pwd)'"' "`rawdata'"; qui insheet using `rawdata', tab clear double; qui erase `rawdata'; qui erase `rawdata'.gz; qui egen data_code = ends(v1), punct(",") head; qui egen region_code = ends(v1), punct(",") tail; qui drop v1; foreach v of varlist v* {; local vname = `v'[1]; rename `v' DGS10`vname'; }; qui drop if _n==1; qui reshape long DGS10, i(region_code) j(daten) string; qui destring DGS10, force replace ignore("i"); qui gen date = date(daten, "Y#M#D"); qui sort date; format date %td; qui save `data', replace; /************************************************************************************************************* 2. Documentation files *************************************************************************************************************/ preserve; qui insheet using "http://epp.eurostat.ec.europa.eu/NavTree_prod/everybody/BulkDownloadListing?sort=1&file=dic%2Fen%2Fgeo.dic", tab clear; local N = _N; forvalues i = 1/`N' {; local v`i' = v1[`i']; *Local name is region abbreviation; local `v`i'' = v2[`i']; *Local value is region full name; }; qui levelsof v1, local(regions); restore; /************************************************************************************************************* 3. Format and save *************************************************************************************************************/ qui reshape wide DGS10, i(date) j(region_code) string; foreach r of local regions {; capture label variable DGS10`r' "``r''"; }; qui tsset date; local filename "European bond yields"; qui save "`filename'", replace; qui zipfile "`filename'.dta", saving("$SavePath/`filename'", replace); qui erase "`filename'.dta";