Announcement

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

  • Confusion about freduse

    I'm having a problem with freduse. I'm using Stata 13.1 for Windows.

    I just installed freduse like the YouTube video said, but when I try to import something with the command I get an error.

    Here's what I see:


    . freduse ICSA
    file __000000.txt could not be opened
    file with temporary name already exits

    rename files that begin with __ r(498);



    I have no idea what this means, so I tried resetting both Stata and my computer, but that hasn't helped. I've also tried googling the problem, but haven't been able to find anything that addressed the problem.

    Any tips or advice would really be appreciated. Thank you for your time!

    -Pierre

  • #2
    Pierre, as you have experienced yourself, Google doesn't always find what you are typing in the search box. That's why the Statalist rules require exact quoting of the source and version of anything additional to a standard Stata installation. In your case, freduse by David Drukker is distributed from this RePEc page , but which YouTube video you refer to remains a mystery, (though not essential anyway).

    Without having the trace of what happened my first intent was to blame StataCorp for the old problem that the temporary filenames are returned without checking for the file with same name existing (relying solely on the uniqueness of the session ID and hoping the previous session with same ID ended up well and released all allocated resources). However after looking at the message that you quoted, I've noticed that the duplicate filename is not a standard Stata's temporary file name ST_{SESSIONID}NNNNNN.tmp and after skimming through the code of freduse the problem is with the lines of _fredweb.ado:

    Code:
        tempname fname
        local fname "`fname'.txt"
        capture noi confirm new file `fname'
        if _rc {
            di as err "{p 2 4 2}file with temporary name already exits"
            di as err "{p 2 4 2}rename files that begin with {cmd:__}"
            exit 498
        }
    This looks like a very ad-hoc way of creating temporary files. The tempname command is not designed for this purpose. Instead tempfile should be used. It is not clear why is the wrong command employed here. One possible explanation is that something else in the pipeline requires the temporary file to have a .txt extension, which can't be enforced with the tempfile command (it creates files with .tmp extension). This is (imho) a big inconvenience that Stata lacks the possibility of creating a set of temporary files (like a temporary shapefile, which requires three (at least) files with same basename and different pre-defined extensions) and temporary folders. I have requested this a couple of times and both times got the recommendation to simulate this with creating a temporary object and implementing the destructor logic for cleanup.

    In your particular case, type in Stata:
    Code:
    tempfile t
    display `"`t'"'
    Then close all Stata's (and as much of other programs as you can not to disturb anything else), go to the folder which Stata has shown you above and delete all files that start with "__" (two underscores). This is what the recommendation you get from the freduse in a rather reduced way, since it doesn't explain where should the files be found.

    If you have any other troubles, don't hesitate to post here with a proper description and trace if possible.

    Hope this helps. Best, Sergiy Radyakin

    Comment


    • #3
      Sergiy,
      I am having the same problem that PduVair67 was having. Here, I have traced the problem. I tried your solution, but could not find the temporary folder that was indicated. I am using Stata 12.1 on a Mac. Here is my output:


      . freduse UNRATE
      ----------------------------------------------------------------------------------------------------- begin freduse ---
      - version 9.0
      - syntax anything(name=slist id="series list" everything) , [ File clear ]
      - mata: _fredifinparse("slist", "ifinmacro")
      - if "`file'" != "" {
      = if "" != "" {
      _freduse `slist' ,`clear'
      }
      - else {
      - _fredweb `slist' , `clear'
      = _fredweb UNRATE ,
      -------------------------------------------------------------------------------------------------- begin _fredweb ---
      - version 9.0
      - syntax anything(name=slist id="series list") , [ clear ]
      - gettoken sname slist:slist , quotes
      - mata: _fredcleanname("sname", 0)
      - tempname fname
      - local fname "`fname'.txt"
      = local fname "__000000.txt"
      - capture noi confirm new file `fname'
      = capture noi confirm new file __000000.txt
      file __000000.txt could not be opened
      - if _rc {
      - di as err "{p 2 4 2}file with temporary name already exits"
      file with temporary name already exits - di as err "{p 2 4 2}rename files that begin with {cmd:__}"

      rename files that begin with __ - exit 498 }
      ---------------------------------------------------------------------------------------------------- end _fredweb
      {hline} } -------------------------------------------------------------------------------------------------------
      end freduse {hline} r(498);

      . tempfile t

      . display `"`t'"'
      /var/folders/ht/0rkdf6l16q9949gm6zcy5txm0000gn/T//S_00937.000001



      I started having this problem simultaneously with a needed change to the _fredweb.ado file (from http to https). I have fixed that problem, I think, but this one remains.

      Any assistance would be greatly appreciated!

      Thank you in advance.

      Jon

      Comment


      • #4
        I had the same problem as OP. Sergiy Radyakin's solution worked for me, with one modification.

        Originally posted by Sergiy Radyakin View Post

        In your particular case, type in Stata:
        Code:
        tempfile t
        display `"`t'"'
        Then close all Stata's (and as much of other programs as you can not to disturb anything else), go to the folder which Stata has shown you above and delete all files that start with "__" (two underscores).
        I had to delete files that had other prefixes, like STiD.

        Comment


        • #5
          I had an issue with freduse and stata 12 as well. Nick's comment on my thread indicates that stata 12 doesn't support https so freduse unfortunately will not work...

          My thread: http://www.statalist.org/forums/foru...-freduse-error

          Comment


          • #6
            I posted here a few weeks ago to say that deleting files with other prefixes worked. Now I think that was incomplete or maybe incorrect. I've been using Notepad++ as a do file editor, and I execute lines of code directly from Notepad++. If I tell Notepad++ to execute code before Stata is open, then Stata assumes Notepad++ is the working directory and I get the same error message described by OP. If I open Stata first, or change the working directory using "cd D:/stata", then freduse works as intended.

            Comment

            Working...
            X