BookmarkSubscribeRSS Feed
LucyDang
Obsidian | Level 7

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!

1 REPLY 1
mkeintz
PROC Star

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.

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 538 views
  • 0 likes
  • 2 in conversation