Announcement

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

  • #16
    Ches Zin you have several posts on Statalist now, so provide proper dataex examples in your future posts. You need to enclose the match within parentheses. Otherwise use -ustrregexs(0)-

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str44 doser
    " 1 tablet when needed . Max 8 tablet per day"
    end
    
    gen max1= ustrregexs(0) if ustrregexm(lower(doser),"max [0-9]")
    gen max2= ustrregexs(1) if ustrregexm(lower(doser),"(max [0-9])")

    Comment


    • #17
      The 1 in -ustrregexm- refers to the first parenthesized expression that matches. You didn't parenthesize anything in your match string, so you got nothing back.

      Code:
      gen max = ustrregexs(1) if ustrregexm(lower(doser),"(max [0-9])")
      does the trick.

      Addeed: Crossed with #16.

      Comment

      Working...
      X