Statalist The Stata Listserver


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

st: Re: Accumulastion Order


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: Accumulastion Order
Date   Fri, 16 Mar 2007 13:28:46 -0400

Your example output does show the cumulative sum of A, but your code doesn't even reference a variable A. It's not clear what p is in your code or why you need a double loop or how it relates to the output below it, but Stata can produce a cumulative sum using the built-in -sum()- function.

Michael Blasnik

---- Original Message ----- From: "Victor M. Zammit" <[email protected]>
To: <[email protected]>
Sent: Friday, March 16, 2007 11:40 AM
Subject: st: Accumulastion Order



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

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