Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Various ICD-10 codes into one code and generating a variable from it

    What command I should be using to generate a single code which contains all diagnosis ICD codes form 1 to 25, and contains the ICD code for diabetes.

    (eg. Diabetes is coded by E08.X, E09.X, E10.X, E11.X, E12.X, E13.X, E14.X) X can be from 1 to 3 digit.

  • #2
    Code:
    icd10 gen wanted = my_icd_10_variable, range(E08* E09* E10* E11* E12* E13* E14*)
    Replace my_icd_10_variable by the actual name of the variable in your data set that contains the ICD diagnosis codes.

    By the way, there are a few diabetes codes that are not covered in the E series. Gestational diabetes, in particular is O24*. And P70.2 is neonatal diabetes mellitus.

    Comment


    • #3
      Hi Clyde thanks for such a quick reply, I had issue that, when I use ​ "​​​​​​icd10 gen DM = I10_DX1-I10_DX25, range(E08* E09* E10* E11* E12* E13* E14*)
      too many variables specified" this comes in red! Where I am missing, I10_DX1, I10_DX2 ..... so on to I10_DX25.

      What should I do?

      Comment


      • #4
        Asked already on Reddit here. Please note that we ask in the FAQ that you do let us know if and where you have cross-posted your questions. This is a courtesy to others who may not wish to duplicate efforts and could otherwise help someone else.

        Comment


        • #5
          As an interim answer to #3

          The example given by Clyde Schechter indicates that you need to plug in a single variable name. The help for icd10 also indicates that a single variable name is to be supplied. The command doesn't support a list of variable names; hence the error message.

          What is best to do here has to be suggested by people who have used this command.

          Comment


          • #6
            If you haven't already figured out how to adapt the response in #2 to your data, please post back with example data, and use the -dataex- command to do so. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

            Also, as you have more than one I10_DX* variable, you need to clarify whether you want a separate new variable corresponding to each of those showing whether or not it codes for diabetes, or if you want a single variable showing whether any of the I10-DX* variables codes for diabetes.

            Comment


            • #7
              Thanks Clyde for the elaborated response, I want a single variable showing whether any of the I10-DX variable codes for diabetes

              Comment


              • #8
                Thanks for clarifying. I did ask for example data, which you have not provided. I will make some assumptions about your data set and offer some code. But if my assumptions are wrong, then we are both wasting our time here. So if this code turns out not to work in your actual data, I can't help you with -dataex- example data.

                Code:
                reshape long I10_DX, i(person_id)
                icd10 gen wanted = I10_DX, range(E08* E09* E10* E11* E12* E13* E14*)
                by person_id (wanted), sort: replace wanted = wanted[_N]
                reshape wide
                Note: If your data set is very large, the -reshape-'s are going to be very slow, so be patient. Alternatively, the -greshape- command is much faster and is part of the -gtools- package, which you can obtain from SSC.
                Last edited by Clyde Schechter; 22 Feb 2023, 19:14.

                Comment

                Working...
                X