Statalist The Stata Listserver

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

RE: st: RE: Understanding the difference between gen and egen

From   Richard Williams <>
Subject   RE: st: RE: Understanding the difference between gen and egen
Date   Wed, 14 Jun 2006 09:31:49 -0500

At 03:14 AM 6/14/2006, Nick Cox wrote:
I am not knocking -egen-. I may be its greatest
fan in the Stata community. I have found it helpful
in my own work to be able to use, and to write -egen-
functions. But it is not, itself, an enormous deal. It is at root
a rag-bag of convenient short-cuts. For example,
if -egen, total()- did not exist, we could get
there typically in two lines instead of one,
as in

bysort bar: egen foototal = total(foo)

being done by

bysort bar : gen foototal = sum(foo)
by bar: replace foototal = foototal[_N]
I think that may understate egen's value a bit. True, as far as typing goes, it may sometimes only save you a line or two. But for many people it will also save the several hours it would take to figure out what those two or three lines would be!

Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: Richard.A.Williams.5@ND.Edu
WWW (personal):
WWW (department):
* For searches and help try:

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