Hi! I am totally new to SAS and primarily use R. I have been struggling with this problem since last two days. My data is as below - Comp date time returns 1 12-Aug-97 10:23:38 0.919292648 1 12-Aug-97 10:59:43 0.204139521 1 13-Aug-97 11:03:12 0.31909242 1 14-Aug-97 11:10:02 0.989339371 1 14-Aug-97 11:19:27 0.08394389 1 15-Aug-97 11:56:17 0.481199854 1 16-Aug-97 13:53:45 0.140404929 1 17-Aug-97 10:09:03 0.538569786 2 14-Aug-97 11:43:49 0.427344962 2 14-Aug-97 11:48:32 0.154836294 2 15-Aug-97 14:03:47 0.445415114 2 15-Aug-97 9:38:59 0.696953041 2 15-Aug-97 13:59:23 0.577391987 2 15-Aug-97 9:10:12 0.750949097 2 15-Aug-97 10:22:38 0.077787596 2 15-Aug-97 11:07:57 0.515822161 2 16-Aug-97 11:37:26 0.862673945 2 17-Aug-97 11:42:33 0.400670247 2 19-Aug-97 11:59:34 0.109279307 This is just a sample data. It has company, date and time level returns on share price for a period of 10 years. I need to calculate autocovariance (degree 1) of returns over a period of 10 days for each Comp and date value combination. As you can see, my time series is not continuous, it has breaks for weekends and public holidays. In such cases, if i need to take a 10 day range, I can't use a intnk function as adding 10 days to the date column might include a saturday/sunday for which I don't have data for and hence, my autocovariance value will be compromised. How do I make this range dynamic? I have gotten till this part -
data ds1;
set ds;
by comp;
LAG_RET = lag(RET);
IF FIRST.comp THEN DO;
LAG_RET = .;
END;
run;
For calculating correlation and covariances -
proc corr data=ds1 outp=Corr
by comp date;
cov; /** include covariances **/
var ret lag_ret;
run;
But how do I insert the event window for each date, store_id combination? My final output should look something like this - Comp Date autocovariance 1 12-Aug-97 ... 1 13-Aug-97 ... If anyone can suggest a methodology to do this, It would be really helpful. Thanks!
... View more