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
    Ryanka:
    please do not duplicate. Thanks.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Your approach works. It can be done a bit more simply with:
      [code]
      collapse (sum) total_grants = grant, by(company_id year)

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        Your approach works. It can be done a bit more simply with:
        [code]
        collapse (sum) total_grants = grant, by(company_id year)
        oh yes, Thank you so much Senior.

        Comment

        Working...
        X