I have a list of over 200 ICD-10 codes and was recommended to use the substr function in SAS to capture all of them ex format. S020XXA and S020XXB
I have seen examples where the substr function helps flag the first few characters but how do I use this function to also include the "A" and "B" at the end of my ICD-10 code? I have included some of the icd10 codes needed here for reference:
S02101A  | 
S02101B  | 
S02102A  | 
S02102B  | 
S02109A  | 
S02109B  | 
S0210XA  | 
S0210XB  | 
S02110A  | 
S02110B  | 
S02111A  | 
S02111B  | 
S02112A  | 
S02112B  | 
S02113A  | 
S02113B  | 
S02118A  | 
Here's an example of using SUBSTR to also check for "A" or "B" as the last character:
if /* some conditions */ and substr(icd10, length(icd10) in "A", "B");
Since you're specifically asking about the last character, I omitted any logic that would check the earlier characters.
Here's an example of using SUBSTR to also check for "A" or "B" as the last character:
if /* some conditions */ and substr(icd10, length(icd10) in "A", "B");
Since you're specifically asking about the last character, I omitted any logic that would check the earlier characters.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.