An Extension to egen for the Computation of Peers' Average Characteristics
egen [type] newvar = peers(argument) [if] [in], by(varname)
Description
peers is an extension to egen that computes the average characteristic of peers in a unit defined by argument.
Behaviour with missing values and small units
peers ignores missing values, ie they do not count in the mean. Moreover if a unit has only one observation, then newvar is set to missing.
Examples
egen average_age_of_peers = peers(age), by(classroom)
Author
Amine Ouazad, PhD Candidate of the Paris School of Economics, Webpage http://www.pse.ens.fr/junior/ouazad/ Email amine.ouazad@pse.ens.fr
Also see
egen