I am working with an around 30 years' data from an annual survey. Each year-wave is saved into a year2000.dta file in my external harddisk (F:\Morg annuali).
I am now trying to do some cleaning and then save all files into a new one using a foreach code I found on here:
Code:
clear
cd "F:\Morg annuali"
local filelist: dir "." files "*.dta", respectcase
local num=0
local appendlist
/* work on every file and temp-save it */
foreach file of local filelist {
use "`file'"
tempfile file`++num'
display as text in smcl "working on file number {it:`num'}..."
*here I do my cleaning
display as text in smcl "... finished working on file number {it:`num'}"
save `file`num''
}
/* concatenate files */
forvalues filenum=1/`num' {
if `filenum'==1 use `file`filenum''
else local appendlist: list appendlist | file`filenum'
}
append using `appendlist'
invalid 'Malisn'
r(198);
I think this is due to my Windows name,"Ilr Malisn", having a space in between and thus confusing Stata. I tried to solve it by moving annual datasets and dofile into the external harddisk, without luck. It also seems like I cannot change my Windows name without resetting the whole laptop.
I would appreciate any kind of help, thank you!
0 Response to invalid 'Mylastname' while executing foreach
Post a Comment