Hello,
I am looking for multple words within title. I am not able to get this work. Please if you can help
data A;
input title $1-39;
datalines;
A TALE OF TWO CITIES
GENERAL MANAGER IN ONE CITY
MANAGER IS IN ANOTHER CITY
MANAGER IS NOT IN THE CITY
run;
data work;
set A;
WORD=FIND(title,("IS IN","IS NOT","i"); /**** "i" is to handle the case insensitive ****/
run;
Maybe a regular expression?
word = prxmatch('/is in|is not/i', title);
Maybe a regular expression?
word = prxmatch('/is in|is not/i', title);
I'm pretty sure you can only search for one string using FIND. What you want is something like
FIND(title,"IS IN","i") or FIND(title,"IS NOT","i")
If you have many of these combinations to search for it may be better to create a data set with the target string and then use SQL to find the matches.
data work.find; infile datalines truncover; input find $10.; datalines; Is in is not in one ; run; data work.A; input title $1-39; datalines; A TALE OF TWO CITIES GENERAL MANAGER IN ONE CITY MANAGER IS IN ANOTHER CITY MANAGER IS NOT IN THE CITY run; proc sql; create table matched as select a.*, b.find, find(a.title,strip(b.find),'i') as word from work.a as a, work.find as b; quit;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.