BookmarkSubscribeRSS Feed
Ginny_Han
Calcite | Level 5

Dear all,

I am working on a project that involves generating the Elixhauser Comorbidity Index from a number of variables that contained ICD-10 codes. There are people who published a macro that generate the Index from the ICD-10 codes (http://mchp-appserv.cpe.umanitoba.ca/Upload/SAS/_ElixhauserICD10.sas.txt) but I'm working on a off-line server, which means I can only type codes in SAS but I cannot copy the macro file in the server. So what I am hoping is to borrow a series of codes from the macro and get it work on my dataset on the server.

The whole point of the Index is to search each of the diagnosis codes variable (in ICD-10), finding out if they have the ICD codes listed in 1 of 31 categories that the comorbidity index defined. It should generate 31 variables corresponding to each category in the index and each one of the 31 variables is binary, indicating whether, in the patient' so many diagnosis codes, have the codes listed in a particular index category. 

As I understand the macro can calculate the Index,  but I don't know how to convert the codes in the macro to, like codes I can run directly.

I now have a dataset with dx1 to dx10 and dxtyp1 to dxtyp10 as well as other variables. It would be great if someone can tell me how to convert the codes from the macro.

Please access the entire macro from http://mchp-appserv.cpe.umanitoba.ca/Upload/SAS/_ElixhauserICD10.sas.txt. I pasted some excerpts here to illustrate my point.

 

 

/*  skip diagnosis if diagnosis type = "2" */
         %if &type=on %then if DXTYP(i) ^= '2' then DO; ;   /* identify ELX group */

The dxtyp variables are to determine whether a dx should be called a comorbidity and entering the calculation. Each dx has a dxtyp.

/*  check each set of diagnoses codes for each ELX group. */
    do i = 1 to dim(dx) UNTIL (DX(i)=' ');   /* for each set of diagnoses codes */
    /*  skip diagnosis if diagnosis type = "2" */
         %if &type=on %then if DXTYP(i) ^= '2' then DO; ;   /* identify ELX group */
          /* Congestive Heart Failure */
          if  DX(i) IN:  ('I099','I110','I130','I132','I255','I420','I425','I426','I427','I428',
                          'I429','I43','I50','P290') then ELX_GRP_1 = 1;
            LABEL ELX_GRP_1 = 'Congestive Heart Failure';

I think this part here is the start of the loop " do i = 1 to dim(dx) UNTIL (DX(i)=' '); ". and "congestive heart failure" is the first category of the 31. If these codes  ('I099','I110','I130','I132','I255','I420','I425','I426','I427','I428','I429','I43','I50','P290') are found in any one of the 10 dx codes, ELX_GRP_1 would be changed to 1. There are 30 more categories to go doing similar thing.

          /*Depression*/
          if  DX(i) IN:  ('F204','F313','F314','F315','F32','F33','F341','F412','F432') then ELX_GRP_31 = 1;
            LABEL ELX_GRP_31 = 'Depression';
			%if &type=on %then  end; ;			
    end;

"Depression" is the last category and should be where the loop ended. I want my code to end here as well. I don't really need to add the 31 variables up, but I do need to generate the 31 variables from dx1-10 and dxtyp1-10.

 

Please illustrate how I can write the code to generate the index based on the macro. Thanks a lot!

 

Ginny Han

 

 

 

 

 

 

1 REPLY 1
Ginny_Han
Calcite | Level 5

Dear all,

Here is an update on what I've got so far:

 

data want;
set have;
array DX (10) dx1-dx10;
do i = 1 to dim(DX);
          if  DX(i) IN:  ('I099','I110','I130','I132','I255','I420','I425','I426','I427','I428',
                          'I429','I43','I50','P290') then ELX_GRP_1 = 1;else ELX_GRP_1 = 0;
            LABEL ELX_GRP_1 = 'Congestive Heart Failure';
end;
run;

The code above definitely had sth wrong because all the ELX_GRP_1=0 in all the observations in data "want“”. But I don't know where.

 

 

If I get rid of the loop, and write:

data want;
set have;
          if dx1 IN:  ('I099','I110','I130','I132','I255','I420','I425','I426','I427','I428',
                          'I429','I43','I50','P290') then ELX_GRP_1 = 1;else ELX_GRP_1 = 0;
            LABEL ELX_GRP_1 = 'Congestive Heart Failure';
run;

 

I would actually get some ELX_GRP_1=1 but that would be the result of searching in dx1, whereas my goal is to search through dx1 to dx10. If either one of the dx variables have the ICD codes of interest, ELX_GRP_1 should be =1.

I've tried to change the name of the variables from dx1 to dx2 ...to dx10, like:

 

data want;
set have;
          if dx1 IN:  ('I099','I110','I130','I132','I255','I420','I425','I426','I427','I428',
                          'I429','I43','I50','P290') then ELX_GRP_1 = 1;else ELX_GRP_1 = 0;
            LABEL ELX_GRP_1 = 'Congestive Heart Failure';
run;
data want; set want; if dx2 IN: ('I099','I110','I130','I132','I255','I420','I425','I426','I427','I428', 'I429','I43','I50','P290') then ELX_GRP_1 = 1;else ELX_GRP_1 = 0; LABEL ELX_GRP_1 = 'Congestive Heart Failure'; run; etc.

But apparently each time the program generate a new ELX_GRP_1 instead of "replace" the value of ELX_GRP_1 the generated by the previous run. So that does not work as well.

 

Can I please get some help on

1) how to write the loop correctly?

and 2) how to replace the value of the previously generated variable (instead of generating a whole new variable every time)?

 

Thanks a lot.

 

Ginny Han

 

 

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1278 views
  • 0 likes
  • 1 in conversation