Announcement

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

  • Evaluating macros containing '

    Hi
    I stumbled on to something peculiar in Stata.
    Let's say that I have created a folder named "C:\nhb's folder", note that ' is part of the name of the folder.

    If I want to see all files in that folder I'll use the extended Stata function dir:
    Code:
    . di `"`: dir "C:\nhb's folder" dir "*"'"'
    invalid syntax
    s folder" dir "*'
    But as seen above `: dir "C:\nhb' is evaluated giving the error and the rest "s folder" is displayed.

    Is there a workaround for this?

    Looking forward to hear from you

    PS I have tried using \' for escaping the problem without any luck
    Kind regards

    nhb

  • #2
    Any reason not to split this, i.e. avoid the in-line evaluation?

    Code:
    local foo : dir "c:/nhb's folder" dir "*"
    code referring to foo
    Best
    Daniel

    Comment


    • #3
      Hi
      That works, thank you.
      However, I thought that this was a Stata problem.
      But it is actually a Mata problem.
      Consider this post answered.
      I'll start a new in the Mata forum

      Once again, thank you very much
      Kind regards

      nhb

      Comment

      Working...
      X