I want to merge two datasets based on one variable (neither dataset contains duplicates on this variable and there are no other identical variables in both sets) and I would expect _merge==3 to be 4,845 (I exported my data to excel and checked it there), both datasets are original datasets so the input data must be identical with each run;
the code is very simple and looks like the following:
use "$path\facility", clear
sort id
drop if id == id[_n-1]
save "$path\facility", replace
use "$path\facilitysponsor", clear
sort id
drop if id == id[_n-1]
merge 1:1 id using "$path\facility"
keep if _merge ==3
However, each time I run the do-file I get slightly different values but never the correct number of merged data. Anyone has an idea where is my mistake?
Thank you in advance!
Related Posts with Please help: Merge 1:1 delivers different results after each runthrough
Changing Type of Local VariablesI have an imported dataset where I need to rename all of the variables and want to use the imported …
error for clogit with vce cluster optionI want to run fixed effects logit model and tell stata that the observations within each firm is not…
How to put all graphs in a same pdf file?Hello. I would like to know if it is possible to make Stata combine all pdf generated by the loop b…
margins plot for*interaction of two continuous variablesHi, I am trying to create a margins plot to illustrate the interaction term between savings rate (% …
Unit root test on panel dataHi! I have a panel data with 155 countries and 43 years. I tried the command Code: xtunitroot ht…
Subscribe to:
Post Comments (Atom)
0 Response to Please help: Merge 1:1 delivers different results after each runthrough
Post a Comment