Statalist The Stata Listserver


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

Re: st: Accumulation function


From   "Victor M. Zammit" <[email protected]>
To   <[email protected]>
Subject   Re: st: Accumulation function
Date   Sat, 17 Mar 2007 21:51:18 +0100

Thanks Radu,that has solved for me a lot of code.

----- Original Message -----
From: "Radu Ban" <[email protected]>
To: <[email protected]>
Sent: Saturday, March 17, 2007 5:17 PM
Subject: Re: st: Accumulation function


> I might have misunderstood, but doesn't this solve your problem?
>
> gen Accum = sum(A)
>
> -Radu
>
> 2007/3/16, Victor M. Zammit <[email protected]>:
>> 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/
>>
> *
> *   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/
>

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