Up until now I have always the by: prefix in order to egen by groups. I recently came across a code that used the by() option instead. Is there any difference between these? The only difference I see is that using the by() option does not necessitate the sorting of the data. Is there anything else going on "behind the scenes"?
Code example:
Code example:
Code:
. sysuse auto (1978 Automobile Data) . sort price . by foreign: egen max_rep78 = max(rep78) not sorted r(5); . bysort foreign: egen max_rep78_1 = max(rep78) . sort price . egen max_rep78_2 = max(rep78), by(foreign) . compare max_rep* ---------- difference ---------- count minimum average maximum ------------------------------------------------------------------------ max_rep~1=max_rep~2 74 ---------- jointly defined 74 0 0 0 ---------- total 74
Comment