Announcement

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

  • Replacing zero numeric with missing based on another column-dataex attached

    Hello all, I wanted all zero in 'tscd20 to become missing if the therapy column has no therapies at all. What is wrong with my code I put in? The unwanted zeros still remain. My aim was to just pick all that had any form for anti-CD20 treatment as long as any treatment data was available.
    Pardon me if this has been discussed elsewhere. I could not find something similar.

    gen tscd20 = ustrregexm(therapyforrtline1line2linen, "nutuzumab|ximab|bin|tumumab|CHOP|-R|R-CHOP|FAR|R-H|FR|FCR|BR|R-C|R-m|R-E|FR|R-I|azy") if !missing(therapyforrtline1line2linen) //anti CD20
    replace tscd20 = "" if therapyforrtline1line2linen == ""


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str183 therapyforrtline1line2linen float tscd20
    "Venetoclax/Rituximab, Venetoclax, Idelasilib/Rituximab, Obintatuzumab"                                                                                                                   1
    "ACP, AVD, BV-bendamustine, BV"                                                                                                                                                           0
    "BR-polatuzumab, Venetoclax, Obinituzumab"                                                                                                                                                1
    "CHOP, R-CHOP"                                                                                                                                                                            1
    ""                                                                                                                                                                                        0
    "Ventoclax"                                                                                                                                                                               0
    "Ibrutinib"                                                                                                                                                                               0
    "DA-EPOCH-R, R-DHAP, Pembrolizumab, XRT (to inguinal and SC/cervical lymph nodes)"                                                                                                        1
    "Obinutuzumab/Chlorambucil"                                                                                                                                                               1
    "R-CHOP, Rituximab, Ibrutinib, Ventoclax/Rituximab, ASCT"                                                                                                                                 1
    "AVD, Azacitidine"                                                                                                                                                                        0
    "DA-EPOCH-R, RICE, MUD SCT, Rituximab, Palliative RT, Lenalidomide"                                                                                                                       1
    "R-CHOP, Hyper-CVAD/Ibrutinib, Hyper-CVAD-B, Ibrutinib"                                                                                                                                   1
    "BV/Rituximab, AVD"                                                                                                                                                                       1
    "R-CHOP, RICE, Ibrutinib, Obinutuzumab/Fludarabine/Cyclophosphamide"                                                                                                                      1
    "FCR, BR, Ibrutinib"                                                                                                                                                                      1
    "EPOCH-R, R-CHOP"                                                                                                                                                                         1
    "MUD SCT, Campath/Fludarabine/Melphalan, Rituximab/Ibrutinib"                                                                                                                             1
    "R-CHOP, Ibrutinib"                                                                                                                                                                       1
    "Palliative XRT/Dexamethasone"                                                                                                                                                            0
    "DA-EPOCH-R, Rituximab/Lenolidomide, Gemcitabine/Oxaliplatin, XRT"                                                                                                                        1
    ""                                                                                                                                                                                        0
    "ABT-199, SCT, Fludarabine/Busulfan/Alemtuzumab, Obinotuzumab/Idelalisib"                                                                                                                 1
    "Idelalisib, Obinotuzumab, Entospletinib"                                                                                                                                                 1
    "R-CHOP, DA-EPOCH-R/Lenalidomide, EPOCH-R, Lenalidomide"                                                                                                                                  1
    "Resection of small bowel lesion, EPOCH-R, Ofatumomab, Ibrutinib"                                                                                                                         1
    "R-CHOP, Ibrutinib, Lenalidomide, R-ICE, MUD SCT, Campath/Fludarabine/Melphalan"                                                                                                          1
    "DA-EPOCH-R, MUD SCT, Campath/Fludarabine/Melphalan"                                                                                                                                      1
    "RT, R-CHOP, SCT, Ibrutinib"                                                                                                                                                              1
    "R-CHOP"                                                                                                                                                                                  1
    "RT, CHOP, R-ICE"                                                                                                                                                                         1
    ""                                                                                                                                                                                        0
    "RT, TPF, THFX"                                                                                                                                                                           0
    ""                                                                                                                                                                                        0
    "R-CHOP, Filgrastim/Vincristine, EPOCH-R"                                                                                                                                                 1
    ""                                                                                                                                                                                        0
    "R-CHOP"                                                                                                                                                                                  1
    "BR, Ibrutinib, Venetoclax"                                                                                                                                                               1
    ""                                                                                                                                                                                        0
    "EPOCH-R"                                                                                                                                                                                 1
    "Bendamustine/Ofatumumab; SCT"                                                                                                                                                            1
    "Rituximab/Solu-medrol"                                                                                                                                                                   1
    ""                                                                                                                                                                                        0
    "FR"                                                                                                                                                                                      1
    "Modified R-CHOP (with vincristine, predisone, and rituximab x4 cycles)"                                                                                                                  1
    "RT, Erlotinib"                                                                                                                                                                           0
    "Bendamustine, Rituximab"                                                                                                                                                                 1
    "R-CHOP, SCT"                                                                                                                                                                             1
    ""                                                                                                                                                                                        0
    "R-CHOP"                                                                                                                                                                                  1
    ""                                                                                                                                                                                        0
    "Fludarabine/Rituximab, SCT after preconditioning with TBI/Etoposide/Alemtuzumab, EPOCH-R, SCT after preconditioning with clofarabine & melphalan & alemtuzumab, Etoposide & alemtuzumab" 1
    "CCI-779, ESHAP"                                                                                                                                                                          0
    "FCR"                                                                                                                                                                                     1
    ""                                                                                                                                                                                        0
    "RT, R-CHOP, Rituximab/Cyclophosphamide/Etoposide, Cisplatin/Methylprednisolone/Etoposide/Cytarabine, SCT, Busulfan/Fludarabine/Alemtuzumab"                                              1
    "R-CHOP, R-ICE, CCI-779"                                                                                                                                                                  1
    ""                                                                                                                                                                                        0
    "SCT, Etoposide, R-CHOP"                                                                                                                                                                  1
    ""                                                                                                                                                                                        0
    "ABVD, Palliative RT"                                                                                                                                                                     0
    "Alemtuzumab, Cyclophosphamide/Pentostatin"                                                                                                                                               0
    ""                                                                                                                                                                                        0
    "SCT, TB/Cyclophosphamide/Alemtuzumab"                                                                                                                                                    0
    ""                                                                                                                                                                                        0
    "None"                                                                                                                                                                                    0
    "EPOCH-R, Cyclophophamide/Rituximab"                                                                                                                                                      1
    "R-CHOP"                                                                                                                                                                                  1
    "CHOP, ICE"                                                                                                                                                                               1
    "Cyclophosphamide/Methotrexate/Vincristine/Ifosfamide/Etoposide/ARA-C/Doxorubicin/Rituximab, Whole brain RT, SCT"                                                                         1
    ""                                                                                                                                                                                        0
    "Rituximab, ICE, Intrathecal Methotrexate"                                                                                                                                                1
    ""                                                                                                                                                                                        0
    "Cisplatin/Cytarabine/Dexamethasone"                                                                                                                                                      1
    "FR"                                                                                                                                                                                      1
    ""                                                                                                                                                                                        0
    "R-CHOP, Venetoclax, Pembrolizumab"                                                                                                                                                       1
    "R-CHOP"                                                                                                                                                                                  1
    "R-CHOP, Ibrutinib/Nivolumab, Ibrutinib, Polatuzumab/BR"                                                                                                                                  1
    "EPOCH/Obinutuzumab, Ibrutinib/Dexamethasoe, R-GEMOX, CAR-T cell therapy, Duvelisib"                                                                                                      1
    "ICE, GEMOX, CAR-T cell therapy"                                                                                                                                                          0
    ""                                                                                                                                                                                        0
    ""                                                                                                                                                                                        0
    "SCT with BEAM"                                                                                                                                                                           0
    "RT, Cyclophosphamide/Prednisone, R-miniCHOP"                                                                                                                                             1
    ""                                                                                                                                                                                        0
    "R-CHOP, Ibrutinib/Venetoclax, Obinutuzumab, Rituximab/Idelalisib, Fludarabine/Cyclophosphamide, CAR-T cell therapy"                                                                      1
    ""                                                                                                                                                                                        0
    "Ibrutinib, Venetoclax/Rituximab"                                                                                                                                                         1
    "BV-bendamustine, BV"                                                                                                                                                                     0
    "Obinutuzumab/Idelalisib"                                                                                                                                                                 1
    "BV/Nivolumab, Methotrexate, Ibrutinib/Methotrexate"                                                                                                                                      0
    ""                                                                                                                                                                                        0
    "R-CHOP/Acalabrutinib"                                                                                                                                                                    1
    "DA-R-EPOCH"                                                                                                                                                                              1
    "R-CHOP, MUD SCT, Flu/Mel/ATG, Decitabine, Venetoclax/Decitabine"                                                                                                                         1
    "R-miniCHOP, RT, Ibrutinib, Venetoclax, Rituximab"                                                                                                                                        1
    "R-CHOP, RT to spine & leg lesion, Fludarabine/Cyclophosphamide, CAR-T cell therapy, R-GEMOX"                                                                                             1
    ""                                                                                                                                                                                        0
    "R-CHOP"                                                                                                                                                                                  1
    end

  • #2
    Changing it to regexm did the trick. Strange that ustrregexm does not work. Thought unicode would the code more universal.

    Comment


    • #3
      If I run this code on your example data I find that ustrregexm() and regexm() produce identical results, because no observations where the two results differ are listed.
      Code:
      gen tu = ustrregexm(therapyforrtline1line2linen, "nutuzumab|ximab|bin|tumumab|CHOP|-R|R-CHOP|FAR|R-H|FR|FCR|BR|R-C|R-m|R-E|FR|R-I|azy") if !missing(therapyforrtline1line2linen)
      gen tr =     regexm(therapyforrtline1line2linen, "nutuzumab|ximab|bin|tumumab|CHOP|-R|R-CHOP|FAR|R-H|FR|FCR|BR|R-C|R-m|R-E|FR|R-I|azy") if !missing(therapyforrtline1line2linen)
      list if tu!=tr
      Perhaps you could provide an example from your data where the results of ustrregexm() and regexm() differ.

      Also, when I run your code from post #1 I get the following error message, which leaves the unwanted zeroes in place.
      Code:
      . replace tscd20 = "" if therapyforrtline1line2linen == ""
      type mismatch
      r(109);

      Comment


      • #4
        My bad. I tried it again with the ustr and I do see the appropriate 1, 0 and missing values with just the first line of code. I was probably not looking carefully since I was mistakenly expecting only '1' or '.' and no zeroes. The second line of code is not needed at all, I guess. Sorry for wasting your time and thanks again for taking the time to give me the feedback, William.

        On a different note, I love your QR code pointing to your orcid. I already have an idea to do the same now.

        Comment


        • #5
          since I was mistakenly expecting only '1' or '.' and no zeroes
          Tagging things (or, for that matter, any dichotomous variable) with values of 1 and . is a bad habit that people carry over from working with spreadsheets. In spreadsheets, where human visual perception is a primary consideration, that works well. In Stata, and most other computational systems, it works poorly. In Stata you should always create and expect dichotomous variables as 1 and 0, not 1 and ., so that you can properly use logical expressions, and so that you do not end up with wholesale exclusion of variables not satisfying the defining condition from all further analyses and calculations.

          Comment


          • #6
            Originally posted by Clyde Schechter View Post
            Tagging things (or, for that matter, any dichotomous variable) with values of 1 and . is a bad habit that people carry over from working with spreadsheets. In spreadsheets, where human visual perception is a primary consideration, that works well. In Stata, and most other computational systems, it works poorly. In Stata you should always create and expect dichotomous variables as 1 and 0, not 1 and ., so that you can properly use logical expressions, and so that you do not end up with wholesale exclusion of variables not satisfying the defining condition from all further analyses and calculations.
            That seem sensible to do and something I will remember as I go further. I have data from multiple institutions and it is quite a challenge to weed through the missing and zero. I am trying my best to making their entry easy but that entails allowing collaborators to freetext as you can see. Sometimes, the zero is genuine missing data and sometimes, negative data that really is a '0'. It is amazing how much mindful cleaning needs to be done prior to embarking on any analysis. I am guilty of having spent 10% on cleaning and 90% on analysis on past studies and published possibly flawed studies. This time around I am hoping to reverse that proportion and feel comfortable with any data I generate. By the time, I am done with the study, all your Stata forum members are going to know all my variables and outcome (except demographics of course).

            Comment


            • #7
              Code:
              This time around I am hoping to reverse that proportion and feel comfortable with any data I generate.
              Good for you!

              Comment

              Working...
              X