Extracting part of a title

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 138
Accepted Solution

Extracting part of a title

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!



Accepted Solutions
Solution
‎02-04-2013 11:50 AM
Frequent Contributor
Frequent Contributor
Posts: 94

Re: Extracting part of a title

Posted in reply to Walternate

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


All Replies
Super Contributor
Posts: 578

Re: Extracting part of a title

Posted in reply to Walternate

index(title,'END')

Respected Advisor
Posts: 3,799

Re: Extracting part of a title

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

Super User
Posts: 5,504

Re: Extracting part of a title

Posted in reply to data_null__

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.

Respected Advisor
Posts: 3,799

Re: Extracting part of a title

Posted in reply to Astounding

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

Super Contributor
Posts: 543

Re: Extracting part of a title

Posted in reply to Walternate

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.

Occasional Contributor
Posts: 14

Re: Extracting part of a title

Posted in reply to Walternate

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

Solution
‎02-04-2013 11:50 AM
Frequent Contributor
Frequent Contributor
Posts: 94

Re: Extracting part of a title

Posted in reply to Walternate

Assuming that your title variable is BookTitleVar:

proc sql;

  create table want as

  select  BookTitleVar

  from have

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

quit;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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