Announcement

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

  • Unable to merge data: obtaining return code r(601)

    Hi all,

    I have a dataset with data on the Gini index for Brazilian municipalities in 2010. I need to merge to this dataset an id variable called "ibge_mun_code", which is located in the dataset "finbra_codsiafi_2008.dta".


    merge 1:1 ibge using finbra_codsiafi_2008.dta, keepusing(ibge_mun_code)


    I have been unable to do the merge. Instead, I get the following error message: file finbra_codsiafi_2008.dta not found

    I don't know the reason for this error. Both datasets are stored in the same folder. In addition, the filename "finbra_codsiafi_2008.dta" is correct. I re-checked several times.

    Does anyone know how to fix this problem?

    Thank you.

  • #2
    Post an example of your data as the FAQ asks, please. This is impossible to solve otherwise. Use dataex.

    Comment


    • #3
      Here follows the data for the master dataset:

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input int year byte ibge_uf_code long ibge double gini
      2010 11 110001 .5893
      2010 11 110037 .5491
      2010 11 110040 .5417
      2010 11 110034 .5355
      2010 11 110002 .5496
      2010 11 110045 .5017
      2010 11 110003 .5166
      2010 11 110060 .5579
      2010 11 110004  .589
      2010 11 110070 .6705
      2010 11 110080 .4762
      2010 11 110090 .4996
      2010 11 110005 .5147
      2010 11 110092 .4752
      2010 11 110006 .5154
      2010 11 110007 .4852
      2010 11 110008 .5239
      2010 11 110094  .525
      2010 11 110009 .5399
      2010 11 110100 .5571
      2010 11 110010 .5586
      2010 11 110110 .4771
      2010 11 110011 .5081
      2010 11 110012 .5449
      2010 11 110013 .5596
      2010 11 110120 .5588
      2010 11 110130 .6102
      2010 11 110140 .4813
      2010 11 110014 .5688
      2010 11 110033 .5357
      2010 11 110143 .4665
      2010 11 110050 .5214
      2010 11 110015 .4947
      2010 11 110145 .5315
      2010 11 110018   .55
      2010 11 110146 .4964
      2010 11 110020 .5745
      2010 11 110025 .5281
      2010 11 110147 .5188
      2010 11 110026 .5783
      2010 11 110028 .5401
      2010 11 110029 .4972
      2010 11 110148 .4695
      2010 11 110149 .5684
      2010 11 110032 .6308
      2010 11 110150 .6384
      2010 11 110155 .4346
      2010 11 110160 .5763
      2010 11 110170 .5165
      2010 11 110175 .5727
      2010 11 110180 .5885
      2010 11 110030  .509
      2010 12 120001 .5464
      2010 12 120005 .6228
      2010 12 120010 .5945
      2010 12 120013 .5832
      2010 12 120017 .5627
      2010 12 120020 .6438
      2010 12 120025  .607
      2010 12 120030 .6774
      2010 12 120032 .7112
      2010 12 120033 .6102
      2010 12 120034 .5939
      2010 12 120035 .5938
      2010 12 120038  .575
      2010 12 120080 .6121
      2010 12 120039 .6094
      2010 12 120040 .6121
      2010 12 120042 .6463
      2010 12 120043 .7758
      2010 12 120050 .5485
      2010 12 120045  .559
      2010 12 120060 .6481
      2010 12 120070   .59
      2010 13 130002 .5881
      2010 13 130006 .6698
      2010 13 130008 .5807
      2010 13 130010 .5984
      2010 13 130014 .5753
      2010 13 130020 .6594
      2010 13 130030 .5982
      2010 13 130040 .7367
      2010 13 130050 .6049
      2010 13 130060 .5665
      2010 13 130063 .6574
      2010 13 130068 .6097
      2010 13 130070 .6427
      2010 13 130080 .6364
      2010 13 130083  .597
      2010 13 130090 .6185
      2010 13 130100 .5402
      2010 13 130110 .6668
      2010 13 130115 .5722
      2010 13 130120 .6234
      2010 13 130130 .6153
      2010 13 130140 .6237
      2010 13 130150 .6374
      2010 13 130160  .631
      2010 13 130165 .7397
      2010 13 130170 .6751
      end

      Comment


      • #4
        Here follows the data for the using dataset:

        Code:
        * Example generated by -dataex-. For more info, type help dataex
        clear
        input int year str2 uf byte ibge_uf_code long(ibge ibge_mun_code)
        2008 "RO" 11 110010 1100106
        2008 "RO" 11 110037 1100379
        2008 "RO" 11 110020 1100205
        2008 "RO" 11 110045 1100452
        2008 "RO" 11 110012 1100122
        2008 "RO" 11 110092 1100924
        2008 "RO" 11 110002 1100023
        2008 "RO" 11 110094 1100940
        2008 "RO" 11 110004 1100049
        2008 "RO" 11 110143 1101435
        2008 "RO" 11 110018 1100189
        2008 "RO" 11 110145 1101450
        2008 "RO" 11 110030 1100304
        2008 "RO" 11 110146 1101468
        2008 "RO" 11 110011 1100114
        2008 "RO" 11 110147 1101476
        2008 "RO" 11 110015 1100155
        2008 "RO" 11 110148 1101484
        2008 "RO" 11 110025 1100254
        2008 "RO" 11 110149 1101492
        2008 "RO" 11 110008 1100080
        2008 "RO" 11 110155 1101559
        2008 "RO" 11 110006 1100064
        2008 "RO" 11 110175 1101757
        2008 "RO" 11 110009 1100098
        2008 "RR" 14 140002 1400027
        2008 "RO" 11 110005 1100056
        2008 "RR" 14 140017 1400175
        2008 "RO" 11 110028 1100288
        2008 "RR" 14 140023 1400233
        2008 "GO" 52 520455 5204557
        2008 "RR" 14 140028 1400282
        2008 "RO" 11 110001 1100015
        2008 "RR" 14 140045 1400456
        2008 "RO" 11 110034 1100346
        2008 "RR" 14 140047 1400472
        2008 "RO" 11 110003 1100031
        2008 "RR" 14 140070 1400704
        2008 "RO" 11 110013 1100130
        2008 "PA" 15 150085 1500859
        2008 "RO" 11 110014 1100148
        2008 "PA" 15 150125 1501253
        2008 "RO" 11 110029 1100296
        2008 "PA" 15 150145 1501451
        2008 "RO" 11 110032 1100320
        2008 "PA" 15 150195 1501956
        2008 "RO" 11 110033 1100338
        2008 "PA" 15 150215 1502152
        2008 "GO" 52 521205 5212055
        2008 "PA" 15 150285 1502855
        2008 "GO" 52 521839 5218391
        2008 "PA" 15 150304 1503044
        2008 "GO" 52 521973 5219738
        2008 "PA" 15 150442 1504422
        2008 "GO" 52 520551 5205513
        2008 "PA" 15 150497 1504976
        2008 "GO" 52 522119 5221197
        2008 "PA" 15 150563 1505635
        2008 "GO" 52 522157 5221577
        2008 "PA" 15 150565 1505650
        2008 "GO" 52 520396 5203962
        2008 "PA" 15 150611 1506112
        2008 "GO" 52 520393 5203939
        2008 "PA" 15 150746 1507466
        2008 "GO" 52 520929 5209291
        2008 "PA" 15 150775 1507755
        2008 "GO" 52 522220 5222203
        2008 "PA" 15 150803 1508035
        2008 "GO" 52 520993 5209937
        2008 "AP" 16 160080 1600808
        2008 "GO" 52 520145 5201454
        2008 "TO" 17 170030 1700301
        2008 "GO" 52 520547 5205471
        2008 "TO" 17 170305 1703057
        2008 "GO" 52 521645 5216452
        2008 "TO" 17 170307 1703073
        2008 "GO" 52 520549 5205497
        2008 "TO" 17 170460 1704600
        2008 "GO" 52 521377 5213772
        2008 "TO" 17 170510 1705102
        2008 "GO" 52 520505 5205059
        2008 "TO" 17 170625 1706258
        2008 "GO" 52 521971 5219712
        2008 "TO" 17 170980 1709807
        2008 "GO" 52 520055 5200555
        2008 "TO" 17 171215 1712157
        2008 "GO" 52 521487 5214879
        2008 "TO" 17 171245 1712454
        2008 "MT" 51 510337 5103379
        2008 "TO" 17 171370 1713700
        2008 "MT" 51 510645 5106455
        2008 "TO" 17 171550 1715507
        2008 "MT" 51 510740 5107404
        2008 "TO" 17 171845 1718451
        2008 "MT" 51 510665 5106653
        2008 "TO" 17 171889 1718899
        2008 "MT" 51 510706 5107065
        2008 "TO" 17 172000 1720002
        2008 "MT" 51 510719 5107198
        2008 "TO" 17 172097 1720978
        end

        Comment


        • #5
          Your using data finbra_codsiafi_2008.dta is in the same folder as your primary data, but that is not what is important. Since you don't give a full path to the dataset, Stata is looking for it in your current working directory, and is not finding it there

          Try the command
          Code:
          pwd
          dir
          before the merge to see what your current working directory is and what data files are in it.

          Comment


          • #6
            Thank you William for the advice. I typed "pwd" before running merge and obtained the following error message: r(9001) - macOS refuses to provide that information

            Comment


            • #7
              I am unable to reproduce that error on my Mac, but it strongly suggests that your current working direction is not one that you have access to.

              I created the folder example on my Mac and placed your two example datasets in it, as you said both your datasets are in the same folder. The following then worked for me.
              Code:
              . cd
              /Users/lisowskiw
              
              . dir example
              
              total 32
              -rw-r--r--  1 lisowskiw  staff  5055 Dec 22 11:50 finbra_codsiafi_2008.dta
              -rw-r--r--  1 lisowskiw  staff  4615 Dec 22 11:50 primary.dta
              
              . use example/primary
              
              . merge 1:1 ibge using example/finbra_codsiafi_2008.dta, keepusing(ibge_mun_code)
              
                  Result                      Number of obs
                  -----------------------------------------
                  Not matched                           130
                      from master                        65  (_merge==1)
                      from using                         65  (_merge==2)
              
                  Matched                                35  (_merge==3)
                  -----------------------------------------
              
              .

              Comment


              • #8
                Thank you William. I re-started Stata the next day and was able to do the merge operation without any problems. Strange.

                Comment

                Working...
                X