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

From |
David Kantor <[email protected]> |

To |
[email protected] |

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

Date |
Wed, 06 Oct 2004 16:33:51 -0400 |

At 03:59 PM 10/6/2004 -0400, Dan Egan wrote, among other things:

(I suppose you meant "bysort pid...".)by sort pid (ob):gen cave = sum(calc)/ob [...] 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).

sum() has always been a basic function. It is not a matter of a "argument" to -generate-. It's a function, and any function can appear in an expression (subject to type compatibility). Thus it can appear anywhere an expression is accepted, such as in -generate-, among others.

See -help mathfun- for details.

The egen sum() program makes use of it. See (in the appropriate ado directory) _gsum.ado to see how it works.

Finally, the "functions" that -egen- accepts are just those that have programs written for them. (They all have "_g" as a prefix to their names. And you can write your own egen functions if you desire.) Some of these happen to have the same name as ordinary functions such as sum(). But there is no explicit connection between the two.

In case you wanted to know, egen is a program that calls another program. If you type

egen myvar = somefunction blah blah blah

then egen will call _gsomefunction with blah blah blah as arguments.

I hope this is useful.

David Kantor

Institute for Policy Studies

Johns Hopkins University

[email protected]

410-516-5404

*

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

**References**:

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