Announcement

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

  • Infix problem (using invalid varname)

    Hello,

    I am trying to read in fixed width data from a .txt file. I am following the documentation from help infix. Here is my code:

    Code:
    infix dictionary using Status.txt {
        id 1-9
        name 10-32
        filedate 33-40
        agency 41-44
        station 45-53
        age 54-59
        years since degree 60-65
        education level 66-67
        pay plan 68-69
    }
    
    infix using Status.txt, clear
    This returns the error "using invalid varname." The infix documentation indicates that it is necessary to include "using" after "dictionary," so I do not understand why it is interpreting using as a variable name. Alternatively, I get the error message "Status.txt invalid name when I delete "using" from the first line of code.

    I have also tried to avoid this problem by coding in a different way:

    Code:
    infix id 1-9 name 10-32 filedate 33-40 agency 41-44 station 45-53 age 54-59 yearssincedegree ///
    60-65 educationlevel 66-67 pay plan 68-69 using 1973-09-to-2014-06\dod\status\Status.txt
    When I do this Stata says that the dictionary is invalid.

    Thank you.
    Last edited by Greg Saldutte; 22 May 2019, 14:52.

  • #2
    you cannot have spaces in variable names in Stata; you can use underscores so, e.g., change "pay plan" to pay_plan"

    Comment


    • #3
      Hello. I am facing a similar issue. I am trying to extract data using the infix command using the code below and I get the error " using invalid varname".

      Code:
      infix dictionary using R75252L01.TXT{
      byte centre 1-3
      byte fsu 4-8
      byte round 9-10
      byte sch 11-13
      byte sampl 14-14
      byte sector 15-15
      byte nssregion 16-18
      byte district 19-20
      byte stratum 21-22
      byte sstratum 23-24
      byte sround 25-25
      byte ssample 26-26
      byte fod 27-30
      byte hamlet_grp 31-31
      byte sss 32-32
      byte hhsno 33-34
      byte level 35-36
      byte filler 37-41
      byte insno 42-43
      byte resp_cd 44-44
      byte surv_cd 45-45
      byte sub_cd 46-46
      byte emp1 47-50
      byte emp2 51-54
      byte emp3 55-58
      byte dts 59-64
      byte dtd 65-70
      byte time_can 71-73
      byte no_invs 74-74
      byte r1 75-75
      byte r2 76-76
      byte r3 77-77
      byte r4 78-78
      byte blank 79-126
      byte nss 127-129
      byte nsc 130-132
      byte mlt 133-142
      }
      Running infix in alternate way given below works just fine. But since I have a huge dataset I wish to use the above format. I don't understand why I'm getting this error.
      Code:
      infix byte centre 1-3 byte fsu 4-8 byte round 9-10 byte sch 11-13 byte sampl ......... byte mlt 133-142 using R75252L01.TXT

      Comment


      • #4
        Add a space before {.

        Comment


        • #5
          Still getting the same error even with space before {.

          Comment

          Working...
          X