winsor2
winsor2 winsorize or trim (if trim option is specified) the variables in varlist at particular percentiles specified by option cuts(# #). In defult, new variables will be generated with a suffix "_w" or "_tr", which can be changed by specifying suffix() option. The replace option replaces the variables with their winsorized or trimmed ones. 批量进行 winsor 或 trimming 处理
安装
ssc install winsor2, replace
相比于winsor命令的改进
(1) 可以批量处理多个变量;
(2) 不仅可以 winsor,也可以 trimming;
(3) 附加了 by() 选项,可以分组 winsor 或 trimming;
(4) 增加了 replace 选项,可以不必生成新变量,直接替换原变量。
范例
/*- winsor at (p1 p99), get new variable "wage_w"*/
. sysuse nlsw88, clear
. winsor2 wage
/*- left-trimming at 2th percentile*/
. winsor2 wage, cuts(2 100) trim
/*- winsor variables by (industry south), overwrite the old variables*/
. winsor2 wage hours, replace by(industry south)
作者
姓名:连玉君单位:中山大学岭南学院金融系