Announcement

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

  • Trying to merge two datasets that have already been merge and getting error 101 (factor-variable and time-series operators not allowed)

    Hello Everyone,

    I am trying to merge two different datasets. Each dataset has two columns (example dataset 1: countryID and fdi_out_1970m.dta , example dataset 2: countryID and aid_out_1970m.dta).
    The dataset with aid_out_1970m.dta has 12 more variables than fdi_out_1970m.dta because it includes the summary of different world region and fdi_out_1970m.dta just has the country names and no regions.

    I previously merged the countryID with aid_out_1970 and fdi_out_1970 and got the results (fdi_out_1970m.dta and aid_out_1970m.dta). Now I am trying to merge together aid_out_1970m.dta with fdi_out_1970m.dta. But every time I try to merge the two datasets together I get factor-variable and time-series operators not allowed.

    Here is the code I tried:

    use "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 2 AID MERGE/aid_out_1970m.dta", clear
    generate id = _n
    tempfile aid
    use "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 2 FDI MERGE/fdi_out_1970m.dta", clear
    generate id = _n
    merge 1:1 aid_out_1970m.dta using fdi_out_1970m.dta


    I also previously tried this code:

    merge 1:1 "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 2 AID MERGE/aid_out_1970m.dta" using /Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 2 FDI MERGE/fdi_out_1970m.dta, clear


    ANY HELP WOULD BE MORE THAN APPRECIATED! THANK YOU FOR YOUR TIME
    Last edited by Noura Compaore; 13 Jul 2018, 23:22.

  • #2
    Your problem is no different than your previous topic. You are not correctly using the merge command. In my response on that topic I wrote

    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.
    Again your merge commands are not correctly specified, you provide no variable name for merge to use to match the files. CountryID would seem to be the correct variable to use.
    Code:
    merge 1:1 CountryID "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 2 AID MERGE/aid_out_1970m.dta" using "/Users/an-nourazen-nabcompaore/Dropbox/AnNoura/build/code/STEP 2 FDI MERGE/fdi_out_1970m.dta"
    I'm sympathetic to you as a new user of Stata - it's a lot to absorb. And even worse if perhaps you are under pressure to produce some output quickly. Nevertheless, I'd like to encourage you to take a step back from your immediate tasks.

    When I began using Stata in a serious way, I started, as have others here, by reading my way through the Getting Started with Stata manual relevant to my setup. Chapter 18 then gives suggested further reading, much of which is in the Stata User's Guide, and I worked my way through much of that reading as well. There are a lot of examples to copy and paste into Stata's do-file editor to run yourself, and better yet, to experiment with changing the options to see how the results change.

    All of these manuals are included as PDFs in the Stata installation (since version 11) and are accessible from within Stata - for example, through the PDF Documentation section of Stata's Help menu. The objective in doing the reading was not so much to master Stata as to be sure I'd become familiar with a wide variety of important basic techniques, so that when the time came that I needed them, I might recall their existence, if not the full syntax, and know how to find out more about them in the help files and PDF manuals.

    Stata supplies exceptionally good documentation that amply repays the time spent studying it - there's just a lot of it. The path I followed surfaces the things you need to know to get started in a hurry and to work effectively.

    Comment

    Working...
    X