BookmarkSubscribeRSS Feed
HansSteenhuis
Calcite | Level 5

Hello,

 

I have certain test sessions with a start and end time. Different tests are performed on the session. These tests also have a beginning and an end time.

 

Now I want to calculate how much time before, within and after the session falls. The hours and minutes may also be in decimals.

 

I calculate this in Excel, but I want to calculate this in EG now. Do you see opportunities to make this possible? In EG these are two separate tables (Sessions and To_test).

 

See my example in Excel.

 

Thank you very much.

1 REPLY 1
tomrvincent
Rhodochrosite | Level 12

I found this here: https://blogs.sas.com/content/sgf/2015/01/21/sas-timer-the-key-to-writing-efficient-sas-code/

 

 

Get your own SAS timer

  1. At the very beginning of your SAS program, place the following line of code that effectively starts the timer and remembers the start time:

/* Start timer */

%let _timer_start = %sysfunc(datetime());

  1. At the end of your SAS program place the following code snippet that captures the end time, calculates duration and outputs it to the SAS Log:

/* Stop timer */

data _null_;

  dur = datetime() - &_timer_start;

  put 30*'-' / ' TOTAL DURATION:' dur time13.2 / 30*'-';

run;


The resulting output in the SAS log will look like this:

------------------------------

 TOTAL DURATION:   0:01:31.02

------------------------------

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1183 views
  • 0 likes
  • 2 in conversation