I need some help, not even sure where to start.
I have transactional data, I need to read through the records for each phone number and determine the time increment between each call to make sure it is outside allowable minimum number of minutes.
Each phone number could only have one call or multiple.
I have no idea how to do this, any assistance will be greatly appreciated.
thank you,
The dif function, based on a numeric variable that has a time format, will provide the number of seconds between two times. e.g.:
data have;
informat time time5.;
format time time5.;
input phonenum time;
cards;
123 9:35
123 10:15
123 14:50
321 9:55
321 10:45
321 14:10
;
data want;
set have;
by phonenum;
dif=dif(time);
if first.phonenum then call missing(dif);
run;
You need to post sample data.
In general use the dif function and then First/Last processing.
Use the First.phone_number to set the difference to missing.
It would be helpful to know what your data looks like (i.e., fields, field types, and how they're formatted), and what you want to achieve. e.g., are you looking for the average time between phone calls for each number, and do you just want to ignore phone numbers that only have one call?
The data is transactional, there is an ID, $18.; phone_num $20.; call_time in a time format looks like 08:46 AM in the data set
I need to evaluate each record that has the same phone number to see if the calls were placed within a 15 minutes period. if so then I have to throw and error.
I do not need to worry about phone numbers that only have 1 record call.
Thanks
Do you have a date variable as well?
all records are for the same date
The dif function, based on a numeric variable that has a time format, will provide the number of seconds between two times. e.g.:
data have;
informat time time5.;
format time time5.;
input phonenum time;
cards;
123 9:35
123 10:15
123 14:50
321 9:55
321 10:45
321 14:10
;
data want;
set have;
by phonenum;
dif=dif(time);
if first.phonenum then call missing(dif);
run;
Thank you very much Arthur, that is exactly what I needed.
Cindy
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.