Announcement

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

  • Error with ICD10

    I am trying to work with the ICD codes in my data. I have several variables for primary and another diagnosis to further compute elixhauser comorbidity index. Yet, when I type "icd10 check d1" all of the observations are "code too long". What should i do?

    Here is an example of the entries:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str8 d1
    "M17.9   "
    "M17.9   "
    "K91.89  "
    "K80.00  "
    "C18.7   "
    "M17.5   "
    "S72.409A"
    "K55.21  "
    "K80.18  "
    "K40.20  "
    "M17.9   "
    "M16.9   "
    "K40.90  "
    "M17.9   "
    "M17.9   "
    "M17.9   "
    "M16.10  "
    "K44.9   "
    "S72.456A"
    "T84.498A"
    "M16.7   "
    "K40.91  "
    "M17.9   "
    "K44.9   "
    "M17.9   "
    "K80.71  "
    "K40.90  "
    "K40.90  "
    "K80.20  "
    "S72.109A"
    "M17.9   "
    "M17.9   "
    "M17.9   "
    "C18.7   "
    "C18.0   "
    "M16.9   "
    "C18.2   "
    "M16.9   "
    "S72.099A"
    "K80.71  "
    "M17.9   "
    "M16.9   "
    "T84.039A"
    "S72.109A"
    "M16.9   "
    "K40.90  "
    "K81.0   "
    "M17.9   "
    "S72.309A"
    "M17.5   "
    "T84.039A"
    "K40.21  "
    "Z43.2   "
    "K40.91  "
    "C16.3   "
    "K40.90  "
    "M17.5   "
    "K81.0   "
    "M17.9   "
    "M17.5   "
    "M17.9   "
    "C18.7   "
    "K80.20  "
    "S72.109A"
    "K41.30  "
    "D37.9   "
    "C18.0   "
    "S72.109A"
    "M17.9   "
    "K40.20  "
    "K80.20  "
    "T84.029A"
    "Z43.3   "
    "C18.7   "
    "K40.91  "
    "T84.029A"
    "M16.9   "
    "K80.00  "
    "M17.9   "
    "M17.10  "
    "S72.26XA"
    "M16.9   "
    "M17.9   "
    "M17.9   "
    "M17.9   "
    "M17.9   "
    "T84.039A"
    "S72.099A"
    "S72.099A"
    "K40.90  "
    "C18.0   "
    "C20     "
    "M16.9   "
    "K43.0   "
    "M17.9   "
    "K40.90  "
    "C18.0   "
    "M17.9   "
    "C18.2   "
    "C18.2   "
    end
    label var d1 "DiagnósticoPrincipal"

  • #2
    all those spaces are confusing Stata; use the trim function; e.g.,
    Code:
    replace dl=trim(dl)

    Comment


    • #3
      I have tried, but still getting the same error "codes too long" for all observations. After the trimming, the data looks as follows:

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str8 d1
      "M17.9"   
      "M17.9"   
      "K91.89"  
      "K80.00"  
      "C18.7"   
      "M17.5"   
      "S72.409A"
      "K55.21"  
      "K80.18"  
      "K40.20"  
      "M17.9"   
      "M16.9"   
      "K40.90"  
      "M17.9"   
      "M17.9"   
      "M17.9"   
      "M16.10"  
      "K44.9"   
      "S72.456A"
      "T84.498A"
      "M16.7"   
      "K40.91"  
      "M17.9"   
      "K44.9"   
      "M17.9"   
      "K80.71"  
      "K40.90"  
      "K40.90"  
      "K80.20"  
      "S72.109A"
      "M17.9"   
      "M17.9"   
      "M17.9"   
      "C18.7"   
      "C18.0"   
      "M16.9"   
      "C18.2"   
      "M16.9"   
      "S72.099A"
      "K80.71"  
      "M17.9"   
      "M16.9"   
      "T84.039A"
      "S72.109A"
      "M16.9"   
      "K40.90"  
      "K81.0"   
      "M17.9"   
      "S72.309A"
      "M17.5"   
      "T84.039A"
      "K40.21"  
      "Z43.2"   
      "K40.91"  
      "C16.3"   
      "K40.90"  
      "M17.5"   
      "K81.0"   
      "M17.9"   
      "M17.5"   
      "M17.9"   
      "C18.7"   
      "K80.20"  
      "S72.109A"
      "K41.30"  
      "D37.9"   
      "C18.0"   
      "S72.109A"
      "M17.9"   
      "K40.20"  
      "K80.20"  
      "T84.029A"
      "Z43.3"   
      "C18.7"   
      "K40.91"  
      "T84.029A"
      "M16.9"   
      "K80.00"  
      "M17.9"   
      "M17.10"  
      "S72.26XA"
      "M16.9"   
      "M17.9"   
      "M17.9"   
      "M17.9"   
      "M17.9"   
      "T84.039A"
      "S72.099A"
      "S72.099A"
      "K40.90"  
      "C18.0"   
      "C20"     
      "M16.9"   
      "K43.0"   
      "M17.9"   
      "K40.90"  
      "C18.0"   
      "M17.9"   
      "C18.2"   
      "C18.2"   
      end
      label var d1 "DiagnósticoPrincipal"

      Comment


      • #4
        ok, this is what I get:
        Code:
        . icd10 check d1
        (d1 contains no missing values)
        
        d1 contains invalid codes:
        
            1.  Invalid placement of period                       0
            2.  Too many periods                                  0
            3.  Code too short                                    0
            4.  Code too long                                    43
            5.  Invalid 1st char (not A-Z)                        0
            6.  Invalid 2nd char (not 0-9)                        0
            7.  Invalid 3rd char (not 0-9)                        0
            8.  Invalid 4th char (not 0-9)                        0
           77.  Valid only for previous versions                  0
           88.  Valid only for later versions                     0
           99.  Code not defined                                  0
                                                        -----------
                Total                                            43
        the problem appears to be the following codes each of which is 8 characters long (and, I believe, the max length of an ICD10 code is 7 characters):
        Code:
        . ta d1 if length(d1)==8
        
          Diagnóst |
        icoPrincipa |
                  l |      Freq.     Percent        Cum.
        ------------+-----------------------------------
           S72.099A |          3       17.65       17.65
           S72.109A |          4       23.53       41.18
           S72.26XA |          1        5.88       47.06
           S72.309A |          1        5.88       52.94
           S72.409A |          1        5.88       58.82
           S72.456A |          1        5.88       64.71
           T84.029A |          2       11.76       76.47
           T84.039A |          3       17.65       94.12
           T84.498A |          1        5.88      100.00
        ------------+-----------------------------------
              Total |         17      100.00

        Comment


        • #5
          Rich has provided good advice. You should know that if you are using US-based data then your codes will be ICD-10-CM which is a US-specific adaptation of the WHO's ICD-10 definition.

          Contrast the results presented by Rich with those using -icd10cm-

          Code:
          . icd10cm check d1
          (d1 contains defined codes; no missing values)

          Comment


          • #6
            I am using a European dataset, but even when I try icd10cm command, there is an error:

            Code:
            . icd10cm check d1
            command icd10cm is unrecognized
            r(199);

            Comment


            • #7
              Thank you for the advice though! I have contacted the data provider and they have used ICD10CM codes indeed.

              Yet, icd9cm still is not a recognized command. Any suggestion?
              Last edited by Lana Kim; 17 Sep 2021, 21:08.

              Comment


              • #8
                -icd9- only works for ICD-9-CM already, as explained -help icd-, so there's no need to do anything special there.

                Comment


                • #9
                  Why ICD10CM command could be unrecognized though?

                  Comment


                  • #10
                    This was introduced since version 15, so if you're using an older version, you are out of luck. If you have a recent version of Stata, you can read the help file by typing:

                    Code:
                    help icd10cm
                    Then again, you don't necessarily need these icd commands to work with such data, you will just need to write more code.

                    Comment

                    Working...
                    X