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

 

I am trying to find  "Paclitaxel" in the string, however I could not find it using index , and , findw , function even I only keep aplphbet and ","  .  However, I can find "carboplatin"  .    Any solution ?  Thank you very much!

 

 

test = compress(lowcase(regimen),'abcdefghijklmnopqrstuvwxyz,','k') ;

if index(test, 'paclitaxel') = 1 then pre_TAXANE = 1 ;

 

regimen

Afatinib,Carboplatin,Paclitaxel1..
Afatinib,Carboplatin,Paclitaxel Protein-Bound1..
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@Astounding doesn't the previous statement lowcase everything?

 

@Ivy review the modifiers so that you can avoid listing all the alphabet in your list. I think its 'ka' to keep all alphabetic values. 

View solution in original post

6 REPLIES 6
Reeza
Super User

INDEX returns the position, not a 0/1. Therefore your test of =1 will only be true if the word is at the exact beginning. Change your condition to test if it’s >0 instead.

 


@Ivy wrote:

 

I am trying to find  "Paclitaxel" in the string, however I could not find it using index , and , findw , function even I only keep aplphbet and ","  .  However, I can find "carboplatin"  .    Any solution ?  Thank you very much!

 

 

test = compress(lowcase(regimen),'abcdefghijklmnopqrstuvwxyz,','k') ;

if index(test, 'paclitaxel') = 1 then pre_TAXANE = 1 ;

 

regimen

Afatinib,Carboplatin,Paclitaxel 1 . .
Afatinib,Carboplatin,Paclitaxel Protein-Bound 1 . .

 

Astounding
PROC Star

There's another good reason that SAS can't find the string ... it isn't there. Character strings in SAS are case-sensitive.  So you should be checking:

 

if index(lowcase(test), 'paclitaxel')  then pre_TAXANE = 1 ;

 

The IF condition will be true for values that are neither 0 nor missing.

 

***************** EDITED:

 

@Reeza you're right.  My bad.  LOWCASE is already built into the logic.  Where's that coffee?

Reeza
Super User

@Astounding doesn't the previous statement lowcase everything?

 

@Ivy review the modifiers so that you can avoid listing all the alphabet in your list. I think its 'ka' to keep all alphabetic values. 

Ivy
Quartz | Level 8 Ivy
Quartz | Level 8

Thank you both very much for the quick response!

 

It is a bless that your guys here. 🙂 

 

Have a great day !

Ivy
Quartz | Level 8 Ivy
Quartz | Level 8
I would like to keep all alphabetic and "," , hope this is a way. Thank you again !
Reeza
Super User

Coffee? I'm about to go to bed and I'm on the West Coast 😄

 

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
  • 6 replies
  • 1134 views
  • 2 likes
  • 3 in conversation