请看看Stata对encode的说明:encode creates a new variable named newvar based on the string variable varname, creating, adding to, or just using (as necessary) the value label newvar or, if specified, name. Do not use encode if varname contains numbers that merely happen to be stored as st...
*单个变量补缺失值replace var=某个数值 if var==.*多个变量同时补缺失值foreach i in var1 var2 var3 {replace `i'=0 if `i'==.} *将所有缺失值替换为0mvencode _all, mv(0) override 剔除ST/*ST/PT的样本 drop if strmatch(Coname,'*ST*')drop if strmatch(Coname,'*PT*') 剔除B股企业 ...
misstable summarize[varlist][if][in][, summarize_options] 1. 运行命令misstable和选项all可以直接输出指定变量串中所有变量的缺失情况。如果变量本身没有缺失值,表格结果显示为空;由于misstable只能识别数值型变量的缺失值,无法识别字符型变量的缺失值,所以,对于字符型变量来说,表格结果显示为“(string variable)...
foreach var of varlistall { renamevar'var'42 } 23.如果你有一个长字符串变量,然后缩短其值,请使用“compress”来缩短变量,这使得数据编辑器更好看。 sysuse auto2, clear replace make = 'This is a long string...' in 1 replace make = substr(make, 1, 6) compress 24.用'trim'去掉字符串变量...
= -1/ln(n)*y_lny_`i'_sum } foreach i in $all_var { gen d_`i'= 1-E_`i'...
foreach var of varlistall { renamevar'var'42 } 23.如果你有一个长字符串变量,然后缩短其值,请使用“compress”来缩短变量,这使得数据编辑器更好看。 sysuse auto2, clear replace make = "This is a long string..." in 1 replace make = substr(make, 1, 6) compress...
foreach var of varlistall { rename var' var'42 } 23.如果你有一个长字符串变量,然后缩短其值,请使用“compress”来缩短变量,这使得数据编辑器更好看。 sysuse auto2, clear replace make = "This is a long string..." in 1 replace make = substr(make, 1, 6) compress...
foreach i in `r(varlist)'{ egen t=sum(strpos(`i',"Total")) if !t drop `i' drop t } --- *设nation中的字符串全部为大写 g c=(strpos(nation,"C")>0) --- keep if strpos(x,"丹红")&...
foreach vname in y1 y2 y3 { (确定y变量组vname) reg `vname' x1 x2 x3 (将y变量组中的各个变量与诸x变量进行回归分析,注意vname的标点符号) } 上式等价于: mvreg y1 y2 y3 = x1 x2 x3 reg3命令: (1)简单用法: reg3 (y1 = x1 x2 x3) (y2 = x1 x3 x4) (y3 = x1 x2 x5) ...
foreach vname in y1 y2 y3 { (确定y变量组vname) reg `vname' x1 x2 x3 (将y变量组中的各个变量与诸x变量进行回归分析,注意vname的标点符号) } 上式等价于: mvreg y1 y2 y3 = x1 x2 x3 reg3命令: (1)简单用法: reg3 (y1 = x1 x2 x3) (y2 = x1 x3 x4) (y3 = x1 x2 x5) ...