Announcement

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

  • Splitting variable based on condition

    Dear all,

    I wonder if it is possible to split string variables containing numbers using 'split VariableA, parse(" ") gen(test_)' command.
    I would like split Variable A into 2 parts (medication name and dose, for example: split AMOXICILLIN + CLAV A 875MG + 125MG into AMOXICILLIN + CLAV A and 875MG + 125MG). Data look as below.

    PHP Code:
    ----------------------- copy starting from the next line -----------------------
    [
    CODE]
    Example generated by -dataex-. For more infotype help dataex
    clear
    input str41 DRUG_NAMEFORM_AND_STRENGTH
    "ABCIXIMAB            10MG/5ML INJECTION-"
    "ABEMACICLIB          100 MG TABLET- 56 ("
    "AMOXICILLIN + CLAV A 875MG + 125MG"
    "TAB-
    BUDESONIDE+FORMOTERO 200MCG+6MCG/ACTN" 
    end
    [/CODE]
    ------------------ 
    copy up to and including the previous line ------------------ 
    Many thanks,
    Oyun

  • #2
    Code:
    gen name = ustrregexs(0) if ustrregexm(DRUG,"\D+")
    gen dose = ustrregexs(0) if ustrregexm(DRUG,"(\d).+")

    Comment


    • #3
      Many thanks for your help!

      Comment

      Working...
      X