Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: PLEASE, Cumulative by group


From   Ulrich Kohler <kohler@wz-berlin.de>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: PLEASE, Cumulative by group
Date   Sat, 18 Nov 2006 18:50:35 +0100

On Saturday 18 November 2006 18:32, Mohamad Al-Ississ wrote:
> Hi,
> I am wondering if you can help me. I am trying to get a cumulative sum
> of AAR below by dif group. So I need the CAAR to do something like
> this:
>
> dif   AAR       CAAR
> 1     2.2         2.2
> 1     2.2         2.2
> 1     2.2         2.2
> 1     2.2         2.2
> 2     6.6         8.8
> 2      6.6        8.8
> 2      6.6        8.8
> 2      6.6        8.8
> 3      1.4        10.2
> 3      1.4        10.2
> 3      1.4        10.2
>
> I cannot do by line because because the groups vary in number of
> sub_occupants. I need to do it by group, can you help me?
> Thanks,

. by diff, sort: gen CAAR = AAR if _n==1
. replace CAAR = sum(CAAR)


-- 
kohler@wz-berlin.de
+49 (0)30 25491-361
*
*   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