Hello SAS gurus,
I am calculating the cumulative abnormal return for an event study. I used the event window of (-180, +1). 0 is the event; +1 day is the next day of the event. I suppose to calculate +1 day in workdays only.
Please see the example datalines below. In this file, I have some variables for one stock: date, eventdate, ticker $, mrkReturn (return of the market), return (of this stock), before (#of days before/after the event date, before=date-eventdate), and wday (check the weekday of each date, from 2=monday to 6=friday).
data now;
input date eventdate ticker $ mrkReturn return before wday;
datalines;
20120830 20120831 AA -0.007806 -0.01171 -1 5
20120831 20120831 AA 0.005073 0.014218 0 6
20120904 20120831 AA -0.001166 -0.01635 4 3
;
run;
Normally, if the event date fall in (2,5), that's fine because the +1 day I want to use to calculate the abnormal return will be the following day (3,6 respectively). However, if the event day falls in wday=6 (Friday), I need to calculate the abnormal return on Monday (skip Sat, Sunday, and in this case, it even skipped Monday (2012/09/03-the labor day of 2012) because it is not a trading day). Moreover, in this file the variable before = 4 while I need to make the variable "before" = 1 for later calculation.
So my questions are:
How can I make a program that automatically recognizes the following trading day (not weekend or holidays) as a "+1" day of the event and sets the "before" variable =1?
Is that likely that I can create a code and assign "if EventDate = Date = Friday, then retain & write the next row (which record data for a trading day) to output table & set the variable "before" of that row = 1"?
Thank you!
Lucy:
As per my response to your other posting, do you have a daily price file. If so, please show us what it looks like, and we can show how to make a trading-day calendar.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.