You've got some good recommendations already.
You could also add a PUT statement to show the values of ICD10Code and Mic. If the PUT statement does not execute, that means you don't actually have the value T21.06XA in your data (maybe there are leading spaces, or capitalization issues, or... )
data want ;
set have ;
IF substr(ICD10Code,1,3)="T21" & substr(ICD10Code,8,1) in ("A", "B", "C") THEN MIC=1;
IF ICD10Code="T21.06XA" then put ICD10Code= Mic= ;
run ;
And of course it always helps to look at your data:
proc freq data=have ;
tables ICD10Code*Mic/missing list ;
format _all_ ;
run ;
The IF statement you posted works, so it's likely that the value of ICD10Code is not matching your expectation.
1 data have ;
2 ICD10Code="T21.06XA" ;
3 run ;
NOTE: The data set WORK.HAVE has 1 observations and 1 variables.
4
5 data want ;
6 set have ;
7 IF substr(ICD10Code,1,3)="T21" & substr(ICD10Code,8,1) in ("A", "B", "C") THEN MIC=1;
8 IF ICD10Code="T21.06XA" then put ICD10Code= Mic= ;
9 run ;
ICD10Code=T21.06XA MIC=1
NOTE: There were 1 observations read from the data set WORK.HAVE.
NOTE: The data set WORK.WANT has 1 observations and 2 variables.
... View more