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
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.
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.
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.
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..
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.