is there an equivalent to Stata's egen function? [duplicate]
问题 This question already has answers here : Calculate group mean (or other summary stats) and assign to original data (4 answers) Closed last month . Stata has a very nice command, egen , which makes it easy to compute statistics over group of observation. For instance, it is possible to compute the max, the mean and the min for each group and add them as a variable in the detailed data set. The Stata command is one line of code : by group : egen max = max(x) I've never found the same command in