Announcement

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

  • Merging macrodata with microdata

    I have been trying to merge macro-level data from WDI with microlevel data from Afrobarometer survey using COUNTRY as the unique identifier, but without success. I destringed the COUNTRY in the macro dataset, but it still didn't work. Please help me.

  • #2
    You shouldn't be using destring at all with country names. Open each dataset and run

    Code:
    dataex in 1/10
    Then copy and paste the output here.

    Comment


    • #3
      Thank you, Andrew. I used encode instead of destring.

      My result
      merge m:1 COUNTRY using "macro.dta"
      (variable COUNTRY was byte, now long to accommodate using data's value)
      variable COUNTRY does not uniquely identify observations in the using data

      Comment


      • #4
        use of encode separately in each file is almost certainly a mistake (unless you also use the "label" option); please do as both the FAQ and Andrew Musau suggest

        Comment


        • #5
          I used the encode command only for the COUNTRY variable in the macro-level data.

          Comment


          • #6

            macro-level data . dataex in 1/10 ----------------------- copy starting from the next line -----------------------
            Code:
             * Example generated by -dataex-. For more info, type help dataex clear input int year1 double GDPpercapita str13 D byte COUNTRY 2016  1010.533896199298 "Benin"    1 2017 1054.9740806681434 "Benin"    1 2018 1151.7409703472013 "Benin"    1 2019 1130.8213533979497 "Benin"    1 2020 1200.1942655778935 "Benin"    1 2021 1318.6515807519838 "Benin"    1 2022 1266.4271103190442 "Benin"    1 2023 1394.1778472183137 "Benin"    1 2016   6749.05994339013 "Botswana" 2 2017  7104.964010880272 "Botswana" 2 end label values COUNTRY country label def country 1 "Benin", modify label def country 2 "Botswana", modify
            ------------------ copy up to and including the previous line ------------------ Listed 10 out of 256 observations micro-level data . dataex in 1/10 input statement exceeds linesize limit. Try specifying fewer variables

            Comment


            • #7
              Problem solved. Thanks, everyone.

              Comment

              Working...
              X