Hello,
After browsing the forum, Stata help and the internet I still haven't found how to solve my problem, if anyone has an idea of what can be wrong in my code I will be extremely grateful and willing to thank with beers the one that will save my mental health
. So my problem is the following, I have a folder with a number of files with a name pattern as DB_?.xls, I populate a local macro (called dtfl) with these names and then I loop over the files to do different operations on data. The character in "?" is the name of the data set and is also present in the ID of each observation so I need to get that character from the file name. I have tried to extract from the local the character in "?" at each loop with substr and I either get an 198 error (operator invalid) of if I try putting double quotes I get a 101 error, it seems that what works for single strings does not for lists of strings?. Here is the code:
And this is the output I get:
C:\TempStata
db_a.xls
db_a: operator invalid
(I would like to have `dtst'="a")
many many many thanks in advance
Pedro
After browsing the forum, Stata help and the internet I still haven't found how to solve my problem, if anyone has an idea of what can be wrong in my code I will be extremely grateful and willing to thank with beers the one that will save my mental health

Code:
local dtfl : dir . files "DB_?.xls" foreach d in `dtfl' { clear cd "C:/TempStata" di "`d'" local dtst = substr(`d',4,1) di "`dtst'"
C:\TempStata
db_a.xls
db_a: operator invalid
(I would like to have `dtst'="a")
many many many thanks in advance
Pedro
Comment