BookmarkSubscribeRSS Feed
rosegarden81
Obsidian | Level 7

Hello all,

 

I have a SAS data set with a variable 'ICD10' which looks like this 

 

ICD10

A00.0- A00.8

A01.00 - A01.2

 

 

I want to convert this file to 

 

ICD10_newvar

A00.0

A00.1

A00.2

A00.3

A00.4

A00.5

A00.6

A00.7

A00.8

A01.00

A01.01

A01.02

A01.03

.

.

A01.18

A01.19

A01.2

 

So basically converting the range to individual ICD codes..

 

Any guidance on this would be highly appreciated! 

 

Regards,

 

Tina

 

 

 

 

6 REPLIES 6
ballardw
Super User

Your desired list may be incomplete:

 

 A00 Cholera 
A00.0 Cholera due to Vibrio cholerae 01, biovar cholerae
A00.1 Cholera due to Vibrio cholerae 01, biovar eltor
A00.9 Cholera, unspecified

Since so many ICD-10 codes have sub-codes you need to describe how many levels you may need.

I would say you might be better off starting with a very complete data set of codes and extracting them.

rosegarden81
Obsidian | Level 7

So if I want to still convert it this way as I was mentioning before, this is my progress on the code

 

data want1;

set have;

test= substr(ICD10,1,3);  /* eg. A00 */

test1= scan(ICD10,1,'-'); 

test1_1 = SCAN( test1, 2, '.') ; /* eg., 0 */

test2 = scan(ICD10 ,2,'-');   

test2_1 = SCAN( test2, 2, '.') ; /* eg., 9 */

run;

 

data want2;

set want1;

do i = test1_1 to test2_1;

testvar = catt(test, ".", i );

output;

end;

run;

 

What am I doing wrong here? If I just manually substitute Test1_1 = 1 and test2_1 with 9 and rerun the want2 datastep, then I get some resutls (which is obviously not right for all codes but converts correctly for first row in original file).

 

I need some tips on what I may be doing wrong in this code instead of suggestions on alternate solutions. 

 

Reeza
Super User
I would recommend downloading the list from CMS, importing it and then merging your categories the main list. The codes don't always behave the way you to want to.

https://www.cms.gov/Medicare/Coding/ICD10/2018-ICD-10-CM-and-GEMs.html
rosegarden81
Obsidian | Level 7

I already have the list of codes in range format that has been sent to me. So I am good there. I just need some help on the code I have written. 

Reeza
Super User
Why not merge with your full list then using SQL?
Split your range into a start and stop and then your join could be something like:
on icd_start < icd_code < icd_end

I feel like the rules building would be painful for ICD list.
rosegarden81
Obsidian | Level 7

I think we discussed it here and we are going to keep it as range format and use =: etc while analysing the data...so I am good now...thank you guys and sorry for the confusion..

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 6 replies
  • 2027 views
  • 4 likes
  • 3 in conversation