Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Cumulative Sum by groups


From   "Alexander Nervedi" <[email protected]>
To   [email protected]
Subject   RE: st: RE: Cumulative Sum by groups
Date   Fri, 22 Apr 2005 14:36:50 +0000

I get the error message "time-series operators not allowed". i have tsset set - i dont think thats necessary to use this is it ?

-AN


From: "Nick Cox" <[email protected]>
Reply-To: [email protected]
To: <[email protected]>
Subject: st: RE: Cumulative Sum by groups
Date: Fri, 22 Apr 2005 15:18:32 +0100

bysort ID (year) : gen cusum = _N - _n + 1

Nick
[email protected]

Alexander Nervedi

> I am looking to implement a group level cumulative sum that
> starts counting
> backwards. Any suggestions on how to go about this would be
> really useful
>
> data example:
> ID  year  num   cusum
> 1    90      1       2
> 1    91      1       1
> 2    90      1       4
> 2    91      1       3
> 2    92      1       2
> 2    93      1       1
> 3    90      1       1
> 4    90      1       2
> 4    90      1       1
> ...
>
> I have variables ID year and num, and am trying to create cusum

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index