BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
abdulla
Pyrite | Level 9

Hi, I need urgent help for SAS code for the attached data. 

I need to know the code for an estimated event window(-5, -2) and event window for (-1, 1). I highlighted the event date. 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@abdulla wrote:
You should know first what event study is. Without knowing anything properly, please don't ask logic behind anything. It is like a childish question for someone who has idea about event study.

Since Wikipedia only has an entry for "event window" on the page: https://en.wikipedia.org/wiki/Event_study and does not define the term it strongly implies that the user has to know what an "event" is and what the duration of an "event window" would be.

 

There is apparently no standard or fixed definition though it does seem to have some sort of time component. If I am incorrect with this statement please post somewhere I can find a standard definition.

 

I find at https://eventstudymetrics.com/index.php/9-steps-to-follow-when-performing-a-short-time-study/

Once you have chosen a model and gathered all necessary data for expected return estimation, you need to determine the estimation window and the event window. The two windows do not overlap, i.e., the trading days prior to the event day which are part of the event window are not part of the estimation window. The estimation window is the period of trading days (before the event date) that is used to estimate the expected return for each asset and each event (using the constant mean return model, the market model, or any other of the aforementioned models). The event window is the period of trading days over which you want to calculate abnormal returns. An event window of one day, abbreviated [0], only includes the event day itself. In many studies the maximum event window includes 41 trading days symmetrically surrounding the identified event day, abbreviated [-20,+20].

So if your -5 and 2 is supposed to mean 5 days before and 2 days after a given date, what is so hard about saying that?

But that still brings up -How  do we tell from your sample data in a generic values of the data what dates are of interest? And if the interval is going to change how to determine the different interval. To write a program we need rules that use the  data.

 

When you have a date that you want to compare an interval then you may want INTNX or INTCK functions. But you will need to tell us how to 1) determine which date is the base date, 2) how to determine the interval for any of those given base dates and 3) what the resulting data set is supposed to look like with the identified intervals.

 

Example of finding 5 days before and 2 days after a given date:

data example;
   x='15JAN2019'd;
   fivedaysprior = intnx('day',x,-5);
   twodaysafter = intnx('day',x,2);
   format x fivedaysprior twodaysafter date9.;
run;

 

 

 

View solution in original post

12 REPLIES 12
Reeza
Super User

Welcome to the SAS forum. You haven't provided enough information to help you out here. How do you know it goes from -5 to 2? Why those rows, what's the logic in identifying those records? Have you tried anything so far?


In general, you're more likely to get a response if you post your question and data directly into the forum, rather than as an attachment. 

 

data have;
informat permno $8. date yymmdd10. returns value_weighted_return equal_weighted_Return 32.7;
input PERMNO $  Date    Returns     value_weighted_return   equal_weighted_Return;
cards;
10696   20100104    0.019596    0.017045    0.019077 
10696   20100105    0.004248    0.003362    0.002451 
10696   20100106    -0.00423    0.001769    0.00318
10696   20100107    -0.004653   0.002821    0.006834
10696   20100108    -0.011179   0.004161    0.007224
10696   20100111    0.005344    0.001122    0.003547
10696   20100112    -0.008792   -0.011004   -0.010224
10696   20100113    0.008457    0.008537    0.008648
10696   20100114    -0.002864   0.002293    0.004398
10696   20100115    -0.016615   -0.011348   -0.008675
10838   20100618    -0.032258   0.001659    0.002824
10838   20100621    -0.044444   -0.004353   -0.006434
10838   20100622    -0.046395   -0.016232   -0.013948
10838   20100623    -0.000122   -0.003042   -0.002017
10838   20100624    0.012195    -0.016297   -0.012466
10838   20100625    0.024096    0.006027    0.010236
10838   20100628    -0.047059   -0.003338   -0.004938
10838   20100629    -0.037037   -0.032917   -0.031228
10838   20100630    -0.012821   -0.009028   -0.00558
10838   20100701    -0.025974   -0.004084   -0.007698
10838   20100702    0.02    -0.004793   -0.00443
10838   20100706    -0.08366    0.003311    -0.00643
;;;;
run;

@abdulla wrote:

Hi, I need urgent help for SAS code for the attached data. 

I need to know the code for an estimated event window(-5, -2) and event window for (-1, 1). I highlighted the event date. 


 

abdulla
Pyrite | Level 9

The window is from (-5 to -2). The highlighted one is the day of an event. I posted this as an example. My file is super big. If I get code for this example I can apply that for the whole data set. 

Reeza
Super User

@abdulla wrote:

The window is from (-5 to -2). The highlighted one is the day of an event. I posted this as an example. My file is super big. If I get code for this example I can apply that for the whole data set. 


What is the logic to identify those two rows though? How do you know that's the 'day of an event'? I see nothing that uniquely identifies those rows.

abdulla
Pyrite | Level 9
-5 to -2 is not two rows. The highlighted ones are the day of an event. These are just an example, not the real one. The real file is super big. Please have a good idea about an event study. Then you will see the logic of estimation window and evaluation window.
ballardw
Super User

@abdulla wrote:
-5 to -2 is not two rows. The highlighted ones are the day of an event. These are just an example, not the real one. The real file is super big. Please have a good idea about an event study. Then you will see the logic of estimation window and evaluation window.

WHY those dates? What rule based on values in the data set tells us those two records are any more important in determining a "window".

 

Where do 5 and -2 come from. Neither of those values is in the data.

The highlighted rows are the "day of an event". There are possible date values but I would suspect the dates are seven months apart, so not a "day" in any apparent form.

 

Without a lot more detail about what the file represents I don't see anything defining  "estimation window and evaluation window"

abdulla
Pyrite | Level 9
You should know first what event study is. Without knowing anything properly, please don't ask logic behind anything. It is like a childish question for someone who has idea about event study.
abdulla
Pyrite | Level 9

Hi, I need urgent help for SAS code for the attached data. 

I need to know the code for an estimated event window(-5, -2) and an evaluation window for (-1, 1). I highlighted the event dates. This is just an example. My real data is huge. If anyone can give the code for this example, I can apply that to my real data. 

ballardw
Super User

@abdulla wrote:
You should know first what event study is. Without knowing anything properly, please don't ask logic behind anything. It is like a childish question for someone who has idea about event study.

Since Wikipedia only has an entry for "event window" on the page: https://en.wikipedia.org/wiki/Event_study and does not define the term it strongly implies that the user has to know what an "event" is and what the duration of an "event window" would be.

 

There is apparently no standard or fixed definition though it does seem to have some sort of time component. If I am incorrect with this statement please post somewhere I can find a standard definition.

 

I find at https://eventstudymetrics.com/index.php/9-steps-to-follow-when-performing-a-short-time-study/

Once you have chosen a model and gathered all necessary data for expected return estimation, you need to determine the estimation window and the event window. The two windows do not overlap, i.e., the trading days prior to the event day which are part of the event window are not part of the estimation window. The estimation window is the period of trading days (before the event date) that is used to estimate the expected return for each asset and each event (using the constant mean return model, the market model, or any other of the aforementioned models). The event window is the period of trading days over which you want to calculate abnormal returns. An event window of one day, abbreviated [0], only includes the event day itself. In many studies the maximum event window includes 41 trading days symmetrically surrounding the identified event day, abbreviated [-20,+20].

So if your -5 and 2 is supposed to mean 5 days before and 2 days after a given date, what is so hard about saying that?

But that still brings up -How  do we tell from your sample data in a generic values of the data what dates are of interest? And if the interval is going to change how to determine the different interval. To write a program we need rules that use the  data.

 

When you have a date that you want to compare an interval then you may want INTNX or INTCK functions. But you will need to tell us how to 1) determine which date is the base date, 2) how to determine the interval for any of those given base dates and 3) what the resulting data set is supposed to look like with the identified intervals.

 

Example of finding 5 days before and 2 days after a given date:

data example;
   x='15JAN2019'd;
   fivedaysprior = intnx('day',x,-5);
   twodaysafter = intnx('day',x,2);
   format x fivedaysprior twodaysafter date9.;
run;

 

 

 

abdulla
Pyrite | Level 9
Please check the attachment I have just posted in my previous post. That contains the actual data. And I need to know the code for the following window
(estimate the parameters in the period -250,-10).
It is like before the event day(which is different for different stock) you have to select (-250, -10) days for every group (by permno) then you have to find regression. For me regreesion is not a problem. The problem is the event date for each group(permno) is different and the (-250, -10) period will be different for different stock . Now how will I code so that I can get my period in a work file. I have delete the other observations which are not in the (-250, -10) period from the event day.
By the way I highlighted the event day. And my Permno are of 400 different stocks. I just gave you two stocks as an example.
ballardw
Super User

@abdulla wrote:
Please check the attachment I have just posted in my previous post. That contains the actual data. And I need to know the code for the following window
(estimate the parameters in the period -250,-10).
It is like before the event day(which is different for different stock) you have to select (-250, -10) days for every group (by permno) then you have to find regression. For me regreesion is not a problem. The problem is the event date for each group(permno) is different and the (-250, -10) period will be different for different stock . Now how will I code so that I can get my period in a work file. I have delete the other observations which are not in the (-250, -10) period from the event day.
By the way I highlighted the event day. And my Permno are of 400 different stocks. I just gave you two stocks as an example.

And my program code cannot determine what you may have highlighted as an example and really cannot tell which base date you need.

 

A rule to allow the data to tell which is the date of interest for each event like "earliest date for a Permno where variable x exceeds value y" or "last date some value occurs", or value changes by z amount or greater. Something that can identify the date of the event in question.

abdulla
Pyrite | Level 9
Thank you for your time. If I get time I will explain the situation later.
Reeza
Super User

@abdulla wrote:
You should know first what event study is. Without knowing anything properly, please don't ask logic behind anything. It is like a childish question for someone who has idea about event study.

That isn't very polite. Please remember you're asking on a programming forum for help. If you have subject specific terms, it is up to you to define that or post on a subject specific forum. Good Luck. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 12 replies
  • 4725 views
  • 4 likes
  • 3 in conversation