****************************************************************************************; * Program: combined_comorbidity_score_code.sas ; * ; * Purpose: To compute combined comorbidity scores based on ICD-9 codes ; * ; * Description: This code takes in a list of ICD-9 codes for ; * ; * Citation: Gagne JJ, Glynn RJ, Avorn J, Levin R, Schneeweiss S. A combined ; * comorbidity score predicted mortality in elderly patients better ; * than existing scores. Journal of Clinical Epidemiology 2011 Jan ; * 3 [Epub ahead of print] ; * ; * Definitions: datain = input datset ; * ICD9variable = ICD-9 codes ; * ; * Comments: After merging the final data file (combinedcomorbidityscore) with ; * the analytic data file, patients with missing combined comorbidity ; * score values (i.e. combinedscore = .) should be set to 0 as these ; * patients did not have any of the component conditions. ; * ; ****************************************************************************************; data conditions; set datain(rename=(ICD9variable = ICD)); length disease $25; disease = 'nopoints'; if substr(ICD,1,3) = '196' or substr(ICD,1,3) = '197' or substr(ICD,1,3) = '198' or substr(ICD,1,3) = '199' then disease = 'metastatic_romano'; if ICD = '40201' or ICD = '40211' or ICD = '40291' or substr(ICD,1,4) = '4293' or substr(ICD,1,3) = '425' or substr(ICD,1,3) = '428' then disease = 'chf_romano'; if substr(ICD,1,4) = '3310' or substr(ICD,1,4) = '3311' or substr(ICD,1,4) = '3312' or substr(ICD,1,3) = '290' then disease = 'dementia_romano'; if ICD = '40311' or ICD = '40391' or ICD = '40412' or ICD = '40492' or substr(ICD,1,3) = '585' or substr(ICD,1,3) = '586' or substr(ICD,1,4) = 'V420' or substr(ICD,1,4) = 'V451' or substr(ICD,1,4) = 'V560' or substr(ICD,1,4) = 'V568' then disease = 'renal_elixhauser'; if '260' <= substr(ICD,1,3) <= '263' then disease = 'wtloss_elixhauser'; if substr(ICD,1,3) = '342' or substr(ICD,1,3) = '344' then disease = 'hemiplegia_romano'; if substr(ICD,1,4) = '2911' or substr(ICD,1,4) = '2912' or substr(ICD,1,4) = '2915' or substr(ICD,1,4) = '2918' or substr(ICD,1,4) = '2919' or '30390' <= ICD <= '30393' or '30500' <= ICD <= '30503' or substr(ICD,1,4) = 'V113' then disease = 'alcohol_elixhauser'; if '140' <= substr(ICD,1,3) <= '171' or '174' <= substr(ICD,1,3) <= '195' or substr(ICD,1,4) = '2730' or substr(ICD,1,4) = '2733' or substr(ICD,1,5) = 'V1046' or '200' <= substr(ICD,1,3) <= '208' then disease = 'tumor_romano'; if ICD = '42610' or ICD = '42611' or ICD = '42613' or '4262' <= substr(ICD,1,4) <= '4264' or '42650' <= ICD <= '42653' or '4266' <= substr(ICD,1,4) <= '4268' or substr(ICD,1,4) = '4270' or substr(ICD,1,4) = '4272' or ICD = '42731' or ICD = '42760' or substr(ICD,1,4) = '4279' or substr(ICD,1,4) = '7850' or substr(ICD,1,4) = 'V450' or substr(ICD,1,4) = 'V533' then disease = 'arrhythmia_elixhauser'; if substr(ICD,1,4) = '4150' or substr(ICD,1,4) = '4168' or substr(ICD,1,4) = '4169' or substr(ICD,1,3) = '491' or substr(ICD,1,3) = '492' or substr(ICD,1,3) = '493' or substr(ICD,1,3) = '494' or substr(ICD,1,3) = '496' then disease = 'pulmonarydz_romano'; if '2860' <= substr(ICD,1,4) <= '2869' or substr(ICD,1,4) = '2871' or '2873' <= substr(ICD,1,4) <= '2875' then disease = 'coagulopathy_elixhauser'; if '25040' <= ICD <= '25073' or '25090' <= ICD <= '25093' then disease = 'compdiabetes_elixhauser'; if '2801' <= substr(ICD,1,4) <= '2819' or substr(ICD,1,4) = '2859' then disease = 'anemia_elixhauser'; if '2760' <= substr(ICD,1,4) <= '2769' then disease = 'electrolytes_elixhauser'; if ICD = '07032' or ICD = '07033' or ICD = '07054' or substr(ICD,1,4) = '4560' or substr(ICD,1,4) = '4561' or ICD = '45620' or ICD = '45621' or substr(ICD,1,4) = '5710' or substr(ICD,1,4) = '5712' or substr(ICD,1,4) = '5713' or '57140' <= ICD <= '57149' or substr(ICD,1,4) = '5715' or substr(ICD,1,4) = '5716' or substr(ICD,1,4) = '5718' or substr(ICD,1,4) = '5719' or substr(ICD,1,4) = '5723' or substr(ICD,1,4) = '5728' or substr(ICD,1,4) = 'V427' then disease = 'liver_elixhauser'; if '4400' <= substr(ICD,1,4) <= '4409' or substr(ICD,1,4) = '4412' or substr(ICD,1,4) = '4414' or substr(ICD,1,4) = '4417' or substr(ICD,1,4) = '4419' or '4431' <= substr(ICD,1,4) <= '4439' or substr(ICD,1,4) = '4471' or substr(ICD,1,4) = '5571' or substr(ICD,1,4) = '5579' or substr(ICD,1,4) = 'V434' then disease = 'pvd_elixhauser'; if '29500' <= ICD <= '29899' or ICD = '29910' or ICD = '29911' then disease = 'psychosis_elixhauser'; if substr(ICD,1,3) = '416' or substr(ICD,1,4) = '4179' then disease = 'pulmcirc_elixhauser'; if substr(ICD,1,3) = '042' or substr(ICD,1,3) = '043' or substr(ICD,1,3) = '044' then disease = 'hivaids_romano'; if substr(ICD,1,4) = '4011' or substr(ICD,1,4) = '4019' or ICD = '40210' or ICD = '40290' or ICD = '40410' or ICD = '40490' or ICD = '40511' or ICD = '40519' or ICD = '40591' or ICD = '40599' then disease = 'hypertension_elixhauser'; if disease ^= 'nopoints'; run; proc sort nodupkey data = conditions; by uniqueidentifier disease; run; *Applying the weights; data conditionweights; set conditions; weight = 0; if disease = 'metastatic_romano' then weight = 5; if disease = 'chf_romano' then weight = 2; if disease = 'dementia_romano' then weight = 2; if disease = 'renal_elixhauser' then weight = 2; if disease = 'wtloss_elixhauser' then weight = 2; if disease = 'hemiplegia_romano' then weight = 1; if disease = 'alcohol_elixhauser' then weight = 1; if disease = 'tumor_romano' then weight = 1; if disease = 'arrhythmia_elixhauser' then weight = 1; if disease = 'pulmonarydz_romano' then weight = 1; if disease = 'coagulopathy_elixhauser' then weight = 1; if disease = 'compdiabetes_elixhauser' then weight = 1; if disease = 'anemia_elixhauser' then weight = 1; if disease = 'electrolytes_elixhauser' then weight = 1; if disease = 'liver_elixhauser' then weight = 1; if disease = 'pvd_elixhauser' then weight = 1; if disease = 'psychosis_elixhauser' then weight = 1; if disease = 'pulmcirc_elixhauser' then weight = 1; if disease = 'hivaids_romano' then weight = -1; if disease = 'hypertension_elixhauser' then weight = -1; keep uniqueidentifier disease weight; run; *Summing the weights; data combinedcomorbidityscore; set conditionweights(keep = uniqueidentifier weight); by uniqueidentifier; if first.uniqueidentifier then combinedscore = 0; combinedscore + weight; if last.uniqueidentifier then output; keep uniqueidentifier combinedscore; run; *Note: patients not included in the final data set (combinedcomorbidityscore) did not have any of the component conditions. Therefore, be sure to set their combined comorbidity score values to zero;