I have two datasets: household and individual data. Usually, it is quite straightforward to use 1:m or m:1 merge in this case. However, in my datasets the personal ID contains integer values, while the household ID contains string values with more than one character relative to the personal ID. It seems that I need to harmonize the two IDs before merging, any help would be much appreciated. Thank you.
Household data
Code:
clear input str12 id float(x1 x2) " 1 10" 3 .06849 " 1 20" 3 .34714 " 1 30" 4 .80035 " 1 40" 2 -.7121 " 1 51" 2 -.29017 " 1 52" 1 -1.16279 " 1 60" 3 -.05045 " 1 70" 3 -.18113 " 1 80" 3 .14243 " 1 90" 2 -.63508 " 1100" 2 -.62762 " 1110" 3 .02875 " 1120" 3 .11791 " 2 20" 2 -.75315 " 2 30" 3 .28492 " 2 40" 2 -.67028 " 2 50" 2 -.71762 " 2 60" 1 -1.11277 " 2 70" 1 -.99784 " 2 80" 3 .61741 " 2 90" 1 -.99544 " 2100" 3 .45869 " 2110" 2 -.4203 " 2120" 4 1.00988 " 2130" 4 1.0954 " 3 10" 2 -.5373 " 3 20" 4 .66405 " 3 30" 2 -.36415 " 3 40" 3 .19945 " 3 50" 1 -1.08678 " 3 60" 4 .73621 " 3 70" 4 .74809 " 3 80" 2 -.45847 " 3 90" 3 .63303 " 3100" 2 -.54443 " 3110" 1 -1.3781 " 3120" 3 -.09137 " 4 10" 3 -.20053 " 4 20" 4 .77128 " 4 30" 2 -.90075 " 4 40" 5 1.4545 " 4 50" 3 .5492 " 4 60" 3 .34798 " 4 70" 3 .57425 " 4 88" 4 .72483 " 4 90" 4 1.13641 " 4100" 4 .7428 " 4110" 3 .07936 " 4120" 5 1.4374 " 4130" 4 .70773 " 5 10" 3 .28812 " 5 20" 5 1.2672 " 5 30" 3 .15984 " 5 40" 4 1.06975 " 5 50" 4 1.13389 " 5 60" 3 .20208 " 5 70" 3 .56203 " 5 80" 5 1.38634 " 5 90" 4 .64855 " 5100" 5 1.86468 " 5110" 5 1.53115 " 5120" 4 1.06683 " 6 10" 5 1.33402 " 6 30" 4 .97834 " 6 40" 4 .82034 " 6 50" 4 1.09458 " 6 60" 5 1.48871 " 6 70" 5 1.3944 " 6 80" 5 1.38047 " 6 90" 3 .44144 " 6100" 2 -.26236 " 6110" 2 -.69594 " 6120" 3 -.02173 " 7 10" 5 1.4374 " 7 20" 3 -.17112 " 7 30" 3 .00473 " 7 40" 3 -.20517 " 7 50" 3 .29125 " 7 60" 2 -.57303 " 7 80" 3 -.08485 " 7 90" 3 -.11895 " 7101" 2 -.60675 " 7102" 2 -.47832 " 7110" 2 -.61103 " 7120" 2 -.89282 " 7130" 5 1.46305 " 8 10" 5 1.42465 " 8 20" 4 1.18588 " 8 30" 5 1.55226 " 8 40" 5 1.29114 " 8 50" 4 1.14672 " 8 60" 4 1.0954 " 8 70" 5 1.30324 " 8 80" 5 1.3014 " 8 90" 4 .79918 " 8100" 2 -.39919 " 8110" 3 .26246 " 9 10" 5 1.2672 " 9 20" 5 1.67923 " 9 30" 4 1.12106 end
Code:
clear input float pid 10 10 20 20 30 30 40 40 40 40 40 40 40 40 40 40 40 40 51 51 51 51 52 60 60 60 60 60 60 70 80 80 80 80 80 90 90 90 90 90 90 100 100 100 100 100 110 110 110 110 110 110 110 110 120 120 120 120 120 120 120 120 120 20 20 20 20 20 20 20 20 20 30 30 30 30 30 30 30 40 40 40 40 40 40 40 40 40 50 50 60 60 60 60 60 60 60 60 60 70 end
0 Response to How to merge two datasets (string and integer values in ID)
Post a Comment