Announcement

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

  • Tempfile error

    Hi,

    I have the following code:

    Code:
    cd "P:\2021\189\Preliminary"
    
    use "P:\2021\189\use\A3_mergedCW_withF.dta", clear
        rename     B_sign1    CWid
        keep     CWid year kontor_handel d25
        tempfile A4
        save `A4'
    But I get the following error:
    invalid 'Files'
    r(198);

    does anyone know what is wrong?

  • #2
    No. Is this the exact output Stata shows after the last line? Your syntax looks perfectly legal, and correct too, so I'm not sure why it would say this

    Comment


    • #3
      Try

      Code:
      save "`A4'"
      as I suspect that your filepath contains one or more spaces. See

      Code:
      help filename
      for this advice.

      Comment


      • #4
        Yeah but... the cwd doesn't have any spaces in it, no? I agree with the quotes being a solution (the one I'd use most likely), but I don't see why the problem happens just based off the MWE

        Comment


        • #5
          Yeah but
          It's common, in my experience standard, that Stata uses a temporary directory that is not the pwd. Indeed that is evident, or at least apparent, here, because Files is not part of the current directory name.

          The current directory for temporary files is recorded in c(tmpdir) How you might change that eludes me at present.

          Comment


          • #6
            Originally posted by Nick Cox View Post
            How you might change that eludes me at present.
            See FAQ: Using the STATATMP environment variable

            Comment


            • #7
              daniel klein Indeed. Thanks!

              Comment


              • #8
                Originally posted by Nick Cox View Post
                Try

                Code:
                save "`A4'"
                as I suspect that your filepath contains one or more spaces. See

                Code:
                help filename
                for this advice.

                The "`A4'" fixed my problem, thanks! It is very strange since the same dofile with the same code ran perfectly before, without the quotation marks.

                Comment

                Working...
                X