BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10
dm 'log;clear;odsresults;clear';

data d;
start_date='18Nov2014'd ;
format start_date date9.;
current_date='18Nov2020'd ;
format current_date date9.;
years=intck('Year' ,start_date,current_date);
months=intck('Month',start_date,current_date);
days= intck('Day',start_date,current_date);
hours=intck('hour','22:10:00't ,1)	;
proc print;run;

Here I want to get hour minute second from start_date and current_date why it gives 22 hours

1 REPLY 1
Kurt_Bremser
Super User

'hour' is a time interval, times are counts of seconds. 1 translates to 00:00:01, so you have 22 hour boundaries between that and 22:10:00.

If you want the difference between dates (there are no timestamp/datetime values in your code) expressed as hours, multiply the day difference by 24.

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
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
  • 1218 views
  • 0 likes
  • 2 in conversation