Afternoon,
I am trying to shorten a file name, so that it omits the last 4 characters. I am using Stata 14.
The data files have names such as: 200112dvb.dta, 20013ascasde.dta, 20013gbfer.dta
The code I am using is:
However, the code I am using returns an error r(198). In particular, it says 200112dvb: operator invalid.
Any assistance would be much appreciated.
I am trying to shorten a file name, so that it omits the last 4 characters. I am using Stata 14.
The data files have names such as: 200112dvb.dta, 20013ascasde.dta, 20013gbfer.dta
The code I am using is:
Code:
local years 2001 2002
foreach year of local years{
cd "dir"
local files : dir . files "`year'*.dta"
foreach f of local files {
disp "`f'"
local file = substr("`f'", 1, length(`f')-4)
}
}
Any assistance would be much appreciated.

Comment