Announcement

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

  • Loop does not end

    Hello everyone,

    I am a beginner user of stata and was trying to create a loop to fill the missing values of a variable. To do that I used stored data in r(N). However the loop should conclude at some point but it does not end at all.
    count if missing(unemplength)
    return list, all

    while `r(N)' >= 1 {
    replace unemplength = unemplength[_n+1] if missing(unemplength)
    count if missing(unemplength)
    return list, all
    }
    This is my relevant part of the code. r(N) should become 0 at some point but it gets stuck at 8 somehow. I could not figure out what is wrong. Any help is appreciated!

  • #2
    Do you have panel data?

    The technique of reversing time discussed at https://www.stata.com/support/faqs/d...issing-values/ may be a better way to do what I think you are trying to do.

    Comment


    • #3
      Originally posted by Nick Cox View Post
      Do you have panel data?

      The technique of reversing time discussed at https://www.stata.com/support/faqs/d...issing-values/ may be a better way to do what I think you are trying to do.
      Yes! I was able to do that thank you very much!

      Comment

      Working...
      X