SAS Code for Stock Price Synchronicity? 
Posted: 14 June 2014 08:53 PM   [ Ignore ]
Newbie
Rank
Total Posts:  4
Joined  2014-06-14

Hi!

I am currently trying to calculate stock price synchronicity.
I am wondering if anybody knows the SAS code for this measure.

I would greatly appreciate your help!

Profile
 
 
Posted: 15 June 2014 11:51 AM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi Snowflake,

How is that measure constructed/computed?

best regards,

Joost

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile
 
 
Posted: 15 June 2014 06:24 PM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  4
Joined  2014-06-14

Hi Joost,

Thank you for your response.

Stock price synchronicity is calculated in two steps (I have attached a file which contains two formulas).


First, using daily returns data, the market model is computed for each stock and each year.

I have an idea (as well as codes) how to calculate all the variables in the equation (1) but INDRET, value-weighted industry returns,


Would really appreciate it if you could help me with this variable if the code for stock price synchronicity is not available. 

Thanks a lot!

Image Attachments
Screen_Shot_2014-06-16_at_9.23.51_am.png
Profile
 
 
Posted: 15 June 2014 08:27 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  901
Joined  2011-09-19

hi Snowflake,

Ok; thanks, that is clear.

That indeed takes some coding. It looks like you will need:
- industry membership (SIC, NAICS, etc)
- shares outstanding (to compute market cap)
- stock returns (daily or monthly, depending on size of window)

You will need to decide how ‘often’ to compute the market cap for each firm (does it need to be updated daily, quarterly, yearly, etc).

The value-weighting itself can be done in two ways: either proc sql (like here: http://support.sas.com/documentation/cdl/en/sqlproc/62086/HTML/default/viewer.htm#a001349249.htm) or in a data step, where you do a ‘by’ (grouping) and ‘retain’ variables to incrementally compute the value-weighted return. The ‘by’ variable would be the industry-period (for example, industry-day or industry-quarter).

Example; assuming you want to compute daily industry-weighted return. I am assuming you have a dataset with SIC (industry), date, return (raw return), size (market cap). The value-weighed return can be computed something like this (not tested)

/* create unique key to identify industry-day */
data inputKeys;
set input;
key SIC || date;
run;

/* sort dataset by 'key'  (required for datastep with 'by' grouping)*/
proc sort data inputKeysby key;run;

data indweighted;
set inputKeys;
/* the 'by' statement is part of the magic, the code-block is executed using all obs with the same value for (in this case) 'key'
   withouth the 'by' statement, it would compute value-weighted returns for the whole sample as opposed to doing this by industry
 */
by key;
/* retain makes SAS 'remember' the values of these variables as it goes over the rows */
retain totMarCap totRet;
/* first observation in each group: set variables to 0 */
if first.key then do;
  
totMarCap 0;
  
totRet 0;
end;
/* update statistics as you go*/
totMarCap totMarCap size;
totRet totRet size * return;
/* last.key means last firm in industry-group: compute the actual value-weighted return*/
if last.key then indRet totRet totMarCap;
if 
last.key then output;
run

The main idea is to do the calculations by the right ‘group’, and use ‘retain’ to remember the calculations as you go over the firms in that industry.

Hope this helps,

Joost

 Signature 

To reply/post new questions: Please use the group WRDS/SAS on Google Groups! http://groups.google.com/d/forum/wrdssas

Profile