I am using CRSP data which has firms(permnos) and monthly data for returns for a long time period and the Fama French 3 factors. I created a time column which equals to 0 if January 1963 and goes up 1 each month. Counter is counting the months for each permno(resets to 1 when a new permno comes in). So my data looks like this; Permno Date TIme Counter exret SMB HML MKT_RF 10001 19630131 0 1 (There are obviously numbers in exret through mkt_rf) 10001 19630228 1 2 10001 19630331 2 3 ... (the dots here are not missing values but I put them to show there are .... other values inbetween) 10001 19830131 240 241 10002 19860131 276 1 10002 19860228 277 2 ... 10002 20100728 570 295 10003. 20030430 483 1 10003. 20030531 484 2 and so on. What I want to do is to use an "expanding window of data" or in other words use only the data in months 1 through t-1 in whatever procedure is being used. I heard this can either be done with a macro or a data step. Any method would be fine with me. The procedure I am using is an EGARCH model (below) but please do not be discouraged from answering if you are not familiar with this model, because what I am interested is only the data step or macro that will allow me to select my sample to include upto month t-1 for each month t, you can answer by showing how to use this macro/data step with another procedure you are familiar with such as PROC REG. My code: proc autoreg data= test ; model exret = mkt_rf smb hml / garch=( q=1, p=1 , type = exp) maxit=500 ; output out=out cev=vhat ; by permno; run; I am trying to 1)avoid the look ahead bias that arises from using whole sample 2)avoid having the return for month t(exret) from getting into the equation when calculating estimates fro month t. What I want is that for each permno, if it is month 30 I want this code to use the data available upto 29 to give an estimate for month 30, in month 31 use data upto month 30 to give an estimate for month 31 and so on until however many months there is for that permno. (I am interested in the estimates of cev(conditional variance) I created the counter variable for this purpose if it helps. I thought to write something like " if counter = x do above procedure using data between counter= 1 to counter= x-1 for each permno" As I said it doesnt necessarily have to be for the above procedure you can give an example of how to do this with another regression model you are familiar with. I thank everyone who will reply for their help in advance. Best Regards
... View more