sungmoo 发表于 2010-11-7 14:41 
*试一下
keep if indexnot("人工",nid)==0
Indexnot 和regexm应该是解决此类问题的很好的方案。但为什么有时候不行呢?我有25个数据,该命令只对一部分起作用,另外还有的判断出错。这是为什么呢?
我的数据见附件,程序为:
insheet using test.txt,clear
set more off
capture drop r
gen r=. // r=0 if matched in both variable
local i=1
while `i'<=_N {
local v substr(name[`i'],1,4)
di `v'
/*scalar a=regexm(name_u,`v')
replace r=a in `i'*/
replace r=indexnot(`v',name_u)
local i=`i'+1
}
list