Setting a smpl for a time period before a given date

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

Gayle
Posts: 6
Joined: Tue Jun 19, 2012 7:26 am

Setting a smpl for a time period before a given date

Postby Gayle » Tue Jun 19, 2012 7:50 am

I'm doing an event study. I have stock return data from 1965 to 2012. For each announcement, I want to analyze stock values 250 to 30 days prior to the announcement. How can I specify a sample (smpl) that consists of -250 to -30 days before a given date? When I double click on "Sample", I can narrow the sample to the dates I want by typing 1/1/2000-250 1/1/2000-30. However, I have many dates so I would like to create program that automatically sets the correct sample by using a variable such as "anndate". That is, I'd like to specify anndate and then program "anndate - 250" or "anndate(-250). Any ideas?

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

Re: Setting a smpl for a time period before a given date

Postby EViews Gareth » Tue Jun 19, 2012 11:49 am

You can use the otod and dtoo functions to do that.

I'm not sure what format you currently have anndate in, but assuming it is a string containing a date, you could do something like:

Code: Select all

%anndate = "1/1/2000" %mydate = @otod(@dtoo(%anndate)-250)

Gayle
Posts: 6
Joined: Tue Jun 19, 2012 7:26 am

Re: Setting a smpl for a time period before a given date

Postby Gayle » Tue Jun 19, 2012 1:39 pm

Thanks for your prompt response. However, when I enter the commands you recommend, only "%anndate = "1/1/2000" works. When I add "@mydate = @otod(@dtoo(@anndate)-250) I receive the following error message: "Illegal date" Any ideas?

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

Setting a smpl for a time period before a given date

Postby EViews Gareth » Tue Jun 19, 2012 2:51 pm

You appear to have changed my % symbols into @ symbols for some reason.

Gayle
Posts: 6
Joined: Tue Jun 19, 2012 7:26 am

Re: Setting a smpl for a time period before a given date

Postby Gayle » Tue Jun 19, 2012 6:51 pm

Dang. I wrong the statements incorrectly in my request to you. I should have written: When I write "%mydate = @otod(@dtoo(%anndate)-250)" I receive the error message "Illegal date".

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

Setting a smpl for a time period before a given date

Postby EViews Gareth » Tue Jun 19, 2012 7:13 pm

Does the date 250 observations before %anndate exist in your workfile,

Gayle
Posts: 6
Joined: Tue Jun 19, 2012 7:26 am

Re: Setting a smpl for a time period before a given date

Postby Gayle » Wed Jun 20, 2012 5:35 am

Yes, I have daily data from 1965 to 2012.

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

Re: Setting a smpl for a time period before a given date

Postby EViews Gareth » Wed Jun 20, 2012 5:45 am

Post your workfile.

Gayle
Posts: 6
Joined: Tue Jun 19, 2012 7:26 am

Re: Setting a smpl for a time period before a given date

Postby Gayle » Thu Jun 21, 2012 2:19 pm

Workfile attached. I want to regress y on x, but only for days -250 to -30 before a specific date, e.g. 1/3/2000
Attachments
test data.wf1
I want to regress y on x, but only for days -250 to -30 before a specific date, e.g. 1/3/2000
(58.75 KiB) Downloaded 363 times

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

Re: Setting a smpl for a time period before a given date

Postby EViews Gareth » Thu Jun 21, 2012 2:22 pm

Code: Select all

%anndate = "1/1/2000" %startdate = @otod(@dtoo(%anndate)-250) %enddate = @otod(@dtoo(%anndate)-30) smpl {%startdate} {%enddate}

Gayle
Posts: 6
Joined: Tue Jun 19, 2012 7:26 am

Re: Setting a smpl for a time period before a given date

Postby Gayle » Thu Jun 21, 2012 6:04 pm

THANKS VERY MUCH! For some reason, the code you sent didn't work exactly on my computer. The following code does:
string anndate
string startdate
string enddate
anndate = "1/1/2000"
startdate = @otod(@dtoo(anndate)-250)
enddate = @otod(@dtoo(anndate)-30)
smpl {startdate} {enddate}

Again, many thanks!


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests