Announcement

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

  • Replace values from bottom to top

    Dear Statalists,

    I have a dataset in the following shape for several counties and years:
    County Year Variable
    1 1977 -
    1 1978 -
    1 1979 -
    1 1980 3000
    1 1981 3000
    ... ... ...
    3 1977 -
    3 1978 -
    3 1979 -
    3 1980 4000
    3 1981 4000
    ... ... ...

    For all counties, the values for the years 1977 to 1979 are missing for "Variable" and I want to replace those missings with the value from the year 1980 of the respective county. I could find comments on how to fill in values from the top to the bottom but not vice versa. Does anyone have a suggestion for me? I suppose I will need a loop as I want to replace the values for several counties.
    Thank you in advance!
    Last edited by Joana Bennet; 18 Nov 2019, 07:38.

  • #2
    This FAQ

    https://www.stata.com/support/faqs/d...issing-values/

    is one of various places where this is discussed. In your data example ipolate, epolate would I think also work as you wish.

    Comment


    • #3
      Thank you Nick, I could find an answer through the link

      Comment

      Working...
      X