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
Generating four new variables out of one variable in a panel datasetHello, I'm trying to create four new variables in the following dataset: Code: input long pidp fl…
Generate a new variable as the mean of individuals over timeI have the following data set, a panel dataset, (it is an example of what I have, the data set is mu…
Marginal Effect of an Interaction Term after Logit (i.dummy#c.continous)Dear All, Here is my data. I am running a logit model and tried to get marginal effects. Here is m…
Scatter plot troubles! Hi! I'm trying to analyse some statistics and was having trouble figuring out why my scatter plots …
Stata 17 - bayesmh not replicating a simple example already done in Stata 15Dear Forum Members, I'm trying to replicate in Stata 17 this (quite simple) example from Stata Yout…
Subscribe to:
Post Comments (Atom)
0 Response to Merging question
Post a Comment