Announcement

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

  • Sum values between two dates in a panel data

    Hello statalist, I have a panel data needs to calculate the sum of a column value between two dates for each studyid. For example, I need sum MsgRepNtwk between the two mark_date and create a new column storing the output. How could I operate it? Thanks very much for helping it out.
    Click image for larger version

Name:	Screen Shot 2020-11-21 at 18.33.28.png
Views:	1
Size:	200.8 KB
ID:	1582822


  • #2
    Ellie Yang I only know about half of the code to do this, but you're more likely to get help from better people if you supply your data (or a portion of it if the file is large) using dataex instead just posting a picture.

    Comment


    • #3
      Code:
      bysort studyid (date) : gen spell = sum(markdate < .) 
      bysort studyid spell : egen wanted = total(MsgReptNtwk)

      Comment


      • #4
        Thank you all! Next time I will work with dataex!

        Comment

        Working...
        X