我这个小程序就是将数字取出来,得到:38883899967993
语法:capnum varname
代码:
- cap program drop capnum
- pro define capnum
- version 13.0
- syntax varlist
- tokenize `varlist'
- loc vn : word count `varlist'
- forval var=1/`vn' {
- loc i=1
- while `i'<=_N {
- loc n=""
- if indexnot(``var''[`i'],"0123456789") != 0 {
- loc m=length(``var''[`i'])
- forval j=1/`m' {
- loc a=substr(``var''[`i'],`j',1)
- if indexnot("`a'","0123456789") == 0 {
- loc n=plural(0,"`n'","+`a'")
- }
- loc ++j
- }
- qui replace ``var''="`n'" in `i'
- }
- loc ++i
- }
- }
- end