Announcement

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

  • "Invalid File Specification" error message when creating local

    Hello, all

    I've run into a repeat error message in the first steps of creating a local dataset on a secure server. Specifically, when I run the following:

    local rawdata_w5 = "[File Path Name Here]\wave.xpt"
    local tempsave = "[File Path Name Here]"
    * Wave vars
    fdause "`rawdata_w5'", clear
    destring aid, replace
    save `tempsave'/w5_temp.dta, replace


    an error reading "Invalid File Specification" appears following the -fdause- command.

    I'm still fairly new to Stata, is there something I'm grossly overlooking here?

    Thank you for any and all help!
    Trent

  • #2
    I can't see anything problematic here, but you are abstracting away detail that might be biting, Crucially the locals must be defined in the namespace in which they are later used,

    Comment


    • #3
      Nick has called it correctly in his second sentence of post #2.

      I believe your problem is that you have written your code in the do-file editor window, and then rather than running everything at once, you are running it by selecting a few lines and running them, then selecting the next few lines and running them, and so on.

      Consider the following example. In the do-file editor window, I have a two-line program that I run in its entirety.
      Code:
      . do "/Users/lisowskiw/Downloads/example.do"
      
      . local message Hello, world.
      
      . display "The message is `message'"
      The message is Hello, world.
      
      . 
      end of do-file
      Now I run the same two lines by selecting the first line and running it, then selecting the second line and running it.
      Code:
      . do "/var/folders/xr/lm5ccr996k7dspxs35yqzyt80000gp/T//SD17616.000000"
      
      . local message Hello, world.
      
      . 
      end of do-file
      
      . do "/var/folders/xr/lm5ccr996k7dspxs35yqzyt80000gp/T//SD17616.000000"
      
      . display "The message is `message'"
      The message is 
      
      . 
      end of do-file
      The important thing to keep in mind is that local macros vanish when the do-file within which they were created ends. If you look carefully at the results above, you'll see that when I selected a single line to run, it was copied into a temporary do-file and run, so even though both lines are in the same window in the do-file editor, they are run as separate do-files, and local macro defined in the first line vanishes at the end of that do-file, and is undefined when the second line is run.

      What you ran was the equivalent of
      Code:
       . fdause "", clear
      invalid file specification
      r(198);

      Comment


      • #4
        Hello, all

        Update: In the original file path names, I had both "/" and "" characters which broke the code following the -fdause-
        Additionally, William was correct in observing that I was not running the code all at once; thus, my locals were vanishing at the end of each run.

        Thank you all kindly for the assistance!
        Trent

        Comment

        Working...
        X