I have a dataset as follows:
Client ID Icd10CodeOne Icd10CodeOneCategory Icd10CodeTwo Icd10CodeTwoCategory Icd10CodeThree Icd10CodeThreeCategory
5679 37 2 10 3 56 1
5289 15 3 2 1 61 2
5620 18 3 28 1 15 2
5417 62 2 29 1 - -
5197 25 1 18 2 10 3
Icd10codeOne, Icd10codeTwo, and Icd10codeThree all have the same values. For instance if Icd10codeOne = 15 where 15 is 'borderline personality disorder', this would be the same diagnosis for Icd10codeThree = 15.
The same goes for Icd10CodeOneCategory, Icd10CodeTwoCategory, and Icd10CodeThreeCategory. There are only three categories: Primary, Secondary, and Tertiary. Only one diagnosis (Icd10code) can be primary, only one can be secondary, and only one can be tertiary.
Is there a way to combine these to where I only have ICD10Code and ICD10CodeCategory? Or at least one of them? Or would that not even be helpful to me? I guess I am trying to figure out how to analyze this when primary diagnoses could be in 3 different columns. Any advice or guidance is welcome.
Hi @jogden
I think it would be better for your analysis to transform data from wide format to long format. It works better with sas procedures. Here is code.
By the way - it would be easier to answer your question, if you provided input as code to create a data set, because half of the time used for answering goes into creation of test data. See my input step in the code below.
data have;
input ClientID Icd10CodeOne Icd10CodeOneCategory Icd10CodeTwo Icd10CodeTwoCategory
Icd10CodeThree Icd10CodeThreeCategory;
cards;
5679 37 2 10 3 56 1
5289 15 3 2 1 61 2
5620 18 3 28 1 15 2
5417 62 2 29 1 . .
5197 25 1 18 2 10 3
;
run;
data want(keep=ClientID lcdCode IcdCategory); set have;
array cat Icd10CodeOneCategory Icd10CodeTwoCategory Icd10CodeThreeCategory;
array code Icd10CodeOne Icd10CodeTwo Icd10CodeThree;
do i = 1 to 3;
IcdCategory = cat[i];
lcdCode = code[i];
if IcdCategory ne . then output;
end;
run;
result:
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: