Hello!

I have a dataset that I want to merge with a sequence of files that correspond to individual years. I want to merge only those cases with the second file that have not been merged with the first file, and so on. It is possible that a case appears in every of the files, thus I need an identifier for which merger file is used too.
I tried a "foreach + numlist" loop but I don't know how to (or if even possible to) implement the "merge" command in this.

Alternatively, I tried to start the loop with those cases that have not been merged with a previous file. But I would need to rename "_merge" first to allow a following merge and the merger would only affect cases under the condition that they have not been merged already.

Applied to the case, I have a list of firms with an ID. The ID is used to merge them with a sequence of files that contain their location L. A firm can appear in more than only one file, that's why the ID itself is insufficient. I could generate a variable "year" first to identify the file and use only the latest year a firm is listed.

Hope someone can help.
Andreas Knabe