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
Related Posts with merge command in a loop
Convert SIF date to yearHi all, Below is a few observations of my large panel data set I got after linking several data tog…
Saving a file takes foreverHi, I have a problem with saving an appended file. I have couple of files to be appended, but it tak…
How to draw a twoway picture like theseHow to draw a twoway picture like these, these two pictures,thanks Code: * Example generated by -d…
Measuring Knowledge Level based on survey answersHi! I asked my respondents a few questions with 04 options each For example, "Which one is the lar…
Desscriptive Statistics and MatricesI have the code below. I want to export the result from the code below to excel and also want to add…
Subscribe to:
Post Comments (Atom)
0 Response to merge command in a loop
Post a Comment