Announcement

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

  • infix error: .raw file not found, dictionary invalid

    I am having trouble importing a flat file (.raw) using a data dictionary that was given to me. The data and the dictionary have the same name -- so let's say NAME.raw is the data file and NAME.dct is the dictionary. The person who gave me the dictionary also gave me a log showing that this code below works to import the data w/ the dictionary. It begins this way (identical to true log but with NAME instead of true file name):

    Code:
    . clear
    
    . infix using NAME
    infix  dictionary using NAME.raw {
     study 1-2
     deck 3-4
     intno 5-8
     serno1 9
     type1 10
     period1 11
     nperiods1 12-14
     avsal1 15-18
     tosal1 19-23
     serno2 24
      type2 25
      period2 26
      nperiods2 27-29
      avsal2 30-33
      tosal2 34-38
     serno3 39
      type3 40
      period3 41
      nperiods3 42-44
      avsal3 45-48
      tosal3 49-53
     serno4 54
      type4 55
      period4 56
      nperiods4 57-59
      avsal4 60-63
      tosal4 64-68
     }
    
    '-' cannot be read as a number for serno3[229]
    (2,376 observations read)
    I'm not sure if it's necessary for the .raw file and the .dct file to have the same name -- the help file for infix is hard to follow -- but I'm guessing that it is necessary for the syntax in the log. Clearly the data imported for the person who gave me the log; the log goes on to manipulate the data. But when I run this same code from a .do file in the same folder as the 2 files (i.e., in the folder with NAME.raw, NAME.dct), I can see from the output that I'm accessing the .dct file but apparently the .raw file is not being found, as I get this error at the bottom:

    Code:
    . infix using NAME
    infix  dictionary using NAME.raw {
     study 1-2
     deck 3-4
     intno 5-8
     serno1 9
     type1 10
     period1 11
     nperiods1 12-14
     avsal1 15-18
     tosal1 19-23
     serno2 24
      type2 25
      period2 26
      nperiods2 27-29
      avsal2 30-33
      tosal2 34-38
     serno3 39
      type3 40
      period3 41
      nperiods3 42-44
      avsal3 45-48
      tosal3 49-53
     serno4 54
      type4 55
      period4 56
      nperiods4 57-59
      avsal4 60-63
      tosal4 64-68
     }
    file NAME.raw not found
    dictionary invalid
    Any help would be greatly appreciated.

  • #2
    It seems you have not set the working directory. You can either set it using the
    Code:
    cd PATH
    command or put the full path before the filename. Otherwise Stata doesn't know where to look for your file.

    Comment


    • #3
      The .do file is in the same folder as the other 2 files, which is the first place Stata looks when no path is specified. So that is not the problem. (I did actually check by adding a path, and the result was the same. Which i knew it would be since the data dictionary *is* being read, as you can see from my output. It's just the .raw file that apparently is not being read.)

      Comment


      • #4
        What do you get when you run

        Code:
        infix study 1-2 deck 3-4 intno 5-8 serno1 9 using NAME.raw, clear
        ?

        Comment


        • #5
          It imports the first three variables!! Amazing!

          I'm so sorry but I just realized that it was my fault -- I had some commented out text at the bottom of the data dictionary, and when i deleted it, it ran fine. That's bizarre to me that the dictionary wouldn't work with commented out text, but it *was* something I had added, a note to myself. Now that I've deleted that text I can import the whole flat file with infix using arisdk96.

          Thanks so much Andrew! Even though it was my fault from the beginning it helped to see what the code was implicitly running. So thanks/sorry. : )
          Last edited by Leah Bevis; 18 Mar 2024, 20:25.

          Comment

          Working...
          X