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

From |
smerryman@kc.rr.com |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: cumulative average moving through time |

Date |
Wed, 06 Oct 2004 15:33:52 -0500 |

Dan, 1) It is listed [R]Functions. -whelp mathfun- will list the other functions. 2) -bysort pid (ob)- sorts pid and then ob within pid but it performs the -gen cave = sum(calc)/ob- only on pid. -bysort pid ob- would not work because it would perform the calculation on each pid and ob pair. I don't believe the –by- option in -egen- is flexible enough to interpret -egen cave=sum(calc)/ob, by(pid ob)- correctly. Also, -egen ,sum()- does not allow expressions as sum(calc)/ob. You might find Nick Cox's article "Speaking Stata: How to move step by: step" SJ 2(1) helpful. Scott ----- Original Message ----- From: Daniel Egan <dp.egan@gmail.com> Date: Wednesday, October 6, 2004 2:59 pm Subject: Re: st: cumulative average moving through time > Hi Scott, > > by sort pid (ob):gen cave = sum(calc)/ob > > This is so obvious as to be painful. So why didn't I think of it? > > 1) Where/When did -sum()- become an acceptable argument to > -generate-!?!? I have only ever seen it in the context of -egen-. > Looking at the help for -generate-, there are no arguments that are > explicitly stated to be useable. It is only at the very bottom of the > examples that one sees an function -uniform- and then -sum- used with > gen. Are the others? I know that using many egen arguments with - > gen- > will return errors (e.g. count). > > 2) Why does the ---bys pid (ob)-- do this correctly? I understand that > it is equivalet to --sort PID OB--, but why does it result in the > correct cumulative sum? > Another way of putting this is why doesnt -egen cave=sum(calc)/ob, > by(PID OB)- work if this does? > > Sorry if this is a lot, I am just surprised about this. > > Oh, and thanks. I did not get to try Dan Lawson's code. > > Dan Egan > * > * 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/

- Prev by Date:
**Re: st: cumulative average moving through time** - Next by Date:
**RE: st: cumulative average moving through time** - Previous by thread:
**RE: st: cumulative average moving through time** - Next by thread:
**RE: st: cumulative average moving through time** - Index(es):

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