*--------------------------------------------------------------------------------------------------------------------------. * EU-Labour Force Survey - Data Service - German Microdata Lab * This routine converts EU-LFS 2008 AD HOC data formatted in CSV into DTA. * Checked for the November 2013 release of the EU-LFS, as provided by Eurostat. * The whole routine consists of three files: * Makro_EULFS_2008_ah.do * Setup_EULFS_2008_ah.do * Labels_EULFS_1983-2012.do * Version 1 of the routine, September 2014 * Stata/MP 13.0 * (c) GESIS - Leibniz Institute for the Social Sciences * German Microdata Lab * Andrea Lengerer, Bianca Dungl * http://www.gesis.org/en/institute/ * Contact: gml@gesis.org * * This Stata code is protected under the creative commons licence. *--------------------------------------------------------------------------------------------------------------------------. * CONFIGURATION. * Line 54: Change CSV_DATA_PATH to the path where the csv files are stored * (e.g. E:/data/EU-LFS/csv/). * Line 58: Change FILENAMES to the expression of files you want to convert from csv to dta * (without file extension, e.g. "*_y.csv" for application on all yearly data sets stored in CSV_DATA_PATH). * Line 63: Change SETUP_PATH to the path where the file "Setup_EULFS_2008_ah.do" is stored * (e.g. E:/data/EU-LFS/setup/Setup_EULFS_2008_ah.do). * Line 64: Change LABEL_SYNTAX_PATH to the path where the file "Labels_EULFS_1983-2012.do" is stored * (e.g. E:/data/EU-LFS/syntax/Labels_EULFS_1983-2012.do). * Line 69: Change DTA_DATA_PATH to the path where you want the dta (Stata format) files to be stored * (e.g. E:/data/EU-LFS/dta/). * Line 86: similar to line 55 *------------------------------------------- Initialization commands ----------------------------------------------------. clear all capture log close set more off // set memory 1G // not necessary in Stata 12 and Stata 13 set dp comma set linesize 250 cd "CSV_DATA_PATH" *--------------------------------------------- Definition and Invocation Macro ------------------------------------. local files : dir . files "*2008_y.csv" foreach f of local files { drop _all import delimited using "`f'", stringcols (11 28 38 110 111 112 114 117 119 124 135 137 144 145) numericcols (72 130 176 177 178) do "SETUP_PATH" do "LABEL_SYNTAX_PATH" local name=substr("`f'",1,7) cd "DTA_DATA_PATH" cap erase `name'ah.dta save `name'ah cd "CSV_DATA_PATH" } *-------------------------------------------------- Combine all Country Files ---------------------------------------. * CONFIGURATION * Line 87: similar to line 67 * with the append command, one can combine the single country files to one file // containing all countries. * e.g. all files of 2008 clear all set more off cd "DTA_DATA_PATH" use at2008_ah.dta foreach x in "be" "bg" "ch" "cy" "cz" "de" "dk" "ee" "es" "fr" "gr" /// "hu" "ie" "it" "lt" "lu" "lv" "nl" "no" "pl" "pt" /// "ro" "se" "si" "sk" "uk" { append using `x'2008_y.dta, force } save 2008_ah, replace