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

I tried to calculate Diff by doing computed column > Advanced expression and then `datetime() - t1.datetime / 60 `. Diff is actually the difference between SAS_update and DateTime, SAS_Update is just the lastruntime (datetime())

 

This is what I got:

Andalusia_0-1634707532713.png
I get a very weird value but I expected Diff to have value -1 because there is a a difference of -1 minutes between them SAS_update and DateTime...

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star
Your approach is OK, but you need to add parentheses. Without them, SAS performs division first, then subtraction. Use parentheses to force the subtraction to take place first.

View solution in original post

4 REPLIES 4
andreas_lds
Jade | Level 19

Use the function intck.

Datetime-variables are, without a format, the number of seconds passed from 1Jan1960 to the actual datetime. The function takes care of the details, if you need the difference in minutes, then use "dtminute" as interval.

Andalusia
Obsidian | Level 7
Could you show an example?
Kurt_Bremser
Super User

@Andalusia wrote:
Could you show an example?

Looks like this:

intck('minute',t1.datetime,datetime(),"c")

The "c" (for continuous) means that difference / 60 is used, and not the count of minute boundaries between the two values (90 seconds difference can turn out to be 2 minutes if the default is used).

For reference, run this:

data _null_;
time = datetime();
rc = sleep (119,1);
diff1 = intck('minute',time,datetime(),"c");
diff2 = intck('minute',time,datetime());
put _all_;
run;
Astounding
PROC Star
Your approach is OK, but you need to add parentheses. Without them, SAS performs division first, then subtraction. Use parentheses to force the subtraction to take place first.

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 555 views
  • 0 likes
  • 4 in conversation