<>
Here's a solution that I believe you could adapt. I have made up my
list of valid codes and codes to be looked up, which are integer; they
could just as well be string values.
clear all
// create a table of valid codes
set obs 500
set seed 20091002
g codes = int(runiform()*1000)
sort codes
// tomata: Bill Gould from ssc
tomata codes
// look these up in the table
local look 50
g variable = int(runiform()*1000) in 1/`look'
tomata variable, nomiss
g foundit = . in 1/`look'
mata:
st_view(f=., ., "foundit")
codes
variable
// mm_posof(): Ben Jann from ssc, moremata
for(i=1; i<=rows(variable); i++) {
f[i] = (mm_posof(codes, variable[i]) > 0)
}
end
l foundit in 1/`look'
Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming
| http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/