I'm trying to run a loop in which I append some .dta files in multiple folders. The path looks like this 'drive>folder_for_year>data_folder>samplefile_quat er.dta'. I'm using a loop with 'forvalues' for this and the loop gets stuck because in some years some quarterly files are missing. What I want is for stata to ignore the missing file, and keep going.

my code-
clear all
global root "/Users/deshamithrajayasekera/Box/CES_80_2015"

forvalues i = 84(1)99 {
forvalues j = 1(1)4{
use "$root/raw/intrvw`i'/fmli`i'`j'.dta", clear
append using "$root/raw/temp.dta", force
replace temp = "`i'.`j'"
save "$root/raw/temp.dta", replace
}
}

Error: file /Users/deshamithrajayasekera/Box/CES_80_2015/raw/intrvw94/fmli941.dta not found
(datafile for the quarter 1 data in 1994 is not available)
  • temp.dta is a master-file of sorts to which I append my data
  • I'm working on Stata 15.1 on a mac
Thank you!