Code:
input VAR1 VAR2 A1 1 A2 0 A3 1 A4 1 A5 1 A6 1 A7 1 A8 1 A9 1 A10 1 A15 1 B7 0 A1 0 A16 1 A17 1 A18 1 A19 1 A20 0 A21 1 end
input VAR1 VAR2 A1 1 A2 0 A3 1 A4 1 A5 1 A6 1 A7 1 A8 1 A9 1 A10 1 A15 1 B7 0 A1 0 A16 1 A17 1 A18 1 A19 1 A20 0 A21 1 end
strpos(VAR1, "A1, A3/A10, A15/A19, A21")
. di strpos("frog A1, A2", "A1, A2") 6 . di strpos("A1, A2", "A1, A2") 1
// expand the numeric list and put into local numlist "1 3/10 15/19 21" local numlist `r(numlist)' // make sure we do not hit the limit of inlist() assert `: word count `numlist'' < 250 // separate entries by comma local numlist : subinstr local numlist " " ", " , all // create the indicator generate byte wanted = inlist(real(regexs(1)), `numlist') /// if regexm(VAR1, "^A([0-9]*)$") // ... fix missing values replace wanted = 0 if mi(wanted)
Comment