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

Hi,

 

I cannot figure out why this code is not returning antibiotics = 1 for the comment that has antibiotics in it.

 

Code below:

-----------------------

Libname Review'/folders/myfolders/Review' ;
Libname Learn'/folders/myfolders/Learn' ;  
Libname myformat'/folders/myfolders/sasuser.v94' ; 
Options fmtsearch=(myformat) ;

Data review.antibiotics ; 

Set learn.Medical ; If FindW(Comment,'antibiotics','i') then antibiotics = 1 ; run ; proc print data=learn.medical noobs ; run ; proc print data=review.antibiotics noobs ; run ;

 Below are the results

Patno 	Clinic 	VisitDate 	Weight 	HR 	DX 	Comment 	antibiotics
001 	Mayo Clinic 	10/21/2006 	120 	78 	7 	Patient has had a persistent cough for 3 weeks 	.
003 	HMC 	09/01/2006 	166 	58 	8 	Patient placed on beta-blockers on 7/1/2006 	.
002 	Mayo Clinic 	10/01/2006 	210 	68 	9 	Patient has been on antibiotics for 10 days 	/*WHY ANTIBIOTICS = . NOT = 1?*/
004 	HMC 	11/11/2006 	288 	88 	9 	Patient advised to lose some weight 	.
007 	Mayo Clinic 	05/01/2006 	180 	54 	7 	This patient is always under high stress 	.
050 	HMC 	07/06/2006 	199 	60 	123 	Refer this patient to mental health for evaluation 	
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

I gave you the right syntax earlier. here again

 

If FindW(Comment,'antibiotics',' ','i') then antibiotics = 1 ; 

View solution in original post

7 REPLIES 7
novinosrin
Tourmaline | Level 20

because 'i' is in place of delimiter specification in your code rather than in place of modifier to ignore case sensitivity

 

This will work Findw(comment,'antibiotics')

 

or Findw(k,'antibiotics',' ','i');

ManitobaMoose
Quartz | Level 8

Ok. Thanks. Then, where would I put the 'i' ignore case modifier?

novinosrin
Tourmaline | Level 20
If FindW(Comment,'antibiotics',' ','i') then antibiotics = 1 ; 
Reeza
Super User

Or:

 

Findw(comment,'antibiotics', , 'i')

http://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p16rdsa30vmm43n1ej4936nwa01t.htm&...

 

FINDW(stringwordcharacter(s)modifier(s) <, start-position>)

 

modifier

specifies a character constant, variable, or expression in which each non-blank character modifies the action of the FINDW function.

Tip
If you use the modifier argument, then it must be positioned after the character argument.
ManitobaMoose
Quartz | Level 8

Hi,

 

I am still getting the same results with the code below:

 

Data review.antibiotics ; 
	Set learn.Medical ; 
	If Findw(Comment,'antibiotics', ,'i') then antibiotics = 1 ; /*output review.antibiotics*/ ;  
run ; 

proc print data=learn.medical noobs ; 
run ; 
proc print data=review.antibiotics noobs ; 
run ;

Patno Clinic VisitDate Weight HR DX Comment antibiotics

001Mayo Clinic10/21/2006120787Patient has had a persistent cough for 3 weeks.
003HMC09/01/2006166588Patient placed on beta-blockers on 7/1/2006.
002Mayo Clinic10/01/2006210689Patient has been on antibiotics for 10 days.
004HMC11/11/2006288889Patient advised to lose some weight.
007Mayo Clinic05/01/2006180547This patient is always under high stress.
050HMC07/06/200619960123Refer this patient to mental health for evaluation.
novinosrin
Tourmaline | Level 20

I gave you the right syntax earlier. here again

 

If FindW(Comment,'antibiotics',' ','i') then antibiotics = 1 ; 
ManitobaMoose
Quartz | Level 8

Thanks!

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 4147 views
  • 2 likes
  • 3 in conversation