Hello,
Lets say that there are 2 columns :X1
Each of them is sas date time column.
Lets say that the formatted values are:
X1=22AUG2022:09:35:00
X2=22AUG2022:09:26:06
LEts say that I want to calculate the difference in minutes between X1 and X2.
I am using intck as following:
INTCK('minute',X1,X2) as dif_in_minutes
My question:
Why am I getting minus 9 and not plus 9???
I was sure that the difference that is calculated is X1-X2 by but the result I see that it is X2-X1
The second argument is the from value, and the third argument is the to value. If "to" is before "from", the function returns a negative value.
If you only want to get the difference, irrespective of the order, use the ABS function around the INTCK.
The answer is quite simple. As the INTCK Function Documentation says, it
Returns the number of interval boundaries of a given kind that lie between two dates, times, or datetime values.
Also:
INTCK returns a negative value whenever the first date(time) is later than the second date(time) and the two date(time)s are not in the same discrete interval.
The second argument is the from value, and the third argument is the to value. If "to" is before "from", the function returns a negative value.
If you only want to get the difference, irrespective of the order, use the ABS function around the INTCK.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.