Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: cumulative summation


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: cumulative summation
Date   Tue, 26 Feb 2013 07:49:50 +0000

bysort firm year (ties) : replace ties = ties[_N]

Nick

On Tue, Feb 26, 2013 at 7:08 AM, James Bernard <jamesstatalist@gmail.com> wrote:

> I have used the sum function to calculate a variable in  a panel data.
>
> Firm        Year      ties
> -----------  ----------    -------
> A             1990      1
> A             1990       2
> A             1991       1
> B             1990       0
> B             1990       1
> B             1990        3
> C             1990        0
> C             1991        0
> C             1992        0
>
> The issue is that the variable ties which is the number of ties a firm
> has formed in a year is a cumulative sum of something and, therefore,
> for a company like A the final number of ties in year 1990 should be
> 2. I need the program to write the same number (final value of the
> cumulative sum) instead of 1.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index