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
I gave you the right syntax earlier. here again
If FindW(Comment,'antibiotics',' ','i') then antibiotics = 1 ;
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');
Ok. Thanks. Then, where would I put the 'i' ignore case modifier?
If FindW(Comment,'antibiotics',' ','i') then antibiotics = 1 ;
Or:
Findw(comment,'antibiotics', , 'i')
FINDW(string, word, character(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.
TipIf you use the modifier argument, then it must be positioned after the character argument.
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
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 | . |
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 | . |
I gave you the right syntax earlier. here again
If FindW(Comment,'antibiotics',' ','i') then antibiotics = 1 ;
Thanks!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.