econfj 发表于 2012-11-5 00:30 
谢谢大白菜,
不过您的回答,跟我原来的程序是一个意思,但是,我要只是中间十个1其他的全部删除
是一样的么????
一样么?
么?
. webuse nlswork,clear
(National Longitudinal Survey. Young Women 14-26 years of age in 1968)
.
. xtpattern, gen(pat)
.
.
. gen mark=strmatch(pat,"1111111111.*") | strmatch(pat,"*.1111111111.*") | strmatch(pat,"*.1111111111")
.
. gen p10=strpos(pat, "1111111111")
.
. tab1 mark p10
-> tabulation of mark
mark | Freq. Percent Cum.
------------+-----------------------------------
0 | 27,088 94.93 94.93
1 | 1,446 5.07 100.00
------------+-----------------------------------
Total | 28,534 100.00
-> tabulation of p10
p10 | Freq. Percent Cum.
------------+-----------------------------------
0 | 22,360 78.36 78.36
1 | 2,313 8.11 86.47
2 | 605 2.12 88.59
3 | 1,065 3.73 92.32
4 | 772 2.71 95.03
5 | 586 2.05 97.08
6 | 833 2.92 100.00
------------+-----------------------------------
Total | 28,534 100.00
your code just considers the substrings starting from "1111111111", which also include others such as "1111111111111".
But mine does answer your Q: 任何位置上连续的十个1,去除11个1或者12个1.。。