Input value at specific date

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

AntonioAcha
Posts: 21
Joined: Wed Jan 07, 2015 8:49 am

Input value at specific date

Postby AntonioAcha » Wed May 11, 2016 11:12 am

Hello, I have to create several dummies for different points in time, so I want to know if there is a way to input the "1" value in a serie using commands

for example (monthly data):

genr dum_feb_2016=0

For that variable (dum_feb_2016) I need to insert a 1 in the date 2016m02 leaving the rest of the serie as zeros.

Any help is appreciated

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: Input value at specific date

Postby startz » Wed May 11, 2016 11:23 am

One way is

Code: Select all

smpl 2016m02 2016m02 dum_feb_2016 = 1 smpl @all

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Input value at specific date

Postby EViews Gareth » Wed May 11, 2016 11:32 am

Startz' is the best general solution, but in your case the best method is probably:

Code: Select all

series dum = @event("2016m2")

ecofin
Posts: 182
Joined: Fri May 10, 2013 11:24 am

Re: Input value at specific date

Postby ecofin » Thu May 12, 2016 3:49 am

hi,
1/to input value one to at specific date it's easy series dum = @event("2016m2"), but what this mean [date2] and [basis] in this function @event("date1 [date2]", [basis]) its like @holiday function, could you explain when i use this function (@event) and can you give an example with this function to understand,
2/when i use this function to put value 1 for some specific days example series dum = @event("2005m2 2005m3 2005m5....etc") dosn't work.
suppose i have frequency monthly obs 93 from 2005m1 2012m9 93 what's the benefit of the @event.
thanks in advance.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Input value at specific date

Postby EViews Gareth » Thu May 12, 2016 4:25 am

Your post is a bit garbled, but I think the help system explains the function:
http://www.eviews.com/help/helpintro.ht ... on.html%23


This example probably highlights it pretty well too:

Code: Select all

%freq = "d7" wfcreate {%freq} 2016 2016 show @event("2016m2") show @event("2016m2", "mon-fri")
Change the frequency to different things to see the differences.

ecofin
Posts: 182
Joined: Fri May 10, 2013 11:24 am

Re: Input value at specific date

Postby ecofin » Thu May 12, 2016 5:38 am

ok i understand :D
1/in the help"date1 [date2]" mean that i can chose pair of dates but by this code i get error "Syntax error"

Code: Select all

series dum2= @event("2016m2" "2016m4" "2016m6 2016m7", "mon-fri")<>0
so what does mean [date2]? and how can do my pair "2016m2" "2016m4" "2016m6 2016m7" example by @event?
could you give me another example with pair of dates in the range.
2/this code make dummy for the second month in 2016
series dum1= @event("2016m2")<>0 but when i use series dum1= @event("2016m2")<>1 it can not reverse the dummy, all value take one.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Input value at specific date

Postby EViews Gareth » Thu May 12, 2016 7:24 am

Code: Select all

%freq = "d7" wfcreate {%freq} 2016 2016 show @event("2016m2") show @event("2016m2 2016m4", "mon-fri")

Is @event("2016m2") equal to 1?

ecofin
Posts: 182
Joined: Fri May 10, 2013 11:24 am

Re: Input value at specific date

Postby ecofin » Thu May 12, 2016 10:37 am

I've got it!, thank you.

AntonioAcha
Posts: 21
Joined: Wed Jan 07, 2015 8:49 am

Re: Input value at specific date

Postby AntonioAcha » Thu May 12, 2016 1:08 pm

Thanks all for the help, @event seems to be my solution, but one more question. Due to I need to do it a lot of times, I wrote this code:

for !i=1 to 12
for !j=1 to 6
genr dum_!i_201!j= @event("201!jm!i")
next
next

the part inside the brackets is generating an error, is there a way to make this?

If I can fix that, that code will create a code with a dummy for each month :)

regards

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Input value at specific date

Postby EViews Gareth » Thu May 12, 2016 1:16 pm

The precise answer to your question is:

Code: Select all

for !i=1 to 12 for !j=1 to 6 %date = "201" + @str(!j) + "m" + @str(!i) genr dum_!i_201!j= @event(%date) next next
But if you want to create a dummy for every month over a period, this is almost certainly not the best way to do it. What's the structure of your workfile (frequency, start/end date), and what do you plan on doing with the dummies?


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests