Statalist The Stata Listserver


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

st: Accumulation function


From   "Victor M. Zammit" <[email protected]>
To   <[email protected]>
Subject   st: Accumulation function
Date   Sat, 17 Mar 2007 00:14:04 +0100

Dear subscribers,

I have variable A with the given observations and I would like to create
code to get variable Accum.I tried

local i = 1

while `i'<= _N {

local e = 1

while `e'<= _N {

local u = p[`i'] + p[`i'-1]

replace c = `u' in `e'

local e = `e'+1

local i = `i'+1

}

}

but it does not work,

A Accum

1     1

3    4

0    4

0    4

1     5

  0    5

3     8

3     11

3     14

0     14

1      15

1      16

3     19

1     20

0     20

1     21

3     24

Can I get any suggestions please

Victor M. Zammit

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