Hello,
I need to calcule the difference between 2 durations :
D1 = 02:26 ( hh:mm)
D2= 03:07 ( hh:mm)
I tried to created a calcuated item like this : D1- D2 but it doesn't return any value.
Do you have any idea please ?
Thank you in advance
Hi @Fox01,
you could define additiona calculated items for Duration1 and Duration2 each.
There you could use the "mean"-Operator (to be found under "aggregate simple") to define columns which contain the mean:
Show us the description of your data.
If you "time" values are character then subtraction will not work and you need to convert them to numeric time values.
Dare I ask what your LOG showed from attempting that subtraction?
The " time " values are not character
The 2 duractions are calculated items which the type is numeric and the format is hhmm5.
I don't have any error message just a . like this
I tried to change time to numeric but the problem is the same
Hi @Fox01,
in similar situation I applied the advanced numeric operator "treatAs" to treat the durations as numeric.
Maybe it helps.
Best
Markus
Hi @Fox01
and please have a look at the calculations with the durations in
Solved: Median duration with conditions - SAS Support Communities
Maybe it gives you some ideas to try.
Best Markus
Hi @Fox01,
sorry, but I don't have any ideas anymore.
Best Markus
Please show the expression you are using to calculate the difference. Also a screenshot from the two durations with the properties would help
Duration 1:
with aggregation as median
Duration 2 :
with aggregation as median.
The expression I am using to calculate the difference is :
duration 1 - duration 2
Thanks for your help.
Hi @Fox01,
remember you are not subtracting single values, but whole columns.
And the two columns (duration 1, duration 2) are defined in a way, that for each row one of the columns has the value "missing".
Best
Markus
Hi @MarkusWeick,
In this case, how can I calculate the difference between Duration 1 and Duration 2 ?
Thanks for your help
I suggest you show us what your data looks like and what you want to achieve.
Hi @Fox01,
you could define additiona calculated items for Duration1 and Duration2 each.
There you could use the "mean"-Operator (to be found under "aggregate simple") to define columns which contain the mean:
Thank you very much ! It's working
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.