Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • merge issue two datasets

    Hi I am trying two merge two data sets

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input int FID str14 DHSID int DHSCLUST double(LATNUM LONGNUM)
    516 "PK201700000535" 535             0             0
    252 "PK201700000260" 260 24.2353094804 68.5785464326
    250 "PK201700000258" 258 24.2918283101  67.684409173
    248 "PK201700000256" 256  24.305098976 67.6244884689
    251 "PK201700000259" 259 24.3335435648  68.258713284
    253 "PK201700000261" 261 24.4073019722  68.000197657
    245 "PK201700000253" 253 24.5832592356 68.8469497923
    247 "PK201700000255" 255 24.6649369257 68.8295667058
    259 "PK201700000267" 267 24.6932509323 69.2486483987
    249 "PK201700000257" 257 24.7332721226 67.9463795241
    277 "PK201700000285" 285  24.820967992  67.022795801
    302 "PK201700000310" 310 24.8280930828  67.131955182
    276 "PK201700000284" 284  24.832391717 66.9996657976
    278 "PK201700000286" 286 24.8333868963 67.0162641549
    299 "PK201700000307" 307 24.8338171421 67.1614849381
    279 "PK201700000287" 287 24.8372526723 67.0120498426
    301 "PK201700000309" 309 24.8377979609 67.1262957028
    300 "PK201700000308" 308 24.8475197283 67.1943983798
    273 "PK201700000281" 281 24.8684384484 67.3885018436
    284 "PK201700000292" 292 24.8685218221 67.0590520381
    275 "PK201700000283" 283 24.8687041674 67.0031526542
    274 "PK201700000282" 282 24.8691044687 66.9856856476
    283 "PK201700000291" 291 24.8705072701 67.0488080765
    280 "PK201700000288" 288 24.8709650692 67.0645973025
    285 "PK201700000293" 293 24.8749655149  67.053955037
    298 "PK201700000306" 306 24.8804495519 67.1591266472
    261 "PK201700000269" 269 24.8928315931 66.8403056654
    272 "PK201700000280" 280 24.8931076552 67.1998572538
    303 "PK201700000311" 311 24.8937231349 67.1997115708
    296 "PK201700000304" 304 24.9058438821 67.0385688373
    295 "PK201700000303" 303 24.9061724943 67.0389459493
    297 "PK201700000305" 305 24.9068704105 67.0223997061
    294 "PK201700000302" 302 24.9074180309 67.0390644406
    286 "PK201700000294" 294 24.9114292219 67.1039421779
    265 "PK201700000273" 273 24.9137790057 66.8407557478
    287 "PK201700000295" 295 24.9177606208 67.1174645107
    281 "PK201700000289" 289 24.9243820347 67.1086379693
    282 "PK201700000290" 290   24.92635132 67.1073846473
    288 "PK201700000296" 296 24.9297043729 67.0466899732
    293 "PK201700000301" 301 24.9304524359 67.0728001773
    263 "PK201700000271" 271 24.9392334599 66.9560159598
    262 "PK201700000270" 270 24.9422161159 66.9573663526
    289 "PK201700000297" 297 24.9427464765 67.0480469294
    268 "PK201700000276" 276  24.944798731 66.9846280118
    264 "PK201700000272" 272 24.9523368527 66.9716874551
    267 "PK201700000275" 275 24.9630888614 66.9897894879
    266 "PK201700000274" 274 24.9744433658 66.9972557349
    291 "PK201700000299" 299 24.9802559712 67.0584921551
    243 "PK201700000251" 251 24.9884575302 68.3910202348
    290 "PK201700000298" 298 24.9957268465 67.0762327704
    292 "PK201700000300" 300 24.9973908447 67.0658061703
    260 "PK201700000268" 268 25.0142394862 67.1287936422
    246 "PK201700000254" 254 25.1007907436 68.8729510799
    269 "PK201700000277" 277  25.103460359  67.163542706
    373 "PK201700000382" 382 25.1464766283  61.807371533
    257 "PK201700000265" 265 25.1601821804 69.5717512699
    270 "PK201700000278" 278 25.1964355724 67.2408208135
    271 "PK201700000279" 279 25.2011459236 67.2462919634
    255 "PK201700000263" 263 25.2063966035 69.1974075701
    258 "PK201700000266" 266 25.2276740391 70.3303530507
    241 "PK201700000249" 249 25.2900398872 68.8630066865
    372 "PK201700000381" 381  25.342327577 62.3127845692
    240 "PK201700000248" 248 25.3591605453 68.3509878974
    239 "PK201700000247" 247  25.361865043 68.4865094278
    371 "PK201700000380" 380   25.36213418 63.1328595847
    366 "PK201700000375" 375 25.3866811774 66.8808832803
    238 "PK201700000246" 246 25.4033636383  68.391379695
    242 "PK201700000250" 250 25.4666207702 68.7356803651
    237 "PK201700000245" 245   25.51534035 68.1528148241
    256 "PK201700000264" 264 25.5275847624 69.2747658338
    311 "PK201700000319" 319 25.7361099627 69.2477597943
    254 "PK201700000262" 262 25.7570782456 69.1270975608
    367 "PK201700000376" 376 25.8186171212 62.3361963706
    244 "PK201700000252" 252 25.8316645629 68.3802160604
    312 "PK201700000320" 320  25.841230693 69.3638627073
    368 "PK201700000377" 377 25.8525933324 63.4490060666
    365 "PK201700000374" 374 25.8546478218  66.712630768
    369 "PK201700000378" 378 25.8786451648 63.4417604402
    363 "PK201700000372" 372 25.8884648847 66.3491767486
    357 "PK201700000366" 366 26.0771433627 65.7230697094
    310 "PK201700000318" 318 26.1235189362 69.0361575883
    358 "PK201700000367" 367  26.149122155 64.9109838567
    354 "PK201700000363" 363 26.2144728689 66.9860425503
    370 "PK201700000379" 379 26.2212349082 62.4062349473
    364 "PK201700000373" 373 26.2302899432 66.3116563263
    236 "PK201700000244" 244 26.2446563443 67.6988767225
    308 "PK201700000316" 316 26.2631595907 68.0993103044
    307 "PK201700000315" 315 26.3493904359 68.5600899484
    309 "PK201700000317" 317 26.4620436064 68.3021392129
    228 "PK201700000236" 236   26.71329895 68.4061479874
    304 "PK201700000312" 312 26.8525541432 68.2114476949
    351 "PK201700000360" 360 26.8915644326 66.8562757264
    234 "PK201700000242" 242 26.9114607479 67.6509776426
    233 "PK201700000241" 241 26.9861254198 67.9612468737
    305 "PK201700000313" 313 27.0383927387 68.3160958696
    306 "PK201700000314" 314 27.0739046366  68.122836228
    235 "PK201700000243" 243   27.20867273 67.9232044018
    232 "PK201700000240" 240 27.3433773347 68.5242157312
    230 "PK201700000238" 238 27.3779221776 68.5882306767
    215 "PK201700000223" 223 27.4353087006 68.1464009874
    end

    second datasets

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str10 date double(lon lat t925 t1000) str8 time int year byte(month day) double(x y) float(mdate ti ti_dum)
    "2001-01-01"           0           0 290.4979 293.9153 "19:00:00" 2001 1 1       0       0 492 -3.4174 0
    "2001-01-01" 68.57854643 24.23530948 287.6612 291.8771 "19:00:00" 2001 1 1 68.5785 24.2353 492 -4.2159 0
    "2001-01-01" 67.68440917 24.29182831 287.8727 292.7105 "19:00:00" 2001 1 1 67.6844 24.2918 492 -4.8378 0
    "2001-01-01" 67.62448847 24.30509898 287.8727 292.7105 "19:00:00" 2001 1 1 67.6245 24.3051 492 -4.8378 0
    "2001-01-01" 68.25871328 24.33354356 288.0058 292.1618 "19:00:00" 2001 1 1 68.2587 24.3335 492  -4.156 0
    "2001-01-01" 68.00019766 24.40730197 288.1553 292.1576 "19:00:00" 2001 1 1 68.0002 24.4073 492 -4.0023 0
    "2001-01-01" 68.84694979 24.58325924 287.2847 291.7254 "19:00:00" 2001 1 1 68.8469 24.5833 492 -4.4407 0
    "2001-01-01" 68.82956671 24.66493693 287.2847 291.7254 "19:00:00" 2001 1 1 68.8296 24.6649 492 -4.4407 0
    "2001-01-01"  69.2486484 24.69325093 286.5049 291.3541 "19:00:00" 2001 1 1 69.2486 24.6933 492 -4.8492 0
    "2001-01-01" 67.94637952 24.73327212 287.8077 291.8286 "19:00:00" 2001 1 1 67.9464 24.7333 492 -4.0209 0
    "2001-01-01"  67.0227958 24.82096799 288.1729 292.7838 "19:00:00" 2001 1 1 67.0228  24.821 492 -4.6109 0
    "2001-01-01" 67.13195518 24.82809308 288.1729 292.7838 "19:00:00" 2001 1 1  67.132 24.8281 492 -4.6109 0
    "2001-01-01"  66.9996658 24.83239172 288.1729 292.7838 "19:00:00" 2001 1 1 66.9997 24.8324 492 -4.6109 0
    "2001-01-01" 67.01626415  24.8333869 288.1729 292.7838 "19:00:00" 2001 1 1 67.0163 24.8334 492 -4.6109 0
    "2001-01-01" 67.16148494 24.83381714 288.1729 292.7838 "19:00:00" 2001 1 1 67.1615 24.8338 492 -4.6109 0
    "2001-01-01" 67.01204984 24.83725267 288.1729 292.7838 "19:00:00" 2001 1 1  67.012 24.8373 492 -4.6109 0
    "2001-01-01"  67.1262957 24.83779796 288.1729 292.7838 "19:00:00" 2001 1 1 67.1263 24.8378 492 -4.6109 0
    "2001-01-01" 67.19439838 24.84751973 288.1729 292.7838 "19:00:00" 2001 1 1 67.1944 24.8475 492 -4.6109 0
    "2001-01-01" 67.38850184 24.86843845 287.9036 292.2814 "19:00:00" 2001 1 1 67.3885 24.8684 492 -4.3778 0
    "2001-01-01" 67.05905204 24.86852182 288.1729 292.7838 "19:00:00" 2001 1 1 67.0591 24.8685 492 -4.6109 0
    "2001-01-01" 67.00315265 24.86870417 288.1729 292.7838 "19:00:00" 2001 1 1 67.0032 24.8687 492 -4.6109 0
    "2001-01-01" 66.98568565 24.86910447 288.1729 292.7838 "19:00:00" 2001 1 1 66.9857 24.8691 492 -4.6109 0
    "2001-01-01" 67.04880808 24.87050727 288.1729 292.7838 "19:00:00" 2001 1 1 67.0488 24.8705 492 -4.6109 0
    "2001-01-01"  67.0645973 24.87096507 288.1729 292.7838 "19:00:00" 2001 1 1 67.0646  24.871 492 -4.6109 0
    "2001-01-01" 67.05395504 24.87496551 288.1729 292.7838 "19:00:00" 2001 1 1  67.054  24.875 492 -4.6109 0
    "2001-01-01" 67.15912665 24.88044955 288.1729 292.7838 "19:00:00" 2001 1 1 67.1591 24.8804 492 -4.6109 0
    "2001-01-01" 66.84030567 24.89283159 288.5164   293.12 "19:00:00" 2001 1 1 66.8403 24.8928 492 -4.6036 0
    "2001-01-01" 67.19985725 24.89310766 288.1729 292.7838 "19:00:00" 2001 1 1 67.1999 24.8931 492 -4.6109 0
    "2001-01-01" 67.19971157 24.89372313 288.1729 292.7838 "19:00:00" 2001 1 1 67.1997 24.8937 492 -4.6109 0
    "2001-01-01" 67.03856884 24.90584388 288.1729 292.7838 "19:00:00" 2001 1 1 67.0386 24.9058 492 -4.6109 0
    "2001-01-01" 67.03894595 24.90617249 288.1729 292.7838 "19:00:00" 2001 1 1 67.0389 24.9062 492 -4.6109 0
    "2001-01-01" 67.02239971 24.90687041 288.1729 292.7838 "19:00:00" 2001 1 1 67.0224 24.9069 492 -4.6109 0
    "2001-01-01" 67.03906444 24.90741803 288.1729 292.7838 "19:00:00" 2001 1 1 67.0391 24.9074 492 -4.6109 0
    "2001-01-01" 67.10394218 24.91142922 288.1729 292.7838 "19:00:00" 2001 1 1 67.1039 24.9114 492 -4.6109 0
    "2001-01-01" 66.84075575 24.91377901 288.5164   293.12 "19:00:00" 2001 1 1 66.8408 24.9138 492 -4.6036 0
    "2001-01-01" 67.11746451 24.91776062 288.1729 292.7838 "19:00:00" 2001 1 1 67.1175 24.9178 492 -4.6109 0
    "2001-01-01" 67.10863797 24.92438203 288.1729 292.7838 "19:00:00" 2001 1 1 67.1086 24.9244 492 -4.6109 0
    "2001-01-01" 67.10738465 24.92635132 288.1729 292.7838 "19:00:00" 2001 1 1 67.1074 24.9264 492 -4.6109 0
    "2001-01-01" 67.04668997 24.92970437 288.1729 292.7838 "19:00:00" 2001 1 1 67.0467 24.9297 492 -4.6109 0
    "2001-01-01" 67.07280018 24.93045244 288.1729 292.7838 "19:00:00" 2001 1 1 67.0728 24.9305 492 -4.6109 0
    "2001-01-01" 66.95601596 24.93923346 288.1729 292.7838 "19:00:00" 2001 1 1  66.956 24.9392 492 -4.6109 0
    "2001-01-01" 66.95736635 24.94221612 288.1729 292.7838 "19:00:00" 2001 1 1 66.9574 24.9422 492 -4.6109 0
    "2001-01-01" 67.04804693 24.94274648 288.1729 292.7838 "19:00:00" 2001 1 1  67.048 24.9427 492 -4.6109 0
    "2001-01-01" 66.98462801 24.94479873 288.1729 292.7838 "19:00:00" 2001 1 1 66.9846 24.9448 492 -4.6109 0
    "2001-01-01" 66.97168746 24.95233685 288.1729 292.7838 "19:00:00" 2001 1 1 66.9717 24.9523 492 -4.6109 0
    "2001-01-01" 66.98978949 24.96308886 288.3328 292.2866 "19:00:00" 2001 1 1 66.9898 24.9631 492 -3.9538 0
    "2001-01-01" 66.99725573 24.97444337 288.3328 292.2866 "19:00:00" 2001 1 1 66.9973 24.9744 492 -3.9538 0
    "2001-01-01" 67.05849216 24.98025597 288.3328 292.2866 "19:00:00" 2001 1 1 67.0585 24.9803 492 -3.9538 0
    "2001-01-01" 68.39102023 24.98845753 288.0439 291.9658 "19:00:00" 2001 1 1  68.391 24.9885 492 -3.9219 0
    "2001-01-01" 67.07623277 24.99572685 288.3328 292.2866 "19:00:00" 2001 1 1 67.0762 24.9957 492 -3.9538 0
    "2001-01-01" 67.06580617 24.99739084 288.3328 292.2866 "19:00:00" 2001 1 1 67.0658 24.9974 492 -3.9538 0
    "2001-01-01" 67.12879364 25.01423949 288.3328 292.2866 "19:00:00" 2001 1 1 67.1288 25.0142 492 -3.9538 0
    "2001-01-01" 68.87295108 25.10079074 287.1579 291.5728 "19:00:00" 2001 1 1  68.873 25.1008 492 -4.4149 0
    "2001-01-01" 67.16354271 25.10346036 288.3328 292.2866 "19:00:00" 2001 1 1 67.1635 25.1035 492 -3.9538 0
    "2001-01-01" 61.80737153 25.14647663 290.2565 293.1479 "19:00:00" 2001 1 1 61.8074 25.1465 492 -2.8914 0
    "2001-01-01" 69.57175127 25.16018218 285.7313 291.3561 "19:00:00" 2001 1 1 69.5718 25.1602 492 -5.6248 0
    "2001-01-01" 67.24082081 25.19643557 287.9614 292.2598 "19:00:00" 2001 1 1 67.2408 25.1964 492 -4.2984 0
    "2001-01-01" 67.24629196 25.20114592 287.9614 292.2598 "19:00:00" 2001 1 1 67.2463 25.2011 492 -4.2984 0
    "2001-01-01" 69.19740757  25.2063966 286.6534 291.5924 "19:00:00" 2001 1 1 69.1974 25.2064 492  -4.939 0
    "2001-01-01" 70.33035305 25.22767404 285.5033 288.0099 "19:00:00" 2001 1 1 70.3304 25.2277 492 -2.5066 0
    "2001-01-01" 68.86300669 25.29003989 287.2383  291.711 "19:00:00" 2001 1 1  68.863   25.29 492 -4.4727 0
    "2001-01-01" 62.31278457 25.34232758 290.1111 292.2216 "19:00:00" 2001 1 1 62.3128 25.3423 492 -2.1105 0
    "2001-01-01"  68.3509879 25.35916055 288.0945 291.3675 "19:00:00" 2001 1 1  68.351 25.3592 492  -3.273 0
    "2001-01-01" 68.48650943 25.36186504 287.8036 291.9183 "19:00:00" 2001 1 1 68.4865 25.3619 492 -4.1147 0
    "2001-01-01" 63.13285958 25.36213418 290.0492 292.9426 "19:00:00" 2001 1 1 63.1329 25.3621 492 -2.8934 0
    "2001-01-01" 66.88088328 25.38668118 288.6649 292.2113 "19:00:00" 2001 1 1 66.8809 25.3867 492 -3.5464 0
    "2001-01-01"  68.3913797 25.40336364 288.0945 291.3675 "19:00:00" 2001 1 1 68.3914 25.4034 492  -3.273 0
    "2001-01-01" 68.73568037 25.46662077 287.3415 291.7832 "19:00:00" 2001 1 1 68.7357 25.4666 492 -4.4417 0
    "2001-01-01" 68.15281482 25.51534035 288.0904 290.6083 "19:00:00" 2001 1 1 68.1528 25.5153 492 -2.5179 0
    "2001-01-01" 69.27476583 25.52758476 286.1016 291.7956 "19:00:00" 2001 1 1 69.2748 25.5276 492  -5.694 0
    "2001-01-01" 69.24775979 25.73610996 286.1336 291.7966 "19:00:00" 2001 1 1 69.2478 25.7361 492  -5.663 0
    "2001-01-01" 69.12709756 25.75707825 286.8082 291.6481 "19:00:00" 2001 1 1 69.1271 25.7571 492 -4.8399 0
    "2001-01-01" 62.33619637 25.81861712 289.6469 292.1649 "19:00:00" 2001 1 1 62.3362 25.8186 492  -2.518 0
    "2001-01-01" 68.38021606 25.83166456 288.3761  291.188 "19:00:00" 2001 1 1 68.3802 25.8317 492 -2.8119 0
    "2001-01-01" 69.36386271 25.84123069 286.1336 291.7966 "19:00:00" 2001 1 1 69.3639 25.8412 492  -5.663 0
    "2001-01-01" 63.44900607 25.85259333  289.485 293.4739 "19:00:00" 2001 1 1  63.449 25.8526 492 -3.9889 0
    "2001-01-01" 66.71263077 25.85464782 288.3307 291.9359 "19:00:00" 2001 1 1 66.7126 25.8546 492 -3.6052 0
    "2001-01-01" 63.44176044 25.87864516  289.485 293.4739 "19:00:00" 2001 1 1 63.4418 25.8786 492 -3.9889 0
    "2001-01-01" 66.34917675 25.88846488 288.8124 291.8152 "19:00:00" 2001 1 1 66.3492 25.8885 492 -3.0028 0
    "2001-01-01" 65.72306971 26.07714336 288.4565 292.5352 "19:00:00" 2001 1 1 65.7231 26.0771 492 -4.0787 0
    "2001-01-01" 69.03615759 26.12351894 286.8556 291.7976 "19:00:00" 2001 1 1 69.0362 26.1235 492  -4.942 0
    "2001-01-01" 64.91098386 26.14912216 288.4823 292.3588 "19:00:00" 2001 1 1  64.911 26.1491 492 -3.8765 0
    "2001-01-01" 66.98604255 26.21447287 288.3998 292.8869 "19:00:00" 2001 1 1  66.986 26.2145 492 -4.4871 0
    "2001-01-01" 62.40623495 26.22123491 289.0208 293.0406 "19:00:00" 2001 1 1 62.4062 26.2212 492 -4.0198 0
    "2001-01-01" 66.31165633 26.23028994 288.2317 291.9709 "19:00:00" 2001 1 1 66.3117 26.2303 492 -3.7392 0
    "2001-01-01" 67.69887672 26.24465634 288.9104  292.332 "19:00:00" 2001 1 1 67.6989 26.2447 492 -3.4216 0
    "2001-01-01"  68.0993103 26.26315959 288.8186 291.2427 "19:00:00" 2001 1 1 68.0993 26.2632 492 -2.4241 0
    "2001-01-01" 68.56008995 26.34939044 288.2822 291.7811 "19:00:00" 2001 1 1 68.5601 26.3494 492 -3.4989 0
    "2001-01-01" 68.30213921 26.46204361 288.6969 291.3572 "19:00:00" 2001 1 1 68.3021  26.462 492 -2.6603 0
    "2001-01-01" 68.40614799 26.71329895 288.6278 290.8796 "19:00:00" 2001 1 1 68.4061 26.7133 492 -2.2518 0
    "2001-01-01" 68.21144769 26.85255414 288.6278 290.8796 "19:00:00" 2001 1 1 68.2114 26.8526 492 -2.2518 0
    "2001-01-01" 66.85627573 26.89156443 288.2894 292.9478 "19:00:00" 2001 1 1 66.8563 26.8916 492 -4.6584 0
    "2001-01-01" 67.65097764 26.91146075 288.8186 290.1059 "19:00:00" 2001 1 1  67.651 26.9115 492 -1.2873 0
    "2001-01-01" 67.96124687 26.98612542 288.6577 289.6593 "19:00:00" 2001 1 1 67.9612 26.9861 492 -1.0016 0
    "2001-01-01" 68.31609587 27.03839274 288.4617 290.6434 "19:00:00" 2001 1 1 68.3161 27.0384 492 -2.1817 0
    "2001-01-01" 68.12283623 27.07390464 288.6577 289.6593 "19:00:00" 2001 1 1 68.1228 27.0739 492 -1.0016 0
    "2001-01-01"  67.9232044 27.20867273  288.274 289.9791 "19:00:00" 2001 1 1 67.9232 27.2087 492 -1.7051 0
    "2001-01-01" 68.52421573 27.34337733 287.8222  291.352 "19:00:00" 2001 1 1 68.5242 27.3434 492 -3.5298 0
    "2001-01-01" 68.58823068 27.37792218 287.8222  291.352 "19:00:00" 2001 1 1 68.5882 27.3779 492 -3.5298 0
    "2001-01-01" 68.14640099  27.4353087 288.3616 289.3179 "19:00:00" 2001 1 1 68.1464 27.4353 492  -.9563 0
    end
    format %tm mdate



    both the data sets have lat and lon but with different decimals points. how I can merge two datasets using lat and lon

    thanks

  • #2
    Hi Muhammad Ramzan,

    It is a common thing to work with many decimal places in coordinate variables, but 8 decimal places correspond to 1.11 mm precision (source), which is in almost all cases just too much. DHS clusters are way bigger. You can round the coordinates to 4 decimal places (11.1 m precision) in both the datasets and still get an accurate merge for the clusters. This addendum code below works with 5 decimal places:

    For the first dataset:
    Code:
    gen LAT = round(LATNUM,0.00001)
    gen LON = round(LONGNUM,0.00001)
    save "first.dta", replace
    For the second dataset and merge:
    Code:
    gen LAT = round(lat,0.00001)
    gen LON = round(lon,0.00001)
    
    merge 1:1 LAT LON using "first.dta"
    Last edited by Ashish Tyagi; 03 May 2023, 10:26. Reason: Added code snippet.

    Comment


    • #3
      thanks meanwhile I tried this but

      use out_2001-2011.dta, clear
      recast float lat lon, force
      sort lat lon
      duplicates report lat lon
      save "out_2001-2011.dta", replace


      use loc_pk_2018.dta ,clear
      recast float lat lon, force

      sort lat lon
      duplicates report lat lon
      save, replace



      merge 1:1 lat lon using out_2001-2011.dta



      getting this error message


      . merge 1:1 lat lon using out_2001-2011.dta
      variables lat lon do not uniquely identify observations in the using data
      r(459);


      I will try you method and let you know plesae

      Comment


      • #4
        Ashish Tyagi Thanks

        I have tired this

        . use out_2001-2011.dta, clear

        . gen LAT = round(lat,0.00001)

        . gen LON = round(lon,0.00001)

        . save "first.dta", replace
        (file first.dta not found)
        file first.dta saved

        .
        end of do-file

        . do "C:\Users\ramzan\AppData\Local\Temp\STD490c_000000 .tmp"

        . use loc_pk_2018.dta ,clear

        . gen LAT = round(lat,0.00001)

        . gen LON = round(lon,0.00001)

        .
        end of do-file

        . do "C:\Users\ramzan\AppData\Local\Temp\STD490c_000000 .tmp"

        . merge 1:1 LAT LON using "first.dta"
        variables LAT LON do not uniquely identify observations in the using data
        r(459);


        Comment


        • #5
          You cannot do a 1 to 1 merge unless the your identifiers are unique in each file.
          In this case it looks like you probably want

          Code:
          merge 1:m LAT LON using "first.dta"
          also see
          Code:
          help isid
          which can help you check whether a group of variables uniquely identifies observations in a dataset before merging.

          Comment

          Working...
          X