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

Dear mkeniz,

 

I have difficulty to understand the generated output by sas program you advised. I would like to compute the following BHAR:

Buy and Hold Abnormal return= ((1+return(m1))(1+return(m2))----(1+return(m12)) - (1+marketreturn(m1)(1+marketreturn(m2))---(1+marketreturn(m12)), where m1=closemonth-11, m2=closemonth-10, m3=closemonth-9, m4=closemonth-8, m5=closemonth-7, --- m12=closemonth

 

As shown in the excel sheet, the computed values in three different ways  are different. 

 

computed value by original definition above: 0.052

computed value by log and exponential: 0.023

computed value by current sas program: 0.388

 

It will be highly appreciative if you can give an idea how to fix program to generate the closest computed value by original definition (0.052).

 


data c4;
** Generate 12-month rolling benchmark returns **
** Do this only once and save in an array **;
if _n_=1 then do until (end_of_benchmark);
set benchmark end=end_of_benchmark;
array bmrk_ret {1990:2019,1:12} _temporary_ ;
array logplusone {12} _temporary_;
y=year(date);
m=month(date);
logplusone{m}=log(1+vwretd);
if n(of logplusone{*})=12 then bmrk_ret{y,m}=exp(sum(of logplusone{*}));
end;
set ch2;
by permno;
if first.permno then call missing(of logplusone{*});
m=month(date);
y=year(date);
logplusone{m}=log(1+ret);
if closemonth^=.;
if n(of logplusone{*})=12 then bhar=exp(sum(of logplusone{*})- bmrk_ret{y,m});
run;

 

Thank you

Joon1

 

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

It looks like a misplaced close parens:

 

Instead of 

if n(of logplusone{*})=12 then bhar=exp(sum(of logplusone{*})- bmrk_ret{y,m});

 

bmrk_ret{y,m} was already exponentiated, so it should not be inside another EXP() function.  Try this:

 

if n(of logplusone{*})=12 then bhar=exp(sum(of logplusone{*}))- bmrk_ret{y,m};

I've been mostly offline lately, so apologies for the tardy response.

 

 

--------------------------
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

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

View solution in original post

5 REPLIES 5
joon1
Quartz | Level 8

Hi ChrisNZ,

 

Thanks for your comment

Could you please clarify your comment? I don't understand your comment.

Joon1

ChrisNZ
Tourmaline | Level 20

You start your question with:

 

Dear mkeniz,

 

which I assume means you directed your question to @mkeintz ?

mkeintz
PROC Star

It looks like a misplaced close parens:

 

Instead of 

if n(of logplusone{*})=12 then bhar=exp(sum(of logplusone{*})- bmrk_ret{y,m});

 

bmrk_ret{y,m} was already exponentiated, so it should not be inside another EXP() function.  Try this:

 

if n(of logplusone{*})=12 then bhar=exp(sum(of logplusone{*}))- bmrk_ret{y,m};

I've been mostly offline lately, so apologies for the tardy response.

 

 

--------------------------
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

--------------------------
joon1
Quartz | Level 8

Thank you so much, mkeintz. I greatly appreciate for your kind advice. Your code works well.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 5 replies
  • 1320 views
  • 2 likes
  • 3 in conversation