I'm a newer user to the SAS world so there very well may be an easy way to do this, but at the moment i'm stuck. I need to calculate the number of days between my records. Currently I've got some code worked out that will solve for the Days to Next Contact (DTNC) and Days Since Last Contact (DSLC). That code is below. What I need is code that will solve for additional contacts in either direction. Stated in another way, given contacts 1 through 5, I need to be able to look a the third contact and say "it was W days earlier that contact 1 happened, X days earlier that contact two happened, Y days later that contact 4 happened ,and Z days later that contact 5 happened." My metrics DSLC and DTNC take care of contacts 2 and 4, but i'm lost trying to solve for 1 and 5. Any help would be GREATLY appreciated. Thanks, -Mike The date I need to reference is "CALLDATE". I create the variable DATE for the purpose of calculation. proc sort /*CallCount*/ data= work.callcount; by ANI CallDate; run; data DSLC; /*from WEEKS - creates DSLC*/ set work.callcount; retain date; by ANI; if first.ani then do; DSLC = .; date=CallDate; end; DSLC=CallDate-date; date=CallDate; run; data DSLC2; /*clears DSLC if only 1 call on record*/ set work.DSLC; by ANI; if count=1 then DSLC=.; run; data DTNC1; /*Creates counter for DTNC2*/ set work.DSLC2; retain order; by ANI; if first.ani then do; order = count+1; end; order=order-1; run; proc sort /*DTNC*/ data=work.DTNC1; by ani order; run; data DTNC2; /*Creates DTNC - From DTNC1*/ set work.DTNC1; retain day; by ANI; if first.ani then do; DTNC = .; day=CallDate; end; DTNC=day-CallDate; day=CallDate; run; proc sql; /*creates DTNC3 - From DTNC2*/ create table DTNC3 as Select ANI, CustNumber, Guide, AcctType, CallDate, CallTime, COUNT, DSLC, DTNC From work.DTNC2; quit; data MASTER; /*Creates MASTER - From DTNC3 - Clears DTNC if only 1 call on record*/ set work.DTNC3; by ANI; if count=1 then DTNC=.; run;
... View more