*! version 1.0.0 10/28/93 STB16: zz3 program define stb_idx /* insert length */ version 3.1 local insert =lower("`1'") local l `2' local i=1 qui drop _all qui set obs 1 qui gen str6 stb = "0" while (1) { capture stb_find stb`i' if _rc { if `i'>15 { qui drop if stb=="0" cap drop file exit } } else { quietly { append using $S_1 if `l'==-3 { keep if index(lower(file),"`insert'") /* */ | stb=="0" keep stb insert ttl author file sort stb insert quietly by stb insert: keep if _n==1 } else { keep stb insert ttl author sort stb insert quietly by stb insert: keep if _n==1 if `l'==-1 { keep if /* */ index(lower(ttl),"`insert'") | /* */ stb=="0" } else if `l'==-2 { keep if /* */ index(lower(author),"`insert'") | /* */ stb=="0" } else keep if /* */ substr(lower(insert),1,`l')== /* */ substr("`insert'",1,`l') | /* */ stb=="0" } } } local i=`i'+1 } /*NOTREACHED*/ end