Hello,
I am tryin to find how many of the 46 records in the attached file are within 24 hours of each other
I have used the code below as one of the conditions?
Can someone please advise if the function is written correctly to capture the cases
(0 <= INTCK('HOUR', A.ENTRY_DT,N.REG_TM ) <= 24)
@Ranjeeta wrote:
Hello,
I am tryin to find how many of the 46 records in the attached file are within 24 hours of each other
I have used the code below as one of the conditions?
Can someone please advise if the function is written correctly to capture the cases
(0 <= INTCK('HOUR', A.ENTRY_DT,N.REG_TM ) <= 24)
You might want
(0 <= abs( INTCK('HOUR', A.ENTRY_DT,N.REG_TM ) ) <= 24)
unless you only want when N.Reg_tm is greater than A.Entry_dt. The Absolute value function make the value positive after the comparison. Or use -24 to 24.
You would have to show us the rest of the code to see if you are comparing the records as intended.
I would also make very sure that your varaibles are either both TIME only or DATETIME only variables. If one is actually a date time and the other time then you will not get the results that you want. I point this out as we see lots of variables with a name ending in DT that are either date, which SAS has in days as units, or datetime which will have much larger values in general than plain "time of day" variables.
@Ranjeeta wrote:
I am tryin to find how many of the 46 records in the attached file are within 24 hours of each other
I'm afraid this is not well-defined enough to venture an answer. Please explain further and give the desired output. Also, please provide your data according to these instructions and not via Excel files.
Are you going to compare all of the records to each other? Or just compare the two columns in the same record to each other?
Are you doing this in SQL code somehow? If not then why do you have periods in your variable names?
Why not just compare the time difference instead of counting the intervals?
0<= X-Y <= '24:00't
@Ranjeeta wrote:
Hello,
I am tryin to find how many of the 46 records in the attached file are within 24 hours of each other
I have used the code below as one of the conditions?
Can someone please advise if the function is written correctly to capture the cases
(0 <= INTCK('HOUR', A.ENTRY_DT,N.REG_TM ) <= 24)
You might want
(0 <= abs( INTCK('HOUR', A.ENTRY_DT,N.REG_TM ) ) <= 24)
unless you only want when N.Reg_tm is greater than A.Entry_dt. The Absolute value function make the value positive after the comparison. Or use -24 to 24.
You would have to show us the rest of the code to see if you are comparing the records as intended.
I would also make very sure that your varaibles are either both TIME only or DATETIME only variables. If one is actually a date time and the other time then you will not get the results that you want. I point this out as we see lots of variables with a name ending in DT that are either date, which SAS has in days as units, or datetime which will have much larger values in general than plain "time of day" variables.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.