Announcement

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

  • Using "*" to keep all codes in a dataset after a certain number

    I am trying to keep all ICD9 codes after the first 2 numbers 73

    I have tried keep if Principal_Dx_ID == 73*

    I get the error of invalid name 73*

    I know there is a simple solution but I am not coming up with it.

    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long(Unique_Person_Id Principal_Dx_ID)
    22107 727
    11547 727
    11547 727
    18801 734
    14711 734
    16926 734
    38215 734
    1005 734
    3542 734
    42237 734
    29534 734
    11258 734
    11258 734
    30847 734
    6674 734
    50650 734
    36606 734
    32881 734
    28094 734
    18801 734
    9965 734
    1005 734
    22103 734
    13253 734
    8251 734
    15565 734
    25266 734
    40082 734
    12456 734
    50803 734
    18054 734
    38910 734
    42670 734
    32535 734
    32535 734
    50406 734
    20141 734
    20141 734
    37004 734
    19427 734
    36814 734
    21264 734
    10983 734
    6674 734
    30847 734
    27419 734
    48260 734
    16511 734
    40082 734
    37719 734
    49510 734
    49048 734
    36814 734
    32535 734
    42708 734
    12578 734
    37266 734
    32881 734
    24557 734
    34049 734
    32535 734
    39353 734
    3542 734
    13572 734
    37404 734
    36814 734
    21268 734
    26426 734
    11167 734
    9957 734
    48412 734
    40082 734
    4085 734
    6906 734
    13253 734
    1277 734
    29534 734
    34107 734
    23965 734
    51102 734
    8376 734
    10816 734
    49027 734
    14711 734
    24557 734
    36606 734
    22832 734
    10816 734
    48412 734
    25553 734
    49626 735
    624 736
    393 736
    16232 736
    20027 736
    43290 736
    30737 736
    30849 736
    14881 736
    49729 736
    end
    [/CODE]
    ------------------ copy up to and including the previous line

  • #2
    If I understood right, you may use the command - icd9 gen - or - icd10 gen - depending on the data, with - range() - function as the option.
    Best regards,

    Marcos

    Comment


    • #3
      Hey Jake,

      see if this works


      Code:
      keep if regexm(strofreal(Principal_Dx_ID), "^73")
      Best,
      Pablo Bonilla

      Comment

      Working...
      X