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/