I am trying to merge two datasets based on two variables: MotherID and PregnancyID. PregnancyID is nested within MotherID as some mothers have multiple pregnancies.
My first dataset (I shall call master) contains multiple observations for each MotherID (details of different events) and there are no Pregnancy IDs in the dataset. My second dataset (I shall call it using) contains all of the PregnancyIDs and their corresponding MotherIDs.
I tried a simple m:m merge on MotherID but this then just assigns the PregnancyIDs to different random observations within the corresponding MotherID. What I would like instead is to have all of the observations within each MotherID to all be assigned to each of the PregnancyIDs, which would involve expanding the total number of observations in the dataset. I wondered if the data requires a reshape but can't think how to make this work.
Thank you for any advice.
Related Posts with Merging question
Merged dataset but converted date variables inaccurateHi I have two datasets, one is compustat data and the other is covenant violations (from Creditor C…
Inclusion of Instrumental Variables in a fixed effects regression.Hi. I am currently looking into the influence of natural disasters on human capital outcomes, throug…
Multiple Tasks in a MacroI know how to write simpel code of a macro to complete one task: e.g. drop obervations whose var1 va…
Remove axes from twoway with by()Hi, Any ideas on how to remove the x-axis from all panels in a twoway graph with the by-option? I h…
Correlations between two variables repeatedly measuredHi, I have a panel data of 30 subjects with 8 longitudinal observations each. I have measured 10 pl…
Subscribe to:
Post Comments (Atom)
0 Response to Merging question
Post a Comment