Announcement

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

  • Calculate total grants

    company_id year grant
    co_001 2003 1
    co_001 2004 0
    co_001 2005 1
    co_001 2005 1
    co_002 2005 0
    co_002 2006 1
    co_002 2006 1
    co_002 2006 1
    co_003 2007 1
    co_003 2007 1
    co_003 2007 1
    co_003 2007 1
    co_004 2008 0
    co_004 2011 1
    1. Create the formula/command/code for the variable total_grants. For example, co_001 received 1grant in 2003, 0 grants in 2004 and 2 grants in 2005.. I
    2. I have used the code: collapse(sum) grant , by (company_id year)
    3. then rename grant total_grants. I dont know if Im correct or not. Kindly review my working also help me to understand how can we use bysort command.
    4. Thank you , Seniors.

  • #2
    Riyanka:
    you may want to try:
    Code:
    bysort company_id: egen total_grants=sum(grant)
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Riyanka:
      you may want to try:
      Code:
      bysort company_id: egen total_grants=sum(grant)
      Oh yes it worked. Thank you so much Senior !

      Comment

      Working...
      X