Statalist


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

Re: st: calculating cumulative exposure


From   Enzo Coviello <enzo.coviello@alice.it>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: calculating cumulative exposure
Date   Fri, 03 Aug 2007 17:53:22 +0200

At 16.36 03/08/2007, you wrote:
Dear statalisters,

I‘ve got multiple records per person and want to calculate some kind of cumulative exposure index per person. I’ve got a variable called “exposure” and want to create a new variable called “cum_exposure”. Each observation in the cum_exposure variable should give the sum of all previous cells in the exposure column (but per person). So something like this:

Id Exposure list Cum.Exposure
1 10 1 10
1 14 2 24
1 15 3 39
2 8 1 8
2 10 2 18
2 15 3 32

Try:

bysort Id: g cumexp=sum(Exposure)


Enzo

Enzo Coviello
Unità di Epidemiologia e Statitica ASL BARI
Piazza V. Emanuele 14 - 70054 Giovinazzo (Bari)
tel./fax 080 3357867
mobile 347 5016 016

*
* 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