Page 1 of 1

Loop with creating series

Posted: Wed Mar 09, 2011 11:40 pm
by robbieboy74
Hello,

is it possible to create many different series using a loop?

I tried using a loop to create seasonal dummies, but i am having trouble. It only creates one, and it turns out wrong.

If, for example, you have daily data, and you want weekday, why doesnt this work?

for !i = 1 to 7

genr series(!i) = @weekday=!i

next

Re: Loop with creating series

Posted: Thu Mar 10, 2011 8:28 am
by EViews Gareth
If only there was some sort of introduction to programming that covered this sort of thing.

Re: Loop with creating series

Posted: Thu Mar 10, 2011 10:04 am
by robbieboy74
I already read that and I don't get it. I am not a programmer. All the codes I write don't run. But thanks for the pernicious sarcasm, it really makes it likely this forum will used again.

Re: Loop with creating series

Posted: Thu Mar 10, 2011 10:30 am
by tchaithonov
Just do this (remove the first line if you have a workfile opened already):

Code: Select all

wfcreate d7 1/1/2011 3/10/2011 group dummies @expand(@weekday) %weekdays = "Mon Tue Wed Thu Fri Sat Sun" for !i = 1 to 7 %weekday = @word(%weekdays,!i) %dum = dummies.@seriesname(!i) series dum_{%weekday} = {%dum} next
This creates 7 dummy series named dum_mon, dum_tue, dum_wed, etc. It should do what you are trying to accomplish.

Tchaithonov