Hi, SAS community!
Urgently I need your help.
I have stock data with firm identifier (=CUSIP), stock date (=Date), and daily returns (=return).
d indicates an event day.
data have;
input CUSIP $ DATE :mmddyy10. return d;
format date mmddyy10.;
datalines;
0001241 6/28/1988 0.003 .
0001241 6/29/1988 0 .
0001241 6/30/1988 0 .
0001241 7/1/1988 0.018 .
0001241 7/4/1988 0.007 .
0001241 7/5/1988 0.003 .
0001241 7/6/1988 0.010 .
0001241 7/7/1988 0.031 .
0001241 7/8/1988 0.003 .
0001241 7/11/1988 0 .
0001241 7/12/1988 -0.017 .
0001241 7/13/1988 -0.006 .
0001241 7/14/1988 -0.027 .
0001241 7/15/1988 0.003 .
0001241 7/18/1988 -0.028 .
0001241 7/19/1988 0.011 .
0001241 7/20/1988 0 .
0001241 7/21/1988 0 .
0001241 7/22/1988 -0.010 .
0001241 7/25/1988 0.011 .
0001241 7/26/1988 0.010 .
0001241 7/27/1988 0 .
0001241 7/28/1988 0.010 .
0001241 7/29/1988 0.017 .
0001241 8/1/1988 0 .
0001241 8/2/1988 0 .
0001241 8/3/1988 -0.010 .
0001241 8/4/1988 -0.007 .
0001241 8/5/1988 0 .
0001241 8/8/1988 0 .
0001241 8/9/1988 -0.003 .
0001241 8/10/1988 -0.014 .
0001241 8/11/1988 0 .
0001241 8/12/1988 0 .
0001241 8/15/1988 -0.003 .
0001241 8/16/1988 -0.007 .
0001241 8/17/1988 0 .
0001241 8/18/1988 0 .
0001241 8/19/1988 0 .
0001241 8/22/1988 0 .
0001241 8/23/1988 -0.003 .
0001241 8/24/1988 -0.003 .
0001241 8/25/1988 -0.011 .
0001241 8/26/1988 -0.026 .
0001241 8/29/1988 0 .
0001241 8/30/1988 -0.015 .
0001241 8/31/1988 0.015 .
0001241 9/1/1988 -0.003 .
0001241 9/2/1988 0.007 .
0001241 9/5/1988 0.003 .
0001241 9/6/1988 0.003 .
0001241 9/7/1988 0 .
0001241 9/8/1988 -0.015 .
0001241 9/9/1988 -0.007 .
0001241 9/12/1988 0.003 .
0001241 9/13/1988 0.003 .
0001241 9/14/1988 0 .
0001241 9/15/1988 0.023 .
0001241 9/16/1988 -0.018 .
0001241 9/19/1988 -0.015 .
0001241 9/20/1988 -0.011 .
0001241 9/21/1988 0.003 .
0001241 9/22/1988 -0.007 .
0001241 9/23/1988 0.003 .
0001241 9/26/1988 -0.003 .
0001241 9/27/1988 0 .
0001241 9/28/1988 0 .
0001241 9/29/1988 0.003 .
0001241 9/30/1988 0.003 .
0001241 10/3/1988 -0.003 .
0001241 10/4/1988 -0.007 .
0001241 10/5/1988 0.003 .
0001241 10/6/1988 0 .
0001241 10/7/1988 0.003 .
0001241 10/10/1988 0 .
0001241 10/11/1988 0 .
0001241 10/12/1988 -0.003 .
0001241 10/13/1988 0 .
0001241 10/14/1988 0 .
0001241 10/17/1988 0 .
0001241 10/18/1988 0 .
0001241 10/19/1988 0.015 .
0001241 10/20/1988 -0.003 .
0001241 10/21/1988 0.003 .
0001241 10/24/1988 0.011 .
0001241 10/25/1988 0.015 .
0001241 10/26/1988 0.019 .
0001241 10/27/1988 -0.013 .
0001241 10/28/1988 0.005 .
0001241 10/31/1988 0.011 .
0001241 11/1/1988 0.011 .
0001241 11/2/1988 -0.007 .
0001241 11/3/1988 -0.003 .
0001241 11/4/1988 -0.003 .
0001241 11/7/1988 0 .
0001241 11/8/1988 0.003 .
0001241 11/9/1988 -0.003 .
0001241 11/10/1988 0 .
0001241 11/11/1988 0 .
0001241 11/14/1988 0.003 .
0001241 11/15/1988 0.022 .
0001241 11/16/1988 0.043 .
0001241 11/17/1988 0.010 .
0001241 11/18/1988 -0.013 .
0001241 11/21/1988 0 .
0001241 11/22/1988 0 .
0001241 11/23/1988 0 .
0001241 11/24/1988 -0.006 .
0001241 11/25/1988 -0.014 .
0001241 11/28/1988 0 .
0001241 11/29/1988 0 .
0001241 11/30/1988 0.017 .
0001241 12/1/1988 -0.010 .
0001241 12/2/1988 -0.003 .
0001241 12/5/1988 0 .
0001241 12/6/1988 -0.007 .
0001241 12/7/1988 -0.021 .
0001241 12/8/1988 -0.029 .
0001241 12/9/1988 -0.011 .
0001241 12/12/1988 -0.003 .
0001241 12/13/1988 0.003 .
0001241 12/14/1988 0.003 .
0001241 12/15/1988 0 .
0001241 12/16/1988 0 .
0001241 12/19/1988 0 .
0001241 12/20/1988 0.019 .
0001241 12/21/1988 0 .
0001241 12/22/1988 0.003 .
0001241 12/23/1988 0 .
0001241 12/26/1988 0 .
0001241 12/27/1988 0 .
0001241 12/28/1988 0.003 .
0001241 12/29/1988 0.018 .
0001241 12/30/1988 0 .
0001241 1/2/1989 0 .
0001241 1/3/1989 0.029 1
0001241 1/4/1989 0 .
0001241 1/5/1989 0 .
0001241 1/6/1989 0 .
0001241 1/9/1989 0.007 .
0001241 1/10/1989 0.014 .
0001241 1/11/1989 0 .
0001241 1/12/1989 0.006 .
0001241 1/13/1989 0.010 .
0001241 1/16/1989 -0.02 .
0001241 1/17/1989 0 .
0001241 1/18/1989 0.013 .
0001241 1/19/1989 0.013 .
0001241 1/20/1989 0.013 .
0001241 1/23/1989 0.013 .
0001241 1/24/1989 0.016 .
0001241 1/25/1989 0.009 .
0001241 1/26/1989 0.003 .
0001241 1/27/1989 0.025 .
0001241 1/30/1989 0.006 1
0001241 1/31/1989 0 .
0001241 2/1/1989 0 .
;
What I want to achieve is, to extract observations from -120th day up until -21st day from the date designated by d=1.
(Then, I intend calculate means and standard deviations of returns BY CUSIP and 100 days over each [-120,-21]).
There is one condition for what I want to achieve:
In the exemplary dataset above, we have two event days (d=1) on 1/3/1989 and 1/30/1989 .
These two dates are close. Thus, in a dataset of extractions of (-120,-21), many duplicate dates can exist because (-120,-21) from 1/3/1989 and (-120,-21) from 1/30/1989 can share many overlapping days.
For this, I used my SAS codes that I obtained from a kind member of SAS community.
It runs like this:
data want_120_21; start=stop+1; retain stop 0; do stop=stop+1 by 1 until(last.CUSIP); set have end=eof nobs=nobs; by CUSIP; end; put (_n_ nobs sedol start stop ) (=); tradeno=0; do obs=start to stop; set have; if d=1 then do; tradeno+1; tradedate=date; format tradedate date9.; do p=max(obs-120,start) to min(obs-21,stop); offset=p-obs; set have point=p; output; end; end; end; run;
I used to use this code to create the windows like (+2,+17), (+2,+126), etc.
But when I apply this code to create the windows (-120,-21), it doesn't work. Keeps producing "Disk is full."
I really appreciate your help,
thanks in advance!!
Sincerely,
KS -
... View more