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

Hello,

 

I have a time series sample of 4000 firms over 18 years period (2000-2017). I am trying to find a way to use the daily returns in order to estimate the annual beta for each stock. I am unsure of what code to use. Any advice or guidance on how to structure my SAS code is highly appreciated. (SAS version 9.4)

 

My data is structured as follows:

 

PERMCO           DATE         COMPANY_NAME            RETURN        MARKET_RETURN       YEAR         PERMCO&YEAR

153                  2000-02-01                                               -0.15                                                    2000            1532000 

153                  2000-02-02                                                0.1                                                       2000

153                  2000-02-03                                                 0.2                                                       2000

153

 

.

.

.

153                  2017-12-28 

674

674

674

.

.

.

2114

2114

211

etc...

 

I would like the output to look something like shown below: (1 beta for each stock per year)

 

PERMCO             YEAR            BETA

153                      2000              

153                      2001

153                      2002          

674                      2015

2114                    2017 

etc...

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
model RETURN = MARKET_RETURN; CAPM beta is just the regression coefficient you can find at OUT=WANT table. beta(correlation ) is covariance of RETURN with MARKET_RETURN when both RETURN and MARKET_RETURN have 0 mean ,1 std .

View solution in original post

4 REPLIES 4
Ksharp
Super User

@Rick_SAS wrote a blog about how to run thousands of Regression before.


proc reg data=have outest=want;

by PERMCO             YEAR ;

model  RETURN = date;

quit;


omars92
Calcite | Level 5
Sorry, I should have specified that I’m trying to estimate each stock’s annual CAPM beta (ideosyncratic risk). I have thought of estimating the covariance of RETURN with MARKET_RETURN by PERMCO YEAR and divide by the variance of MARKET return but cannot find a way to get the covariance value without the covariance matrix
Ksharp
Super User
model RETURN = MARKET_RETURN; CAPM beta is just the regression coefficient you can find at OUT=WANT table. beta(correlation ) is covariance of RETURN with MARKET_RETURN when both RETURN and MARKET_RETURN have 0 mean ,1 std .
omars92
Calcite | Level 5
Thank you Ksharp. The code worked perfectly.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 5431 views
  • 0 likes
  • 2 in conversation