/* This is the Charlson Comorbidity Index macro code using ICD-9-CM codes in medical claims. This program reads through the diagnosis codes in medical claims records in medical services data and identifies whether the record belongs to one (or more) of 17 different Charlson Comorbidity Index (CCI) groups. The groups are identified by using the Enhanced ICD-9-CM diagnosis codes listed in Quan et al., "Coding Algorithms for Defining Comorbidities in ICD-9-CM and ICD-10 Administrative Data", Medical Care:43(11), Nov. 2005 p1130-1139. The original SAS code for this program was developed by Hude Quan's group at the U of C in Calgary, and modified to work with MCHP data. This code was adapted at MCHP to work with the limited 3-digit ICD-9-CM diagnosis codes in Manitoba medical claims. The diagnosis codes match on either 3, 4 or 5 digits, as described in the article. Diagnosis codes are checked with the IN: statement at the 3, 4, or 5 digit level. There is a dxstrict option to do strict 4 or 5 digit matching when the more precise codes are available. By default, 3 digit matches are sufficient. Note that setting dxstrict to on will cause a drop in diagnosis counts in several comorbidity groups starting in 2018, as the 5-digit ICD-9 codes were introduced in medical claims in fiscal year 2018. It is best to use this option only when all claims examined begin no earlier than 01apr2018, to avoid an artefactual drop in counts when comparing years with and without 5-digit codes. To help reduce the number of records kept, which can be a lot when dealing with medical claims, by default the macro only keeps records with matching diagnoses. There is a dxonly option to turn off this feature. Date: January 30, 2023 Author: Gilles Detillieux File Name: S:\support\maclib\_charlsonICD9med.sas */ %macro _CharlsonICD9med (data =, /* input data set */ out =, /* output data set */ dx3 =diag, /* 3-digit diagnosis variable */ dx5 =diag_icd5, /* 4 or 5-digit dx variable */ dxstrict=off, /* strict match of 4-5 digit dx */ dxonly =on, /* only keep records with matching dx */ debug = off) ; %put Charlson Comorbidity Index Macro - ICD9CM Codes in Medical Claims ; %put Manitoba Centre for Health Policy, Based on Code from Hude Quan University of Calgary ; %put Quan et al., Coding Algorithms for Defining Comorbidities ; %put in ICD-9-CM and ICD-10 Administrative Data, Medical Care:43(11), Nov. 2005 p1130-1139 ; %put Version 1.0 January 30, 2023 ; %* put default options into &opts variable ; %let opts=%sysfunc(getoption(mprint,)) %sysfunc(getoption(notes,)) ; %if &debug=1 | %lowcase(&debug)=debug | %lowcase(&debug)=on %then %do ; options mprint notes ; %end ; %else %do ; options nomprint nonotes ; %end ; %* Check if previous data step, or procdure had an error and stop running the macro. This assumes that the previous step is used in the macro.; %if %eval(&SYSERR>0) %then %goto out1 ; %* Check if input data exists ; %if &data= %str() %then %goto out2 ; %* if the output data set is not defined then define it as the input ; %if &out= %then %let out=&data ; %if %sysfunc(exist(&data)) ^= 1 %then %goto out3 ; data &out; set &data ; /* set up Dx code variables based on macro parameters */ length _dx3 $3 _dx5 $5; %if %length(dx3)>0 %then _dx3 = &dx3; ; %if %length(dx5)>0 %then _dx5 = &dx5; ; %if &dxstrict=1 | %lowcase(&dxstrict)=yes | %lowcase(&dxstrict)=on %then %do ; if length(_dx5) > 3 then _dx3 = ' '; else if _dx3 = ' ' & _dx5 ^= ' ' then _dx3 = _dx5; %end ; /* set up array for individual CCI group counters, initialize to 0 */ array CC_GRP{*} CC_GRP_1 - CC_GRP_17; do i = 1 to dim(CC_GRP); CC_GRP{i} = 0; end; /* check each set of diagnosis codes for each CCI group. */ CC_GRP_1 = (_dx3 in ('410','412')) | (_dx5 in: ('410','412')); LABEL CC_GRP_1 = 'Myocardial Infarction'; CC_GRP_2 = (_dx3 in ('398','402','425','428')) | (_dx5 in: ('39891','40201','40211','40291','40401','40403','40411','40413','40491','40493', '4254','4255','4257','4258','4259','428')); LABEL CC_GRP_2 = 'Congestive Heart Failure'; CC_GRP_3 = (_dx3 in ('440','441','443','447','557')) | (_dx5 in: ('0930','4373','440','441','4431','4432','4438','4439','4471','5571','5579','V434')); LABEL CC_GRP_3 = 'Peripheral Vascular Disease'; CC_GRP_4 = (_dx3 in ('430','431','432','433','434','435','436','437','438')) | (_dx5 in: ('36234','430','431','432','433','434','435','436','437','438')); LABEL CC_GRP_4 = 'Cerebrovascular Disease'; CC_GRP_5 = (_dx3 in ('290','294','331')) | (_dx5 in: ('290','2941','3312')); LABEL CC_GRP_5 = 'Dementia'; CC_GRP_6 = (_dx3 in ('416','490','491','492','493','494','495', '496','500','501','502','503','504','505')) | (_dx5 in: ('4168','4169','490','491','492','493','494','495','496','500', '501','502','503','504','505','5064','5081','5088')); LABEL CC_GRP_6 = 'Chronic Pulmonary Disease'; CC_GRP_7 = (_dx3 in ('446','710','714','725')) | (_dx5 in: ('4465','7100','7101','7102','7103','7104','7140','7141','7142','7148','725')); LABEL CC_GRP_7 = 'Connective Tissue Disease-Rheumatic Disease'; CC_GRP_8 = (_dx3 in ('531','532','533','534')) | (_dx5 in: ('531','532','533','534')); LABEL CC_GRP_8 = 'Peptic Ulcer Disease'; CC_GRP_9 = (_dx3 in ('070','570','571','573')) | (_dx5 in: ('07022','07023','07032','07033','07044','07054','0706','0709','570','571', '5733','5734','5738','5739','V427')); LABEL CC_GRP_9 = 'Mild Liver Disease'; CC_GRP_10 = (_dx3='250') | (_dx5 in: ('2500','2501','2502','2503','2508','2509')); LABEL CC_GRP_10 = 'Diabetes without complications'; *** 3-digit codes overlap with # 10; CC_GRP_11 = (_dx5 in: ('2504','2505','2506','2507')); LABEL CC_GRP_11 = 'Diabetes with complications'; CC_GRP_12 = (_dx3 in ('334','342','343','344')) | (_dx5 in: ('3341','342','343','3440','3441','3442','3443','3444','3445','3446','3449')); LABEL CC_GRP_12 = 'Paraplegia and Hemiplegia'; CC_GRP_13 = (_dx3 in ('403','582','583','585','586','588','V56')) | (_dx5 in: ('40301','40311','40391','40402','40403','40412','40413','40492','40493','582', '5830','5831','5832','5834','5836','5837','585','586','5880','V420','V451','V56')); LABEL CC_GRP_13 = 'Renal Disease'; CC_GRP_14 = (_dx3 in ('140','141','142','143','144','145','146','147','148','149', '150','151','152','153','154','155','156','157','158','159', '160','161','162','163','164','165','170','171','172','174', '175','176','179','180','181','182','183','184','185','186', '187','188','189','190','191','192','193','194','195','200', '201','202','203','204','205','206','207','208','238')) | (_dx5 in: ('140','141','142','143','144','145','146','147','148','149', '150','151','152','153','154','155','156','157','158','159', '160','161','162','163','164','165','170','171','172','174', '175','176','179','180','181','182','183','184','185','186', '187','188','189','190','191','192','193','194','195','200', '201','202','203','204','205','206','207','208','2386')); LABEL CC_GRP_14 = 'Cancer'; CC_GRP_15 = (_dx3 in ('456','572')) | (_dx5 in: ('4560','4561','4562','5722','5723','5724','5728')); LABEL CC_GRP_15 = 'Moderate or Severe Liver Disease'; CC_GRP_16 = (_dx3 in ('196','197','198','199')) | (_dx5 in: ('196','197','198','199')); LABEL CC_GRP_16 = 'Metastatic Carcinoma'; CC_GRP_17 = (_dx3 in ('042','043','044')) | (_dx5 in: ('042','043','044')); LABEL CC_GRP_17 = 'AIDS/HIV'; TOT_GRP = sum(of CC_GRP_1-CC_GRP_17); LABEL TOT_GRP ='Total CCI groups per record'; DROP _dx3 _dx5; /* handle dxonly macro parameters */ %if &dxonly=1 | %lowcase(&dxonly)=yes | %lowcase(&dxonly)=on %then %do ; IF TOT_GRP > 0; %end ; run; options notes ; %put ; %put NOTE: _Charlson Finished &out created ; %put ; %goto exit ; %out1: %put ERROR: Prior Step failed with an Error submit a null data step to correct ; %goto exit ; %out2: %put ERROR: Input Data Was Not Defined; %goto exit ; %out3: %put ERROR: Input Data &data does not exist ; %goto exit ; %exit: %**** Reset the SAS options ; options &opts ; %mend _CharlsonICD9med; /************** Example Program code *************** ; data med; set health.mhmed_1997apr (keep=scrphin acqdt servdt diag diagicd prefix tariff md refmd mdbloc nserv fee opd ngc mgc) health.mhmed_2018sep (keep=scrphin acqdt servdt diag diag_icd5 diagicd prefix tariff md_code refmd_code mdbloc nserv fee opd ngc mgc); where mod(scrphin,1e6) = 0 and prefix = '7' and "01apr2016"d <= servdt <= "31mar2021"d and diag ^in: (' ','A','B','C'); *** exclude missing & chiropractic diag; run; * macro call *; %_CharlsonICD9med(data =med, out =cci_groups, dx3 =diag, dx5 =diag_icd5, dxstrict =on, dxonly =on); ************************************; * Analysis Section of Program *; ************************************; PROC FREQ data=CCI_groups; TITLE1 "Charlson Comorbidity Groups in Medical Services Claims"; TITLE2 "Using Enhanced ICD-9-CM Coding"; TABLES CC_GRP: TOT_GRP; run; PROC PRINT data=CCI_groups (obs=10); run; ***/