Creating Dummies for calendar effects (2)

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

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Creating Dummies for calendar effects (2)

Postby trubador » Wed Apr 25, 2012 3:58 am

There is more than one way to do that. Below you can find two of them:

Code: Select all

%may = "05/01 05/02 05/03" %oct= "09/30 10/01 10/02 10/03 10/04 10/05 10/06" series dum1 = 0 series dum2 = 0 for !i = 1 to @wcount(%may) dum1 = @recode(@datestr(@date,"MM/DD")=@word(%may,!i),1,dum1) next for !j = 1 to @wcount(%oct) dum2 = @recode(@datestr(@date,"MM/DD")=@word(%oct,!j),1,dum2) next

Code: Select all

%may = "05/01 05/02 05/03" %oct= "09/30 10/01 10/02 10/03 10/04 10/05 10/06" series dum1 = 0 series dum2 = 0 smpl if @datestr(@date,"MM/DD")>=@wleft(%may,1) and @datestr(@date,"MM/DD")<=@wright(%may,1) dum1 = 1 smpl if @datestr(@date,"MM/DD")>=@wleft(%oct,1) and @datestr(@date,"MM/DD")<=@wright(%oct,1) dum2 = 1 smpl @all

Sissy
Posts: 30
Joined: Thu Apr 19, 2012 1:59 am

Re: Creating Dummies for calendar effects (2)

Postby Sissy » Wed Apr 25, 2012 4:58 am

Thanks a lot for these 2 codes.
However,the first code did not work because the Eviews 7 Student Version does not provide programs apparently.
So I tried the second code, but an error message tells me "Error in the sample: the %MAY is not defined ". Could you help me to resolve this problem, please ?

Thanks in advance.

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Creating Dummies for calendar effects (2)

Postby trubador » Wed Apr 25, 2012 5:50 am

This should work:

Code: Select all

string may = "05/01 05/02 05/03" string oct= "09/30 10/01 10/02 10/03 10/04 10/05 10/06" series dum1 = 0 series dum2 = 0 smpl if @datestr(@date,"MM/DD")>=@wleft(may,1) and @datestr(@date,"MM/DD")<=@wright(may,1) dum1 = 1 smpl if @datestr(@date,"MM/DD")>=@wleft(oct,1) and @datestr(@date,"MM/DD")<=@wright(oct,1) dum2 = 1 smpl @all

Sissy
Posts: 30
Joined: Thu Apr 19, 2012 1:59 am

Re: Creating Dummies for calendar effects (2)

Postby Sissy » Wed Apr 25, 2012 5:56 am

Thanks a lot. It totally works :lol:

Sissy
Posts: 30
Joined: Thu Apr 19, 2012 1:59 am

Re: Creating Dummies for calendar effects (2)

Postby Sissy » Fri Apr 27, 2012 12:04 am

Hello,

I have another problem considering non-fixed holiday periods:

I need to regress daily (7 weekdays) prices against some monetary policy variables. But in my regression, calendar effects have to be controled. Calendar effects correspond to Chinese holidays. In order to take calendar effects into account, I'd like to create a dummy variable,taking the value 1, for the following Chinese holidays (MM/DD/YYYY) which are not the same for each year:

02/06/2008, 02/07/2008, 02/08/2008, 02/09/2008, 02/10/2008, 02/11/2008, 02/12/2008, 01/25/2009, 01/26/2009, 01/27/2009, 01/28/2009, 01/29/2009, 01/30/2009, 01/31/2009, 02/13/2010, 02/14/2010, 02/15/2010, 02/16/2010, 02/17/2010, 02/18/2010 and 02/19/2010 .

My daily (7 weekdays) sample runs from 12/01/2007 to 04/27/2010.

Could you help me to resolve my problem, please ?

Thanks.

EViews Esther
EViews Developer
Posts: 149
Joined: Fri Sep 03, 2010 7:57 am

Re: Creating Dummies for calendar effects (2)

Postby EViews Esther » Fri Apr 27, 2012 8:57 am

This will work.

Code: Select all

%holidays= "02/06/2008 02/07/2008 02/08/2008 02/09/2008 02/10/2008 02/11/2008 02/12/2008 01/25/2009 01/26/2009 01/27/2009 01/28/2009 01/29/2009 01/30/2009 01/31/2009 02/13/2010 02/14/2010 02/15/2010 02/16/2010 02/17/2010 02/18/2010 02/19/2010" series dummy = 0 for !i = 1 to @wcount(%holidays) dummy = @recode(@datestr(@date,"MM/DD/YYYY")=@word(%holidays,!i),1,dummy) next smpl @all


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests