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
PPML estimation with bilateral trade agreement dummies.Hello everyone! I am applying PPML estimation to analyze the impact of two trade agreements (both b…
Spatial shocks: when is collinearity too much?Hi, I am working with a municipality-level dataset. I am analysing the effect of immigration shocks…
Confusion about the example in STATA help file of didregressToday I read the detail description of didregress from STATA. from page 6 and 7, there is a point th…
Seeking help with unbalanced panel data analysisHi, I have recently analyzed an unbalanced panel data, but since it is my first time to work with su…
The problem with count if syntax regarding encoded string variablesFrom the dataset hospdd given by STATA (https://www.stata-press.com/data/r17/hospdd.dta), I want to …
Subscribe to:
Post Comments (Atom)
0 Response to Merging question
Post a Comment