/* 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 31 different Elixhauser Comorbdity (ELX) groups. The groups are identified by using the 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\_elixhauserICD9med.sas */ %macro _ElixhauserICD9med (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 Elixhauser 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 ELX group counters, initialize to 0 */ array ELX_GRP{*} ELX_GRP_1 - ELX_GRP_31; do i = 1 to dim(ELX_GRP); ELX_GRP{i} = 0; end; /* check for diagnoses in all 31 groups */ ELX_GRP_1 = (_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 ELX_GRP_1 = 'Congestive Heart Failure'; ELX_GRP_2 = (_dx3 in ('426','427')) | (_dx5 in: ('4260','42613','4267','4269','42610','42612', '4270','4271','4272','4273','4274','4276','4278', '4279','7850','99601','99604','V450','V533')); LABEL ELX_GRP_2 = 'Cardiac Arrhythmia'; ELX_GRP_3 = (_dx3 in ('394','395','396','397','424','746')) | (_dx5 in: ('0932','394','395','396','397','424','7463', '7464','7465','7466','V422','V433')); LABEL ELX_GRP_3 = 'Valvular Disease'; ELX_GRP_4 = (_dx3 in ('415','416','417')) | (_dx5 in: ('4150','4151','416','4170','4178','4179')); LABEL ELX_GRP_4 = 'Pulmonary Circulation Disorders'; ELX_GRP_5 = (_dx3 in ('440','441','443','447','557')) | (_dx5 in: ('0930','4373','440','441','4431','4432','4438', '4439','4471','5571','5579','V434')); LABEL ELX_GRP_5 = 'Peripheral Vascular Disorders'; ELX_GRP_6 = (_dx3 = '401') | (_dx5 =: '401'); LABEL ELX_GRP_6 = 'Hypertension Uncomplicated'; ELX_GRP_7 = (_dx3 in ('402','403','404','405')) | (_dx5 in: ('402','403','404','405')); LABEL ELX_GRP_7 = 'Hypertension Complicated'; ELX_GRP_8 = (_dx3 in ('334','342','343','344')) | (_dx5 in: ('3341','342','343','3440','3441','3442','3443', '3444','3445','3446','3449')); LABEL ELX_GRP_8 = 'Paralysis'; ELX_GRP_9 = (_dx3 in ('331','332','333','334','335','336','340','341', '345','348')) | (_dx5 in: ('3319','3320','3321','3334','3335','33392','334', '335','3362','340', '341','345','3481','3483','7803','7843')); LABEL ELX_GRP_9 = 'Other Neurological Disorders'; ELX_GRP_10 = (_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 ELX_GRP_10 = 'Chronic Pulmonary Disease'; ELX_GRP_11 = (_dx3='250') | (_dx5 in: ('2500','2501','2502','2503')); LABEL ELX_GRP_11 = 'Diabetes Uncomplicated'; *** 3-digit codes overlap with # 11; ELX_GRP_12 = (_dx5 in: ('2504','2505','2506','2507','2508','2509')); LABEL ELX_GRP_12 = 'Diabetes Complicated'; ELX_GRP_13 = (_dx3 in ('240','243','244','246')) | (_dx5 in: ('2409','243','244','2461','2468')); LABEL ELX_GRP_13 = 'Hypothyroidism'; ELX_GRP_14 = (_dx3 in ('403','585','586','588','V56')) | (_dx5 in: ('40301','40311','40391','40402','40403','40412', '40413','40492','40493','585', '586','5880','V420','V451','V56')); LABEL ELX_GRP_14 = 'Renal Failure'; ELX_GRP_15 = (_dx3 in ('070','456','570','571','572','573')) | (_dx5 in: ('07022','07023','07032','07033','07044','07054', '0706','0709','4560','4561', '4562','570','571','5722','5723','5724','5728', '5733','5734','5738','5739','V427')); LABEL ELX_GRP_15 = 'Liver Disease'; ELX_GRP_16 = (_dx3 in ('531','532','533','534')) | (_dx5 in: ('5317','5319','5327','5329','5337','5339', '5347','5349')); LABEL ELX_GRP_16 = 'Peptic Ulcer Disease excluding bleeding'; ELX_GRP_17 = (_dx3 in ('042','043','044')) | (_dx5 in: ('042','043','044')); LABEL ELX_GRP_17 = 'AIDS/HIV'; ELX_GRP_18 = (_dx3 in ('200','201','202','203')) | (_dx5 in: ('200','201','202','2030','2386')); LABEL ELX_GRP_18 = 'Lymphoma'; ELX_GRP_19 = (_dx3 in ('196','197','198','199')) | (_dx5 in: ('196','197','198','199')); LABEL ELX_GRP_19 = 'Metastatic Cancer'; ELX_GRP_20 = (_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','166','167','168','169', '170','171','172','174','175','176','177','178','179','180', '181','182','183','184','185','186','187','188','189','190', '191','192','193','194','195')) | (_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','166','167','168','169','170','171', '172','174','175','176','177','178','179','180', '181','182','183','184','185','186','187','188', '189','190','191','192','193','194','195')); LABEL ELX_GRP_20 = 'Solid Tumor without Metastasis'; ELX_GRP_21 = (_dx3 in ('446','701','710','711','714','719','720','725', '728')) | (_dx5 in: ('446','7010','7100','7101','7102','7103','7104', '7108','7109','7112','714','7193','720','725', '7285','72889','72930')); LABEL ELX_GRP_21 = 'Rheumatoid Arthritis/Collagen'; ELX_GRP_22 = (_dx3 in ('286','287')) | (_dx5 in: ('286','2871','2873','2874','2875')); LABEL ELX_GRP_22 = 'Coagulopathy'; ELX_GRP_23 = (_dx3='278') | (_dx5 =: '2780'); LABEL ELX_GRP_23 = 'Obesity'; ELX_GRP_24 = (_dx3 in ('260','261','262','263')) | (_dx5 in: ('260','261','262','263','7832','7994')); LABEL ELX_GRP_24 = 'Weight Loss'; ELX_GRP_25 = (_dx3='276') | (_dx5 in: ('2536','276')); LABEL ELX_GRP_25 = 'Fluid and Electrolyte Disorders'; *** 3-digit codes overlap with # 27; ELX_GRP_26 = (_dx5 =: '2800'); LABEL ELX_GRP_26 = 'Blood Loss Anemia'; ELX_GRP_27 = (_dx3 in ('280','281')) | (_dx5 in: ('2801','2808','2809','281')); LABEL ELX_GRP_27 = 'Deficiency Anemia'; ELX_GRP_28 = (_dx3 in ('291','303','980')) | (_dx5 in: ('2652','2911','2912','2913','2915','2918', '2919','3030','3039','3050','3575','4255', '5353','5710','5711','5712','5713','980','V113')); LABEL ELX_GRP_28 = 'Alcohol Abuse'; ELX_GRP_29 = (_dx3 in ('292','304','305')) | (_dx5 in: ('292','304','3052','3053','3054','3055','3056', '3057','3058','3059','V6542')); LABEL ELX_GRP_29 = 'Drug Abuse'; ELX_GRP_30 = (_dx3 in ('293','295','297','298')) | (_dx5 in: ('2938','295','29604','29614','29644','29654', '297','298')); LABEL ELX_GRP_30 = 'Psychoses'; ELX_GRP_31 = (_dx3 in ('296','300','309','311')) | (_dx5 in: ('2962','2963','2965','3004','309','311')); LABEL ELX_GRP_31 = 'Depression'; TOT_GRP = sum(of ELX_GRP_1-ELX_GRP_31); LABEL TOT_GRP ='Total Elixhauser 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: _ElixhauserICD9med 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 _ElixhauserICD9med; /************ 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 *; %_ElixhauserICD9med(DATA =med, OUT =ELX_groups, dx3 =diag, dx5 =diag_icd5, dxstrict=on, dxonly =on); **************************************************; * Analysis Section of program *; **************************************************; PROC FREQ data=ELX_groups; TITLE1 "Elixhauser Comorbidity Groups in Medical Services Claims"; TITLE2 "Using Enhanced ICD-9-CM Coding"; TABLES ELX_GRP: TOT_GRP; RUN; ****/