Announcement

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

  • Looking for Quotes in String Variables

    How can I have Stata look for a quote (") in a string variable?

    I tried writing the following, but am getting an error, "too few quotes."

    count if regexm(Var1, "'")

    Thanks in advance for any ideas.

    Erika

  • #2
    Code:
    count if regexm(Var1, `"""')
    Note: You will probably go blind trying to look at that mess and figure it out. Copy and paste it to be sure to get it right.

    See -help quotes-, and particularly the part about compound double quotes.

    Comment


    • #3
      Use compound double quotes and/or look for char(34).

      Using strpos() is often simpler and as effective as trying to cast every string problem in terms of regular expressions.

      Comment

      Working...
      X