Setting a smpl for a time period before a given date
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
Setting a smpl for a time period before a given date
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: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Setting a smpl for a time period before a given date
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:
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)
Re: Setting a smpl for a time period before a given date
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: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Setting a smpl for a time period before a given date
You appear to have changed my % symbols into @ symbols for some reason.
Re: Setting a smpl for a time period before a given date
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: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Setting a smpl for a time period before a given date
Does the date 250 observations before %anndate exist in your workfile,
Re: Setting a smpl for a time period before a given date
Yes, I have daily data from 1965 to 2012.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Setting a smpl for a time period before a given date
Post your workfile.
Re: Setting a smpl for a time period before a given date
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 362 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Setting a smpl for a time period before a given date
Code: Select all
%anndate = "1/1/2000"
%startdate = @otod(@dtoo(%anndate)-250)
%enddate = @otod(@dtoo(%anndate)-30)
smpl {%startdate} {%enddate}
Re: Setting a smpl for a time period before a given date
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!
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!
Who is online
Users browsing this forum: No registered users and 2 guests
