Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: st: AW: Calculating a (changing) accumulative sum


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: AW: Calculating a (changing) accumulative sum
Date   Thu, 14 Jan 2010 18:02:59 +0100

<> 

I am glad to hear that! BTW, and just out of curiosity: What does "also"
mean here? Is your solution not exactly what I recommended?



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von
[email protected]
Gesendet: Donnerstag, 14. Januar 2010 18:00
An: [email protected]
Betreff: Re: st: AW: Calculating a (changing) accumulative sum

bysort subject (period) : gen accumcon=sum(con)

also worked! :-)

Thank you very much!

Martin Weiss schrieb:
> <> 
>
>
> Try Nick`s http://www.stata-journal.com/sjpdf.html?articlenum=pr0004 for
> further explanations...
>
>
>
> *************
> clear*
> set obs 10
> gen byte subject=_n
>
> expand 10
> bys subject: gen byte time=_n
>
> gen con=int(runiform()*20)
>
> bys subject (time): gen accumcon=sum(con)
>
> l, sepby(subject) noo
> *************
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von
> [email protected]
> Gesendet: Donnerstag, 14. Januar 2010 17:49
> An: [email protected]
> Betreff: st: Calculating a (changing) accumulative sum
>
> I have 20 "period"s (i.e., 20 rows) of data for each "subject" i. For 
> each subject i, I would like stata to calculate the accumulative sum of 
> the variable "con" in a new variable "accumcon" in the following way:
>
> In period 1: accumcon = con[1]. In period 2:  accumcon = con[1]+con[2] 
> In period 3: accumcon = con[1]+con[2]+con[3] and so on, for each 
> subject, from period 1 until period 20.
>
> Thank you for your help.
>
>   

-- 
Dr. Özgür Gürerk

Lehrstuhl für Mikroökonomie & Laboratorium für experimentelle
Wirtschaftsforschung
(Microeconomics & Laboratory for Experimental Economics)

Universität Erfurt, Nordhäuser Str. 63, D-99089 Erfurt 

Tel: +49 361 7374561
Fax: +49 361 7374569
www.uni-erfurt.de/elab
--

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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