BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Walternate
Obsidian | Level 7

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!


1 ACCEPTED SOLUTION

Accepted Solutions
VD
Calcite | Level 5 VD
Calcite | Level 5

Assuming that your title variable is BookTitleVar:

proc sql;

  create table want as

  select  BookTitleVar

  from have

  where upcase(BookTitleVar) like '%END%';

quit;

View solution in original post

7 REPLIES 7
DBailey
Lapis Lazuli | Level 10

index(title,'END')

data_null__
Jade | Level 19

The OP mentioned word end not string.  I would think indexW.

Astounding
PROC Star

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.

data_null__
Jade | Level 19

OR maybe FINDW with option to ignore case.  So may choices. :smileyshocked:

AncaTilea
Pyrite | Level 9

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.

Data_Detective_23219
Calcite | Level 5

indexW would be my choice coupled with the upcase function in order to remedy any upper/lower case variations of the word end.

VD
Calcite | Level 5 VD
Calcite | Level 5

Assuming that your title variable is BookTitleVar:

proc sql;

  create table want as

  select  BookTitleVar

  from have

  where upcase(BookTitleVar) like '%END%';

quit;

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 820 views
  • 3 likes
  • 7 in conversation