*** This SAS code generates an overall (longitudinal) Charlson Comorbidity Index score for an individual scrambled PHIN based on ALL episodes of care (hospitalizations and physician visits) over a specified period of time (usually one year), by collapsing the calculated individual Charlson Comorbidity Index scores into one record per person. A prerequisite to running this SAS code is creating the output file(s) from the SAS Charlson macro(s)/code for the Hospital and Medical Claims data, and using them as input files for this program. The SAS macro/code choice(s) depend on the scope/time frame of your study. In this SAS code example, three input files are used in the first DATA step ... charlson9, charlson10 and med_char. DATE: November 6, 2014 AUTHOR: Heather Prior ***** ; *** summarize the comorbidity groups per person over all hospitalizations & physician visits in the time period; data charlson; set charlson9 charlson10 med_char (keep=scrphin cc_grp_1-cc_grp_17); by scrphin; retain ccgrp1 ccgrp2 ccgrp3 ccgrp4 ccgrp5 ccgrp6 ccgrp7 ccgrp8 ccgrp9 ccgrp10 ccgrp11 ccgrp12 ccgrp13 ccgrp14 ccgrp15 ccgrp16 ccgrp17; if first.scrphin then do; ccgrp1=0; ccgrp2=0; ccgrp3=0; ccgrp4=0; ccgrp5=0; ccgrp6=0; ccgrp7=0; ccgrp8=0; ccgrp9=0; ccgrp10=0; ccgrp11=0; ccgrp12=0; ccgrp13=0; ccgrp14=0; ccgrp15=0; ccgrp16=0; ccgrp17=0; end; *** these are the original comorbidity variables generated from each hospital separation or physician claim; array hsp{17} cc_grp_1 cc_grp_2 cc_grp_3 cc_grp_4 cc_grp_5 cc_grp_6 cc_grp_7 cc_grp_8 cc_grp_9 cc_grp_10 cc_grp_11 cc_grp_12 cc_grp_13 cc_grp_14 cc_grp_15 cc_grp_16 cc_grp_17; *** these are the summary comorbidity values over all claims; array tot{17} ccgrp1 ccgrp2 ccgrp3 ccgrp4 ccgrp5 ccgrp6 ccgrp7 ccgrp8 ccgrp9 ccgrp10 ccgrp11 ccgrp12 ccgrp13 ccgrp14 ccgrp15 ccgrp16 ccgrp17; do i = 1 to 17; if hsp{i} = 1 then tot{i} = 1; end; if last.scrphin then do; totalcc = sum(of ccgrp1-ccgrp17); *** use Charlson weights to calculate a weighted score; wgtcc = sum(of ccgrp1-ccgrp10) + ccgrp11*2 + ccgrp12*2 + ccgrp13*2 + ccgrp14*2 + ccgrp15*3 + ccgrp16*6 + ccgrp17*6; output; end; label ccgrp1 = 'Charlson Comorbidity Group 1: Myocardial Infarction' ccgrp2 = 'Charlson Comorbidity Group 2: Congestive Heart Failure' ccgrp3 = 'Charlson Comorbidity Group 3: Peripheral Vascular Disease' ccgrp4 = 'Charlson Comorbidity Group 4: Cerebrovascular Disease' ccgrp5 = 'Charlson Comorbidity Group 5: Dementia' ccgrp6 = 'Charlson Comorbidity Group 6: Chronic Pulmonary Disease' ccgrp7 = 'Charlson Comorbidity Group 7: Connective Tissue Disease-Rheumatic Disease' ccgrp8 = 'Charlson Comorbidity Group 8: Peptic Ulcer Disease' ccgrp9 = 'Charlson Comorbidity Group 9: Mild Liver Disease' ccgrp10 = 'Charlson Comorbidity Group 10: Diabetes without complications' ccgrp11 = 'Charlson Comorbidity Group 11: Diabetes with complications' ccgrp12 = 'Charlson Comorbidity Group 12: Paraplegia and Hemiplegia' ccgrp13 = 'Charlson Comorbidity Group 13: Renal Disease' ccgrp14 = 'Charlson Comorbidity Group 14: Cancer' ccgrp15 = 'Charlson Comorbidity Group 15: Moderate or Severe Liver Disease' ccgrp16 = 'Charlson Comorbidity Group 16: Metastatic Carcinoma' ccgrp17 = 'Charlson Comorbidity Group 17: HIV/AIDS' totalcc = 'Sum of 17 Charlson Comorbidity Groups' wgtcc = 'Weighted Sum of 17 Charlson Comorbidity Groups' ccwgtgrp = 'Category of Weighted Sum of 17 Charlson Comorbidity Groups'; keep scrphin totalcc wgtcc ccwgtgrp ccgrp1 ccgrp2 ccgrp3 ccgrp4 ccgrp5 ccgrp6 ccgrp7 ccgrp8 ccgrp9 ccgrp10 ccgrp11 ccgrp12 ccgrp13 ccgrp14 ccgrp15 ccgrp16 ccgrp17; run;