05-03-2018 06:22 PM
I cannot figure out why this code is not returning antibiotics = 1 for the comment that has antibiotics in it.
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
05-03-2018 06:31 PM - edited 05-03-2018 06:32 PM
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');
05-03-2018 06:34 PM
Findw(comment,'antibiotics', , 'i')
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.
05-03-2018 06:40 PM
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||.|
Need further help from the community? Please ask a new question.