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
sfpanelI have a quick query regarding the stochastic frontier models. I am running a stochastic frontier mo…
Random implementation test/ falsification check for Diff-in-Diff with staggered adoptionDear all, I employ difference-in-differences estimation to analyze the effect of a legislative poli…
a Regression with missing ValuesHallo Statalist, i am trying to find out the effect of the macro variables on the credit Rating in …
Whether we need to show all coefficients of all variables after testing DiD?I am curious about whether it is a need to show all coefficients of all variables after testing DiD.…
Can we construct the survival curve after stteffects commands?Hello, I'm working on the survival analysis, using stteffects command (both LAC-IPWRA and WAC-IPWRA…
Subscribe to:
Post Comments (Atom)
0 Response to Merging question
Post a Comment