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

RE: SPAM: RE: st: Re: Cumulative sum


From   "de la Garza, Adrian" <ADelagarza@imf.org>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: SPAM: RE: st: Re: Cumulative sum
Date   Mon, 3 May 2004 15:37:58 -0400

Yes, Nick. I was confusing it with -egen-. Thank you. And thanks (and
sorry!) to you too, Michael!

Adrian

> -----Original Message-----
> From: Nick Cox [mailto:n.j.cox@durham.ac.uk] 
> Sent: Monday, May 03, 2004 3:21 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: SPAM: RE: st: Re: Cumulative sum
> 
> 
> Michael is correct. Your guess is not! 
> 
> Perhaps you are confusing the function -sum()-
> with the -egen- function -sum()-. 
> 
> Nick
> n.j.cox@durham.ac.uk 
> 
> de la Garza, Adrian
>  
> > I don't think that gives me the cumulative sum, does it? It 
> > gives me the
> > overall sum by country. That is, for every observation for which the
> > country is the same, I will get the same 'sum' variable, if I 
> > do it that
> > way...
>  
> Michael Blasnik 
> 
> > > no loop needed...
> > > 
> > > by country: gen cum_amount=sum(amount)
> 
> de la Garza, Adrian
>  
> > > > I would like to create a variable that gives me the 
> > cumulative of an
> > > > amount by country, like so:
> > > > 
> > > > country year quar amount cum_amount
> > > > Argentina 1990 1 100 100
> > > > Argentina 1990 2 50 150
> > > > Argentina 1990 2 25 175
> > > > Argentina 1990 2 100 275
> > > > Argentina 1990 3 200 475
> > > > ...
> > > > Bolivia 1990 1 25 25
> > > > Bolivia 1990 1 30 55
> > > > ...
> > > > 
> > > > Does anyone know a command that would do this without 
> > > needing to write a
> > > > loop?
> 
> *
> *   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/
> 

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index