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

RE: st: RE: Cumulative Sum by groups


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

That surprises me. However, Stata does not 
act to minimise my surprise. Are you 
sure you are typing exactly what was 
suggested, as it works for me? 

Nick 
[email protected] 

Alexander Nervedi

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

Nick Cox

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

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/



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