Hello,
I have a variable listing book titles and I'd like to identify which titles have the word "End" in them. The word can be at different positions in the title so I'm not sure which command to use.
Thanks!
Assuming that your title variable is BookTitleVar:
proc sql;
create table want as
select BookTitleVar
from have
where upcase(BookTitleVar) like '%END%';
quit;
index(title,'END')
The OP mentioned word end not string. I would think indexW.
Building upon what has already been suggested:
search_result = indexW(upcase(title), 'END');
SEARCH_RESULT will be 0 when END is not found, and > 0 when it is found.
Good luck.
OR maybe FINDW with option to ignore case. So may choices. :smileyshocked:
I think :
found = (prxmatch('m/end/i', title) > 0); * the 'i' allows for both lower or upper case, it tells SAS that the match is case insensitive;
Good luck!
Anca.
indexW would be my choice coupled with the upcase function in order to remedy any upper/lower case variations of the word end.
Assuming that your title variable is BookTitleVar:
proc sql;
create table want as
select BookTitleVar
from have
where upcase(BookTitleVar) like '%END%';
quit;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.