Find “Mike” in the Name variable. Use scan function when you know the position of the word within the variable and the delimiter. Use contains for general search. Use substr function when you know the starting position of the word within the variable.
- Scan
data a; set b; where scan(name, 1, ' ') = "Mike"; run;
/* nested Scan example */ /* data string is like 'XX XX ABCD>XXXX' */ /* need to get the 'ABCD' portion of the string, but it can be different lengths */ data temp; set set1; temp =scan(scan(var, 3, ' '),1, '>'); keep temp; run;
- Contains
data a; set b; where upcase(name) contains "MIKE"; run;
- Substr
data a; set b; where substr(name, 1, 4) = "Mike"; run;