BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Fox01
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
MarkusWeick
Barite | Level 11

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:

Bruehl_0-1655196635560.png

 

Please keep the community friendly.
Like posts you agree with or like. Mark helpful answers as “accepted solutions”. Generally have a look at https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles

View solution in original post

14 REPLIES 14
ballardw
Super User

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?

Fox01
Fluorite | Level 6

The " time " values are not character 

The 2 duractions are calculated items which the type is numeric and the format is hhmm5.2022-06-13.png

I don't have any error message  just a . like this

 

2022-06-13 (1).png

 

I tried to change time to numeric but the problem is the same 

 

2022-06-13 (3).png

 

 

 

 

 

MarkusWeick
Barite | Level 11

Hi @Fox01,

in similar situation I applied the advanced numeric operator "treatAs" to treat the durations as numeric.

Maybe it helps.

 

Best

Markus

Please keep the community friendly.
Like posts you agree with or like. Mark helpful answers as “accepted solutions”. Generally have a look at https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles
MarkusWeick
Barite | Level 11

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

Please keep the community friendly.
Like posts you agree with or like. Mark helpful answers as “accepted solutions”. Generally have a look at https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles
Fox01
Fluorite | Level 6

Hi @MarkusWeick,

I tried treatas but the probleme is the same 

2022-06-13 (4).png

MarkusWeick
Barite | Level 11

Hi @Fox01,

sorry, but I don't have any ideas anymore.

 

Best Markus

Please keep the community friendly.
Like posts you agree with or like. Mark helpful answers as “accepted solutions”. Generally have a look at https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles
BrunoMueller
SAS Super FREQ

Please show the expression you are using to calculate the difference. Also a screenshot from the two durations with the properties would help

Fox01
Fluorite | Level 6

Hi @BrunoMueller 

Duration 1: 

Fox01_0-1655190131729.png

with aggregation as median 

Fox01_1-1655190158764.png

 

Duration 2 : 

Fox01_2-1655190184397.png

with aggregation as median.

 

The expression I am using to calculate the difference is :

duration 1 - duration 2 

Thanks for your help.

 

 

 

 

BrunoMueller
SAS Super FREQ
I can see that if the condition is false you return missing, can you show what the preview button displays, when you do the calculation d1 - d2, maybe all the values are missing
MarkusWeick
Barite | Level 11

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

Please keep the community friendly.
Like posts you agree with or like. Mark helpful answers as “accepted solutions”. Generally have a look at https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles
Fox01
Fluorite | Level 6

Hi @MarkusWeick,

In this case, how can I calculate the difference between Duration 1 and Duration 2 ? 

Thanks for your help 

BrunoMueller
SAS Super FREQ

I suggest you show us what your data looks like and what you want to achieve.

MarkusWeick
Barite | Level 11

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:

Bruehl_0-1655196635560.png

 

Please keep the community friendly.
Like posts you agree with or like. Mark helpful answers as “accepted solutions”. Generally have a look at https://communities.sas.com/t5/Getting-Started/tkb-p/community_articles
Fox01
Fluorite | Level 6

 

Thank you very much ! It's working 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

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.

Discussion stats
  • 14 replies
  • 2389 views
  • 9 likes
  • 4 in conversation