Hi,
I have a series that has NAs for the first, say, 20 periods and then non-na values. How do I "fill" the NAs up to the first non-na value with the first non-na value?
If the NAs were located at the end of the series, x=@recode(x=na,x(-1),x) works but I can't manage to work a variation of this expression for the question above.
Could you please help?
Thanks,
Javier
Fill NA values with first non-NA value
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Fill NA values with first non-NA value
Identify the first obs, get the value in that period, assign to the prior obs...
Code: Select all
smpl @all
series newx = x
scalar val = @first(x)
scalar id = @ifirst(x)
smpl @first @first+id-2
newx = val
smpl @all
show newx x
Who is online
Users browsing this forum: No registered users and 2 guests
