Announcement

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

  • Trying to merge two 1 column datasets but error 101 (factor-variable and time-series operators not allowed) keeps occuring.

    Hello everyone,

    I was trying to merge two datasets: countryID.dta and aid_out_1970.dta
    Country ID is just a column with country names and aid_out_1970 is only one column with the numbers.
    Every time I try to merge them I get an error code r101 ( factor-variable and time-series operators not allowed). Any help would be more than appreciated!

    I tried this code:
    use "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP1FDI/countryid.dta
    use "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 1 AID.dta/aid_out_1970.dta"
    merge 1:1 "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP1FDI/countryid.dta' using "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 1 AID.dta/aid_out_1970.dta"

    I also tried this code:

    use "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP1FDIcountryid.dta
    use "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 1 AID.dta/aid_out_1970.dta"
    merge m:m "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP1FDI/countryid.dta" using "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 1 AID.dta/aid_out_1970.dta

    I also tried this code:

    merge 1:1 "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP1FDI/fcountryid.dta" using "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 1 AID.dta/aid_out_1970.dta"

    Already tried:
    merge m:m "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP1FDI/fcountryid.dta" using "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 1 AID.dta/aid_out_1970.dta"

    I also tried
    merge 1:1 countryid.dta using aid_out_1970.dta
    merge m:m countryid . dta using aid_out_1970.dta

    Thank you very much for your time!


  • #2
    Noura:
    welcome to this forum.
    - you should never -merge- with the -m:m- option (event if available), as it often gives catastrophic results (see -merge- entry in Stata .pdf manual);
    - can you share with the list an example/excerpt of your datasets (using -dataex-) (see the FAQ)?
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      The merge command requires one or more variable names to be given: the variables are used by Stata to match the corresponding observations in the two datasets.

      If I understand correctly, you have two datasets, one is a list of country names, in some order, and the other is a list of numbers, in the same order. The two datasets have the same number of observations and you want to match the observations by their order in the two datasets.

      One approach is to add a sequential identifier to each dataset and then use that identifier in the merge command. Here's sample code that may start you in the right direction, if I have correctly understood your problem.
      Code:
      use "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 1 AID.dta/aid_out_1970.dta", clear
      generate id = _n
      tempfile aid
      save `aid'
      use "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP1FDI/countryid.dta, clear
      generate id = _n
      merge 1:1 id using `aid'

      Comment


      • #4
        Thank you very much! It helped a lot!

        Comment

        Working...
        X