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
item-rest correlation using Spearman?Hi, I'm wondering if there is a way to get item-rest correlation, as you get from the command alpha…
Creating a variable from a percentileDear Statalist Experts I hope you are well. I want to create a new variable "highVarA" that should …
encoding a string variable with a delimiterHello Community, I've been struggling with this one. I have a dataset which is a questionnaire, in …
Propensity Score Matching (PSM) to match firms based on age, size and industryDear community, I have a data set of firms that went public via a SPAC merger (SPAC=1). Now I want …
Interpretation of results of a paired analysisHello Everyone, I am doing a paired kidney analysis to look at the effect of obesity on post-transp…
Subscribe to:
Post Comments (Atom)
0 Response to merge command in a loop
Post a Comment