Fill empty rows by last row non empty?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Fill empty rows by last row non empty?

jfca283
This post has NOT been accepted by the mailing list yet.
Hi
This is so simple, but i can't do it.




The idea is fill in the empty rows in v1 by the last non-empty value. If v1 has a number, leave it and keep filling in the empty rows. The desired result will be like v2. Simple, but frustrating to perform it by a newbie stata user. Thanks for your help and time.
Reply | Threaded
Open this post in threaded view
|

Re: Fill empty rows by last row non empty?

Tinh Doan
This post has NOT been accepted by the mailing list yet.
This post was updated on .
If you have a variable for ID then it is very easy

egen v3=max(v1), by(id)

replace v1=v3 if v1==.

bro

drop v3


Tinh Doan
Reply | Threaded
Open this post in threaded view
|

Re: Fill empty rows by last row non empty?

jfca283
This post has NOT been accepted by the mailing list yet.
Thanks. It worked fine.