Hi all,
I would like to merge together 16 datasets which are defined by country and are made as follows:
AUS.dta is:
var1
Mol1_a a1
Mol2_a a2
Mol3_a a3
Mol4_a a4
Mol5_a a5
...
Molk_a ak
GER.dta is:
var1
Mol1_g g1
Mol2_g g2
Mol3_g g3
Mol4_g g4
Mol5_g g5
...
Molk_g gk
where Moli_g is different from Moli_a. Both are string variables. And so on for other 14 countries.dta.
Now what I would like to do (possibly in a loop) is to merge together the datasets so that if a value (molecule) is missing in a country the data is maintained only in the country(its) where var1 is not missing and in the others it is put as missing.
For instance say Mol2_a and Mol5_a are present in AUS.dta but not in GER.dta and at the same time Mol1_g in GER.dta is not present in AUS.dta while other values are in common in the sense that Mol3_a coincides with Mol6_g for instance and Mol4_a with Mol5_g (and other with others molecules in GER.dta e.g. Mol6_a with g23 and so on)The resulting db should look like this:
GER AUS
Moll1_g g1 .
Moll1_a g2 .
Moll2_g g2 .
Moll2_a . a2
Moll3_g g3 a7
Moll3_a g6 a3
Moll4_g g2 .
Moll4_a g5 a4
Moll5_g g5 a8
Moll5_a . g5
Moll6_g g6 a3
Moll6_a a2 g23
Then I'll drop the duplicates...
Related Posts with merging datasets with different dimensions
endogeneity test after xtologit and xtoprobitHi all, please I need help with testing for endogeneity after xtologit and xtoprobit. Firstly, how d…
Find number of children, age at birth for women using identifiersHi: I am working with a dataset that looks something like this: HHID PID MID Rel_Head Age 10 1 3 1…
How to find duplicate across variablesHello, I am relatively new to stata, but I have encountered a problem of not being able to find dup…
data annualizationDear all, May I have your guidance please on the following: I have 5 subjects with 5 observations ov…
rate of admission in NRDhello all i'm working on NRD I am looking to compare rate of hospitalizations before and after certa…
Subscribe to:
Post Comments (Atom)
0 Response to merging datasets with different dimensions
Post a Comment