clear all set more off #delimit; capture log close; /************************************************************************************************************* This do-file reads in the CPS March socioeconomic supplement files from http://www.nber.org/data/current-population-survey-data.html and using http://www.nber.org/data/cps_progs.html. 1. Read in data *************************************************************************************************************/ do paths; /************************************************************************************************************* 1. Read in data *************************************************************************************************************/ forvalues yyyy=2019/2019 {; clear all; local yy = substr(`"`yyyy'"',3,2); di "`yy'"; if `yyyy'<=2012 {; copy http://www.nber.org/cps/cpsmar`yy'.zip cpsmar`yy'.zip, replace; unzipfile cpsmar`yy'.zip, replace; copy http://www.nber.org/data/progs/cps/cpsmar`yy'.do cpsmar`yy'.do, replace; copy http://www.nber.org/data/progs/cps/cpsmar`yy'.dct cpsmar`yy'.dct, replace; }; else {; if `yyyy'==2013 {; copy http://www.nber.org/cps/cpsmar`yyyy'.dat.gz cpsmar`yy'.dat.gz, replace; gunzipfile cpsmar`yy'.dat, replace; }; else if `yyyy'<2019 {; copy http://data.nber.org/cps/cpsmar`yyyy'.zip cpsmar`yy'.zip, replace; gunzipfile cpsmar`yy'.zip, replace; }; else {; copy http://data.nber.org/cps/asecpub`yy'csv.zip asecpub`yy'csv.zip, replace; gunzipfile asecpub`yy'csv.zip, replace; }; copy http://data.nber.org/data/progs/cps/cpsmar`yyyy'.do cpsmar`yy'.do, replace; copy http://data.nber.org/data/progs/cps/cpsmar`yyyy'.dct cpsmar`yy'.dct, replace; }; !type cpsmar`yy'.do | findstr /v "local dat_name" | findstr /v "saveold" | findstr /v "quietly infile" >cpsmar`yy'x.do; *Removes lines with specified strings. The paths in Jean Roth's files are MAC paths, and I am too lazy to change them by hand.; *Name of data file and extension changes. I create a macro with the name of the data file.; local datfile: dir "" files "*`yy'*.dat"; foreach ext in cps pub {; if `"`datfile'"'=="" {; local datfile: dir "" files "*.`ext'"; }; }; qui infile using cpsmar`yy'.dct, using(`datfile') automatic clear; erase `datfile'; do cpsmar`yy'x.do; qui save cpsmar`yy', replace; qui zipfile cpsmar`yy'.dta, saving("$SavePath/CPS/March/cpsmar`yy'", replace); capture log close; foreach ext in .zip .dat.gz .do x.do .dct .dta .log .smcl {; capture erase cpsmar`yy'`ext'; capture erase cpsmar`yyyy'`ext'; }; *Original 2004 supplement excluded noncash income. This adds them back in.; if `yyyy'==2004 {; do cps-March-2004; }; };