I am trying to get the data difference between occurences of certain call records. the records are identified based on four variables (tid dt_stamp sp_acid lengt_of_call). However there could be multiple instances of records with similar values for these four variables. I need to select one of those instances and find time difference from another record with same tid in past. I am using the code below but keep getting a zero for the time difference inspite of the fact that there is significant gap between the two call occurences. Any help in this regard would be appreciated.
proc sort data=as.uniquenbscalls1106to1007 ;
by tid dt_stamp sp_acid lengt_of_call tm_stamp ;
data as.uniquenbscalls1106to1007 ;
retain prev_tid 0 prevtm_stmp 0 ;
set as.uniquenbscalls1106to1007 ;
by tid dt_stamp sp_acid lengt_of_call ;
if first.tid or first.dt_stamp or first.sp_acid or first.lengt_of_call then do ;
if cl_tid = prev_tid then diff = intck('HOUR',tm_stamp,prevtm_stmp) ;
prevtm_stmp = tm_stamp ;
prev_tid = tid ;
end ;
run ;
... View more