Hi all,
I'm trying to loop through files in the Quarterly Census of Employment and Wages -- all the files for a year are downloaded into one of my folders (all metro areas in the US). Unfortunately, Stata tells me when I try to loop that there are too many files in the loop!
My code is below -- anyone know what could be going wrong, or alternatives?
local files : dir "$data\qcew\2014" files "*.csv"
foreach file in `files' {
quietly insheet using `file', clear
quietly keep area_fips industry_code agglvl_code year qtr area_title industry_title agglvl_title ///
qtrly_estabs_count month* total_qtrly_wages oty_qtrly_estabs_pct_chg ///
oty_month1_emplvl_pct_chg oty_month2_emplvl_pct_chg oty_month3_emplvl_pct_chg
quietly keep if agglvl_code==74 // keep at naics sector level
quietly bysort area_fips qtr year: egen demp=rowmean(oty_month1_emplvl_pct_chg oty_month2_emplvl_pct_chg oty_month3_emplvl_pct_chg)
quietly save `file'.dta, replace
}
I'm trying to loop through files in the Quarterly Census of Employment and Wages -- all the files for a year are downloaded into one of my folders (all metro areas in the US). Unfortunately, Stata tells me when I try to loop that there are too many files in the loop!
My code is below -- anyone know what could be going wrong, or alternatives?
local files : dir "$data\qcew\2014" files "*.csv"
foreach file in `files' {
quietly insheet using `file', clear
quietly keep area_fips industry_code agglvl_code year qtr area_title industry_title agglvl_title ///
qtrly_estabs_count month* total_qtrly_wages oty_qtrly_estabs_pct_chg ///
oty_month1_emplvl_pct_chg oty_month2_emplvl_pct_chg oty_month3_emplvl_pct_chg
quietly keep if agglvl_code==74 // keep at naics sector level
quietly bysort area_fips qtr year: egen demp=rowmean(oty_month1_emplvl_pct_chg oty_month2_emplvl_pct_chg oty_month3_emplvl_pct_chg)
quietly save `file'.dta, replace
}
Comment