Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: cumulative summation


From   James Bernard <[email protected]>
To   [email protected]
Subject   Re: st: cumulative summation
Date   Tue, 26 Feb 2013 17:03:15 +0800

Hi Nick,

Or, I am thinking about an easier option:

For me the first observation is not useful, so I want the second one
for firm A in year 1990.For firm A in year 1991, I have only one
observation and I need it. For B in year 1990 I want the observation
where ties is equal to 3. I don't want the other two cases of Firm B
in year 1990. So, I want them dropped from my dataset.
Thanks,
james


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
>>>




On Tue, Feb 26, 2013 at 4:39 PM, James Bernard <[email protected]> wrote:
> Thanks Nick,
>
> I have missing values in my list, so it seems that the command is not
> working, because it sets many of the values to . (missing).
>
> I gave you the simplifies version. In fact, I am using loops and
> macros to do this
>
> Then, instead would it be possible to write a comand that can detect
> that for firm A in 1990, 2 is the larger one.
>
> Alternatively, would it be possible to ask the program to keep only
> the last observation of every group (a group defined by firm and year)
>
> Thanks a gain,
> James
>
>
> On Tue, Feb 26, 2013 at 3:49 PM, Nick Cox <[email protected]> wrote:
>> bysort firm year (ties) : replace ties = ties[_N]
>>
>> Nick
>>
>> On Tue, Feb 26, 2013 at 7:08 AM, James Bernard <[email protected]> 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/
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index