Hi, I am new to eviews and am trying to write some code that will set a variable equal to 1 if the date on the 20th of the month is a business day. If it is not a business day then the variable should be equal to 1 on the next business day.
I have written some code which is not quite doing what I would like. I am sure there is also a more efficient way to do this, any help is appreciated. The series is daily 7 day week.
series day_of_week=@weekday
smpl if (day_of_week<6)
series t= @recode(@day=20, 1, 0)
smpl if (day_of_week=6 and @day=20)
series t_sat = @recode(@day=20, 1, 0)
smpl @all
series t_sat =@recode(t_sat=na,0,1)
if t_sat=1 then series t= @recode(@day=22, 1, 0)
endif
smpl if (day_of_week=7 and @day=20)
series t_sun = @recode(@day=20, 1, 0)
smpl @all
series t_sun =@recode(t_sun=na,0,1)
if t_sun=1 then series t= @recode(@day=21, 1, 0)
endif
Due Dates on Weekends
Moderators: EViews Gareth, EViews Moderator
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13330
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Due Dates on Weekends
When you say Business Day, are you worried about holidays? If so, do you have a variable that indicates whether a day is a holiday?
Follow us on Twitter @IHSEViews
Re: Due Dates on Weekends
I am worried about holidays. Currently I am constructing a dummy equal to 1 when there is a public holiday.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13330
- Joined: Tue Sep 16, 2008 5:38 pm
-
- EViews Developer
- Posts: 565
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Due Dates on Weekends
I believe the following does what you want utilizing your holiday series public_hol:
Series target is the resulting indicator series, series tmp holds intermediate results and can be deleted. FYI, series tmp is an indicator of non-business days that need to be skipped over.
Code: Select all
series tmp = (@day = 20 or @nan(tmp(-1), 0) = 1) and (@weekday > 5 or public_hol = 1)
series target = (@day = 20 and tmp = 0) or @nan(@d(tmp) = -1, 0)
Series target is the resulting indicator series, series tmp holds intermediate results and can be deleted. FYI, series tmp is an indicator of non-business days that need to be skipped over.
Return to “General Information and Tips and Tricks”
Who is online
Users browsing this forum: No registered users and 4 guests