Announcement

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

  • __000001 not found Error

    When running the following snippet of code in a do file:

    . use uganda13.dta

    .
    . /*Let's start with some cleaning of parcel manager variables*/
    .
    . gen double m0 = parcel_manager0

    . gen double m1 = parcel_manager1

    . gen double m2 = parcel_manager2

    .
    . tostring m0, replace format(%20.0f)
    m0 was double now str1

    . tostring m1, replace format(%20.0f)
    m1 was double now str1

    . tostring m2, replace format(%20.0f)
    m2 was double now str1

    .
    . gen temp1 = cond(m1 < m2, m1, m2)

    . gen temp2 = cond(m1 < m2, m2, m1)

    . /*Jake: let's see if this fixes the problem*/
    . bysort year season HHID: gen temp1 = cond(m1 < m2, m1, m2)

    . bysort year season HHID: gen temp2 = cond(m1 < m2, m2, m1)

    . replace temp2 = "." if temp1 == temp2 & temp2! = "." /*Jake: not called in this case, throwing error*/
    (0 real changes made)

    .
    . replace m1 = temp1
    (0 real changes made)

    . replace m2 = temp2
    (0 real changes made)

    .
    . drop temp1 temp2

    .
    . replace m0 = m1 if m1!="." & m2=="." & m0=="."
    (0 real changes made)

    . replace m1="." if m0!="."
    (0 real changes made)

    .
    . *bysort season HHID parcelID plotID cropID: gen N = _N
    .
    . /*We now look at crops per plot*/
    . egen count4 = nvals(cropID) if cropID != ., by(season HHID parcelID plotID)

    I get the error:

    __000001 not found
    r(111);

    end of do-file

    After reading a bit about what the issue might be, it seems this error gets thrown when a problem with a temporary variable or file is occurring... As a relative novice to Stata, might anyone have some guidance as to how to resolve this error? Could it possibly be a problem with the way I'm using egen?

  • #2
    The egen function nvals() is from egenmore (SSC), as you are asked to explain (FAQ Advice #12).

    I think we need to see your dataset or enough of it to reproduce the problem. It's hard to think through the consequences of a long chain of commands without seeing the original data at all. (Also FAQ Advice #12.)

    As the original author of tostring, I am puzzled at why you're using it here. You're generating doubles and then forcing them to string variables which turn out to be one character long!

    EDIT

    I looked through your code and can slim it down. Also, it seems that the final egen command does not depend at all on any of the previous commands. So, it's just a case of being able to run the egen command on your original data.


    Code:
    use uganda13.dta
    
    gen m0 = string(parcel_manager0) 
    gen m1 = string(parcel_manager1) 
    gen m2 = string(parcel_manager2) 
    
    
    gen temp1 = cond(m1 < m2, m1, m2)
    gen temp2 = cond(m1 < m2, m2, m1)
    
    * the next two won't work because temp1, temp2 already exist 
    * but the by: prefix would make no difference 
    * bysort year season HHID: gen temp1 = cond(m1 < m2, m1, m2)
    * bysort year season HHID: gen temp2 = cond(m1 < m2, m2, m1)
    
    replace temp2 = "." if temp1 == temp2 & temp2! = "." /*Jake: not called in this case, throwing error*/
    
    replace m1 = temp1
    replace m2 = temp2
    
    drop temp1 temp2
    
    replace m0 = m1 if m1 != "." & m2 == "." & m0 == "."
    replace m1 = "." if m0 != "."
    
    egen count4 = nvals(cropID) if cropID != ., by(season HHID parcelID plotID)
    Last edited by Nick Cox; 13 Jul 2017, 11:44.

    Comment


    • #3
      The error in


      Code:
      temp2! = "."
      is the space that should be removed leaving

      Code:
      !=
      as the operator.

      Comment

      Working...
      X