Hi
How can I get the smpl of the most recent period with consecutive positive values for a series?
Thomas
Smpl of most recent consecutive positive values
Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator
-
- Posts: 540
- Joined: Fri Apr 15, 2011 5:35 am
-
- EViews Developer
- Posts: 563
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Smpl of most recent consecutive positive values
Hello,
How about this, where "x" is the series of interest:
The temporary auxiliary series "tmp" creates a numbering for every region of consecutive (non)positive values in such a way that the last positive region is always associated with the number one, and "tmp2" is a pseudo-dummy series (na/1 instead of 0/1) useful for retrieving the endpoints of said region.
How about this, where "x" is the series of interest:
Code: Select all
genr(r) tmp = @nan(tmp(1) + ((x(1) > 0) <> (x > 0)), x > 0)
series tmp2 = @recode(tmp = 1, 1, na)
string first = tmp2.@first
string last = tmp2.@last
smpl {first} {last}
The temporary auxiliary series "tmp" creates a numbering for every region of consecutive (non)positive values in such a way that the last positive region is always associated with the number one, and "tmp2" is a pseudo-dummy series (na/1 instead of 0/1) useful for retrieving the endpoints of said region.
-
- Posts: 540
- Joined: Fri Apr 15, 2011 5:35 am
Re: Smpl of most recent consecutive positive values
Excellent, thanks!
Who is online
Users browsing this forum: No registered users and 39 guests