Hi!
Suppose I have two datafiles: datafileA and datafileB.
Both datafiles have a variable called ID.
In both datafiles ID does not uniquely identify observations:
in datafileA, each occurence of a certain ID represents a case for that specific ID. There can be many cases for a specific ID.
In datafileB, each occurence of a certain ID is accompanied by a year and info about that year for that specific ID. There can be many years for a specific ID.
Now, each time an ID appears in datafileA (a case), I would like to copy this row as many times as that ID has observations (or years) in datafileB, and merge the matching rows.
The results should be so that the datafileA row appears the same for each matched row in datafileB, which have altering content for each year.
Is this a situation for many-to-many merge, or should I do a joinby to achieve this?
I can always separate all duplicates from datafileA to their own datasets and do then a 1:m merge for each of them with datafileB, but I'm asking if a more straightforward solution exists.
Thank you already in advance!
Suppose I have two datafiles: datafileA and datafileB.
Both datafiles have a variable called ID.
In both datafiles ID does not uniquely identify observations:
in datafileA, each occurence of a certain ID represents a case for that specific ID. There can be many cases for a specific ID.
In datafileB, each occurence of a certain ID is accompanied by a year and info about that year for that specific ID. There can be many years for a specific ID.
Now, each time an ID appears in datafileA (a case), I would like to copy this row as many times as that ID has observations (or years) in datafileB, and merge the matching rows.
The results should be so that the datafileA row appears the same for each matched row in datafileB, which have altering content for each year.
Is this a situation for many-to-many merge, or should I do a joinby to achieve this?
I can always separate all duplicates from datafileA to their own datasets and do then a 1:m merge for each of them with datafileB, but I'm asking if a more straightforward solution exists.
Thank you already in advance!

Comment