Page 1 of 2

generate dummy for weekday

Posted: Thu Oct 02, 2014 12:08 pm
by ecofin
hi,
i have 574 obs weekly, i would like to create dummy equal 1 for the first and last week in the month for every years.
thanks in advance.

Re: generate dummy for weekday

Posted: Thu Oct 02, 2014 1:16 pm
by EViews Gareth
What is the first week of a month? Weeks and months do not align.

Re: generate dummy for weekday

Posted: Sun Oct 05, 2014 10:26 am
by ecofin
1-there is no solution for this case, can you solve this problem in the future Mr Gareth by new function for this case.
2-now if i would create dummy equal to 1 for the first third fifth month...etc for every years what can i do? just i have manipulate data by this function but I could not get the desired result, or if there is another way.

Code: Select all

smpl @all series dum=0 smpl if @mod(@year,1)=0 and @mod(@month,3)<2 dum=1
thanks in advance.

Re: generate dummy for weekday

Posted: Sun Oct 05, 2014 12:08 pm
by EViews Gareth
I don't think you understood.

Ignoring EViews, for the moment, how do you define the first week of a month?

Re: generate dummy for weekday

Posted: Sun Oct 05, 2014 12:49 pm
by ecofin
you mean the dated-regular frequancy (weekly)
1-create dummy equal 1 for the first and last week in the month for every years.
2-create dummy eqaul 1 for the first third month...etc for every years.
see the picture below, I have ateched my workfile.

Re: generate dummy for weekday

Posted: Sun Oct 05, 2014 1:10 pm
by startz
The first day of October this year was a Wednesday. Is the week in which Sunday was September 28 the last week of September or the first week of October?

Re: generate dummy for weekday

Posted: Sun Oct 05, 2014 1:12 pm
by EViews Gareth
Again, ignore EViews for the moment. Just define, in words, what the first week of a month is.

Re: generate dummy for weekday

Posted: Sun Oct 05, 2014 1:54 pm
by ecofin
the first week of a month is Monday. sorry! :oops:

Re: generate dummy for weekday

Posted: Sun Oct 05, 2014 2:04 pm
by startz
the first week of a month is Monday. sorry! :oops:
Would I be reading your definition correctly to say that the month that a week belongs to is defined by the month that the Monday of that week belongs to?

Re: generate dummy for weekday

Posted: Mon Oct 06, 2014 4:43 am
by ecofin
how can we solve this problem Mr. Startz if it is your case.

Re: generate dummy for weekday

Posted: Mon Oct 06, 2014 9:44 am
by EViews Gareth
Which day of the week is your workfile structured on? (i.e. in your workfile, which day of the week do weeks start on)?

Re: generate dummy for weekday

Posted: Mon Oct 06, 2014 9:55 am
by EViews Gareth
Assuming your weeks start on a Monday (which 01-01-1990 was),

Code: Select all

'day at the beginning of this week (a monday) is in the first seven days of this month series first = @date < @datefloor(@date,"month") + 7 'day at the beginning of next week (a monday) is within the next month series last = @enddate+1 >= @dateadd(@datefloor(@date,"month"),1, "month")

Re: generate dummy for weekday

Posted: Mon Oct 06, 2014 10:26 am
by ecofin
it's that what i need :) thanks Mr Gareth & Mr Startz.
for my second question: create dummy equal 1 for the 1st month 3rd month 5th month...etc, I could not get the desired result by this:

Code: Select all

smpl @all series dum=0 smpl if @mod(@year,1)=0 and @mod(@month,3)<2 dum=1
can you help me.

Re: generate dummy for weekday

Posted: Mon Oct 06, 2014 11:07 am
by EViews Gareth
Use the @month function.

Re: generate dummy for weekday

Posted: Mon Oct 06, 2014 12:15 pm
by ecofin
I have solved my case.
thanks for all your efforts :D
kind regards ecofin.