Announcement

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

  • Notation problem

    Hello. I have a foreach loop in which I save a file "`f'" without any problems. But when I try to save it in another folder, for example C:\folder1\folder2"`f'", it doesn't work. I know it's a notation problem, but I've been searching the help menus for a while and can't find the solution. Please help.
    Last edited by Esteban Jara; 31 May 2025, 13:06.

  • #2
    The keys here are likely to be that

    1. Double quotes
    Code:
    "  "
    are not at all part of your filename under MS WIndows, which I presume is the unstated operating system here. Their purpose is just to act as delimiters, especially if your filepath or filename includes spaces.

    2. Backslahes don't work well when followed by local macro references. This is explained in

    SJ-8-3 pr0042 . . . . . . . Stata tip 65: Beware the backstabbing backslash
    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox
    Q3/08 SJ 8(3):446--447 (no commands)
    tip to use forward slash instead of backslash for
    directory and file names

    which in turn is recycling with more detail the signal at [U] 18.3.11 https://www.stata.com/manuals/u18.pdf


    Short of seeing the rest of the code and any concrete examples of your filenames, my guess would be that your syntax should be more like


    Code:
    "C:\folder1\folder2/`f'"  

    Comment

    Working...
    X