Announcement

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

  • Merging/adding two rows of data

    We have a big problem conserning our panel data. When we xtset we get a problem of repeated time values within panel. As we are not able to just drop the data that has repeated time values we somehow need to add them togheter. We have now been browsing for several hours without finding any feasable solution. In short, some of the grocery stores we are analyzing have two observations per week for the same product. The code: drop if week == week[_n-1] solves the problem, but instead of dropping, we want to add another variable called "sales" if week == week[_n-1]. To specify we want to add the two sale observations for the same week together. The code should therefore look something like: "add sales if week = week[_n-1]". Hope this made sense, and thank you in advance.

  • #2
    Please provide an extract of your data using the dataex command, as advised in the Statalist FAQ.

    Comment


    • #3
      Your solution will almost certainly involve using the collapse command to reduce your observations to 1 for each combination of week and store.

      See
      Code:
      help collapse
      for more documentation about the collapse command, or as post #2 recommends, provide useful example data using the dataex command so that realistic example code can be written.

      Comment

      Working...
      X