Page 1 of 1
Input value at specific date
Posted: Wed May 11, 2016 11:12 am
by AntonioAcha
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
Re: Input value at specific date
Posted: Wed May 11, 2016 11:23 am
by startz
One way is
Code: Select all
smpl 2016m02 2016m02
dum_feb_2016 = 1
smpl @all
Re: Input value at specific date
Posted: Wed May 11, 2016 11:32 am
by EViews Gareth
Startz' is the best general solution, but in your case the best method is probably:
Re: Input value at specific date
Posted: Thu May 12, 2016 3:49 am
by ecofin
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.
Re: Input value at specific date
Posted: Thu May 12, 2016 4:25 am
by EViews Gareth
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.
Re: Input value at specific date
Posted: Thu May 12, 2016 5:38 am
by ecofin
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.
Re: Input value at specific date
Posted: Thu May 12, 2016 7:24 am
by EViews Gareth
Code: Select all
%freq = "d7"
wfcreate {%freq} 2016 2016
show @event("2016m2")
show @event("2016m2 2016m4", "mon-fri")
Is @event("2016m2") equal to 1?
Re: Input value at specific date
Posted: Thu May 12, 2016 10:37 am
by ecofin
I've got it!, thank you.
Re: Input value at specific date
Posted: Thu May 12, 2016 1:08 pm
by AntonioAcha
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
Re: Input value at specific date
Posted: Thu May 12, 2016 1:16 pm
by EViews Gareth
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?