Announcement

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

  • Merging two rows into one - Trade data

    Dear all,

    I have trade data for bilateral trade. I have two data sets, the export data (tradeflow_comtrade_o) and the import data (tradeflow_comtrade_d). I want to merge the two datasets to have one dataset with export and import data. Unfortunately, the merge command did not lead to the results needed. I tried the append command which brought me a bit closer. The result when appending the two data sets:


    ID year iso3_o iso3_d tradeflow_comtrade_o tradeflow_comtrade_d
    45454 2021 USA FRA 3.07e+07
    53085 2021 USA FRA 5.17e+07
    45338 2022 USA FRA 4.69e+07
    53165 2022 USA FRA 5.91e+07
    45093 2023 USA FRA 4.53e+07
    53097 2023 USA FRA 5.89e+07

    As you can see the same year is always in two rows with export data in one row and import data in the second row.

    I now want to merge the two rows into one, so I have one row per year.

    I would be grateful for any help.
    Best
    Christopher

  • #2
    How do you tell which observations (rows) contain exports and which imports? It is not obvious to me.

    Comment


    • #3
      Unfortunately, i cannot copy-paste the output, but the 1,3,5 row (3.07, 4.69, 4.53) are export data (tradeflow_comtrade_o) and the 2,4,6 row (5.17, 5.91, 5.89) is import data (tradeflow_comtrade_d).

      Comment


      • #4
        I fixed the problem! But many thanks for your interest!

        Comment

        Working...
        X