Announcement

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

  • Sum Columns Row by Row

    Hi all,

    I have a dataset that is a panel of women's observations by year. I would like to sum a particular variable called deaths row by row, meaning that I want the sum of the deaths of 1995+1996 for the row in 1996 and so on.. Like this:

    woman year death sum

    1. 1995 0. 0
    1. 1996. 1. 1
    1. 1997 6. 7
    1. 1998. 0. 7
    1. 1999. 10. 17

    I know such a command exists because I have used in the past but I cannot find it..

    Thanks in advance!

  • #2
    There is a function (not a command) dedicated to your purpose, namely sum().

    For panel data, you want something like

    Code:
    bysort woman (year) : gen sum = sum(death)
    For a personal survey of some key functions see https://journals.sagepub.com/doi/pdf...867X1101100308

    Comment


    • #3
      Many thanks!!

      Comment

      Working...
      X