Announcement

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

  • merging data with different time frequencies

    Hello,
    I have looked for guidance from other posts but could not solve this: I have two datasets- 'Dataset A has annual observations (for instance, on local infrastructure expenditure) while Dataset B has observations at interval of 5 years (for instance, on elections- winners, number of votes, winner's details). There are key variables which can be used for merging Dataset A and Dataset B- area code. But the person elected in 2001, for example, is responsible for infrastructural investment for the subsequent 5 years. How do I merge them to match each observation in Dataset A with corresponding leaser's observations in Dataset B?

  • #2
    Show your two datasets using the dataex command please. Welcome to Statalist.

    Comment


    • #3
      Originally posted by Jared Greathouse View Post
      Show your two datasets using the dataex command please. Welcome to Statalist.
      Oh its a HUGE dataset with variable names not self explanatory. That's why I described the problem as concisely as I could. I basically need to merge data with 5 year intervals with another annual data such that the 5 year variables populate all of the intermediate periods in the annual data.

      Comment


      • #4
        Nobody is asking you to post the entire huge data set. In fact, nobody would want that. Just a modest sample from each data set that illustrates the problem at hand (so, it should include some observations from data set 2 that will match with the ones you show from data set 1, and some others that won't. And if the variable names are not self explanatory, provide an explanation of them. Actually, for this problem, the only variables that we need to understand are the key variables for the merge-ing and the variables that give the year (or 5-year).

        Use the -dataex- command to post the examples. 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.

        That's why I described the problem as concisely as I could.
        Yes, and you did a nice job of that. But the best description of the problem still doesn't provide enough information about the data itself to give anything more than a vague, generic, and usually unhelpful, solution. If you would like a vague, generic solution, I can tell you that it will probably involve using the -rangejoin- command, written by Robert Picard, available from SSC. Perhaps you will find that sufficient to solve the problem from there. If not, post back with example data.
        Last edited by Clyde Schechter; 28 Apr 2022, 00:14.

        Comment

        Working...
        X