Hello Arthur,    Thanks for your help. I'm now testing the code and it has following error message I could not figure out. Can you please help?      data need (drop=_:);  65     do until (last.gvkey);  66       set gooddata;  67       by gvkey;  68       array before_months(686);  69       retain months:;  70       if first.gvkey then do;  71         call missing(of before_months(*));  72       end;  73       _month=intck('month', '01dec1969'd, DATADATE);  74       _low=max(_month-36+1,1);  75       do _j=_low to _month + span.-1;                                  -----                                  22                                  201  ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string,                a numeric constant, a datetime constant, a missing value, arrayname, (, +, -, INPUT,                NOT, PUT, ^, _NEW_, ~.      ERROR 201-322: The option is not recognized and will be ignored.      76         if _month le _j then before_months(_j)=sum(before_months(_j),1);  77       end;  78     end;  79     do until (last.gvkey);  80       set gooddata;  81       by gvkey;  82       output;  83     end;  84   run;   
						
					
					... View more