Statalist


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

Re: st: How to generate a cumulative sum


From   west--@libero.it
To   "statalist" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: How to generate a cumulative sum
Date   Fri, 26 Oct 2007 12:16:10 +0200

Dear Austin,

this is the result (for the first firm only) of the short program you kindly wrote to me:

. webuse grunfeld, clear

. g k0=int(uniform()*1000) if year==1935
(190 missing values generated)

. g k=.
(200 missing values generated)

. bys c(y): replace k=cond(l.k<.,l.k*(1-`d'),k0)+i
time-series operators not allowed
r(101);

. li com year k0 k inv in 1/10, noo sepby(com)

  +-----------------------------------+
  | company   year    k0   k   invest |
  |-----------------------------------|
  |       1   1935   715   .    317.6 |
  |       1   1936     .   .    391.8 |
  |       1   1937     .   .    410.6 |
  |       1   1938     .   .    257.7 |
  |       1   1939     .   .    330.8 |
  |       1   1940     .   .    461.2 |
  |       1   1941     .   .      512 |
  |       1   1942     .   .      448 |
  |       1   1943     .   .    499.6 |
  |       1   1944     .   .    547.5 |
  +-----------------------------------+

-----------------------------------------------

As you can see (I tried several times...), no new "k" has been generated by Stata 9.2. I don't understand the reason and I ask for your help again to find a solution. Thank you.

Damiano 


---------- Initial Header -----------




© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index