-2

I am aware that there already exist related threads like how do I loop through file names in stata

I follow those instructions but however receive the invalid syntax r(198) error in Stata.

My code looks as follows:

foreach var of "*/ABC.dta" ABC{
infix observation 1-2 date 3 using "*/CC_ABC`var'.txt" 
save "*/CC_ABC`var'.dta" ,replace
}

Where ABC.dta is a list of pretty random numbers which all occur in file names. Do you have an idea why I get errors here? Thanks a lot!

Community
  • 1
  • 1
Felix H
  • 21
  • 1
  • 8

1 Answers1

0

Is this real code?

Stata wouldn't get past the lack of a listtype following of. This is the very first thing explained in the help for foreach.

If this isn't real code, please show us a real example of something that doesn't work, ideally one that we can reproduce.

(If you don't understand something, imposing your own abstraction or generalization is just likely to muddy your question for those who do.)

Nick Cox
  • 35,529
  • 6
  • 31
  • 47