BookmarkSubscribeRSS Feed
abhisegal
Calcite | Level 5
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 ;
1 REPLY 1
deleted_user
Not applicable
I can't see what values are going into the calculation, and neither can you. As soon as you have a previous time stamp that is valid you overwrite it with the current one and lose the ability to repeat the IntCk() calculation.

Look at what rounding is done by IntCk(), and whether 29 minutes is 0 hours or 1 hour. Understand what the funciton will give you, and then look at the data you are sending it. At the point where you calculate the DIFF interval, put the contributing values out to the log so you can review them and verify you have set up the function correctly.

I'm a little mystified at the need to analyse call records for a clinical trial. Or perhaps I have been fortunate not to have foreign accents disturb my dinner with offers for aspirin.

Kind regards

David

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

Discussion stats
  • 1 reply
  • 777 views
  • 0 likes
  • 2 in conversation