Announcement

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

  • Merging 2 datasets and drawing a graph

    Hello Statalist community;

    I have 2 datasets:
    - The first one contains about 100 countries (as the x variable or axis), and the Inflation rate for each country (as the y variable or axis).
    - The second one contains about 100 countries or so (again, as the x variable or axis), and the purchase power decrease for each county (as the y variable or axis) (by purchase power decrease, I mean it's an inverse scale)

    Remark: Both datasets don't contain the same countries, there are countries which exist in the first one and doesn't in the second one, and vice-versa.

    My goal is draw a graph, showing the situation, for each country that exists in both datasets, according to its inflation and power purchase decrease. The idea is to have a graph showing the inflation (in the horizontal axis) and purchase power decrease (in the vertical axis) for each country existing in both datasets, and I wanna eliminate those who exist in just one datasets.
    Already, there is the idea of merging the 2 datasets by country (the x variable or axis), eliminating the countries whch missing data in one of the datasets, and then drawing the scatterplot.

    Could anyone suggest a Stata code on how to do so? Also, both datasets are in Excel format.

    Thanks very much for the help.

  • #2
    It is premature to request Stata code when you have not yet imported your data into Stata data sets (except if your requesting help with the code to do the importation itself.) You may find that the importation leads to unexpected problems in the Stata data sets that will need to be cleaned up before you can combine them. (This is a frequent occurrence given the unstructured nature of spreadsheets.)

    Please proceed with importing your data from Excel and saving it in Stata data sets. (Use the -import excel- command for best results.) Then, if you remain uncertain how to proceed, post back showing example data from both data sets using the -dataex- command to get specific advice. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment


    • #3
      Hello M. Schechter, thanks very much fpr your explenation. Problem already solved

      Comment

      Working...
      X