[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: cumulative average moving through time
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.
Institute for Policy Studies
Johns Hopkins University
* For searches and help try: