generate dummy for weekday

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

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

generate dummy for weekday

Postby ecofin » Thu Oct 02, 2014 12:08 pm

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.
Attachments
dummy-week.png
dummy-week.png (77.15 KiB) Viewed 12802 times

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

Re: generate dummy for weekday

Postby EViews Gareth » Thu Oct 02, 2014 1:16 pm

What is the first week of a month? Weeks and months do not align.

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

Re: generate dummy for weekday

Postby ecofin » Sun Oct 05, 2014 10:26 am

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.

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

Re: generate dummy for weekday

Postby EViews Gareth » Sun Oct 05, 2014 12:08 pm

I don't think you understood.

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

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

Re: generate dummy for weekday

Postby ecofin » Sun Oct 05, 2014 12:49 pm

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.
Attachments
ase-week.wf1
(17.75 KiB) Downloaded 460 times
weekly-dummy.png
weekly-dummy.png (75.83 KiB) Viewed 12761 times

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

Re: generate dummy for weekday

Postby startz » Sun Oct 05, 2014 1:10 pm

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?

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

Re: generate dummy for weekday

Postby EViews Gareth » Sun Oct 05, 2014 1:12 pm

Again, ignore EViews for the moment. Just define, in words, what the first week of a month is.

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

Re: generate dummy for weekday

Postby ecofin » Sun Oct 05, 2014 1:54 pm

the first week of a month is Monday. sorry! :oops:

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

Re: generate dummy for weekday

Postby startz » Sun Oct 05, 2014 2:04 pm

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?

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

Re: generate dummy for weekday

Postby ecofin » Mon Oct 06, 2014 4:43 am

how can we solve this problem Mr. Startz if it is your case.

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

Re: generate dummy for weekday

Postby EViews Gareth » Mon Oct 06, 2014 9:44 am

Which day of the week is your workfile structured on? (i.e. in your workfile, which day of the week do weeks start on)?

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

Re: generate dummy for weekday

Postby EViews Gareth » Mon Oct 06, 2014 9:55 am

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")

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

Re: generate dummy for weekday

Postby ecofin » Mon Oct 06, 2014 10:26 am

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.

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

Re: generate dummy for weekday

Postby EViews Gareth » Mon Oct 06, 2014 11:07 am

Use the @month function.

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

Re: generate dummy for weekday

Postby ecofin » Mon Oct 06, 2014 12:15 pm

I have solved my case.
thanks for all your efforts :D
kind regards ecofin.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests