目录
按类别求均值,然后创建一个新的变量
bysort year industry: egen meanvariable=mean(variable)
//year industry :分组的类别
//meanvariable :新变量的名称
//variable :均值变量
//如表所示的样例
bysort category: egen mean_variable=mean(variable)
variable | category | mean_variable |
目录
bysort year industry: egen meanvariable=mean(variable)
//year industry :分组的类别
//meanvariable :新变量的名称
//variable :均值变量
//如表所示的样例
bysort category: egen mean_variable=mean(variable)
variable | category | mean_variable |