I would like to import and then append a multitude of tsv files which are located within different subfolders of my main folder. I am trying to replicate the example at the end of filelist's help file, with a minor twist (instead of importing a csv I am importing a tsv and I want 3 columns to be read as strings).
Unfortunately, I get the following error:
in range not allowed
r(101);
Here is my code
Unfortunately, I get the following error:
in range not allowed
r(101);
Here is my code
Code:
filelist, dir("/Users/emarchesi/Desktop/TEST") pat("*.tsv") save("tsv_datasets.dta")
use "tsv_datasets.dta", clear
local obs = _N
forvalues i=1/`obs' {
import delimited "tsv_datasets.dta" in `i', stringcols(1 2 3) clear
local f = dirname + "/" + filename
insheet using "`f'", clear
gen source = "`f'"
tempfile save`i'
save "`save`i''"
}
use "`save1'", clear
forvalues i=2/`obs' {
append using "`save`i''"
}

Comment