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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.