This function searches for a string pattern str within a vector vs and, if found, returns a value from vector vref with the same index. Vector vref may be contain numeric or string values. By default, the function searches vs for the full string (option = 2). If no match if found and vref is numeric, the function returns a missing value ("--"); when vref contains strings, an empty string is returned.
The function will return the closest match, using option =0 or =1, but Lookup() does not support wildcard characters.
This function also searches for a numeric value dd within a vector vd and, returns a value from vector vref with the same index. By default, the function seaches vd for the closest value (option = 2). If option = 0, it searchs for the closest value smaller than dd. If option = 1, it searchs for the closest value larger than dd.
If vref contains numeric values,
double Lookup(string str$, vector<string> vs, vector vref[, int option, int Case])
If vref contains string values,
string Lookup(string str$, vector<string> vs, vector<string> vref[, int option, int Case])$
If search a numeric vector vd,
double Lookup(double dd, vector vd, vector vref[, int option, int Case])
str
vs
dd
vd
vref
option
Case
If str is found in vs, returns a value in vector vref of the same row index.
If option = 2, and str is not found, returns an empty string or missing value.
If option = 0 and str is not found, returns the value corresponding to the nearest smaller value of str. If no smaller value of str exists, returns missing value (numeric) or empty string (string).
If option = 1 and str is not found, returns the value corresponding to the nearest larger value of str. If no larger value of str exists, returns missing value (numeric) or empty string (string).
range aa=1!col(A); range bb=1!col(B); string str1$ = Lookup("FSA", aa, bb)$; str1$=;