Hi all,
I have a variable "DateTime" that looks like this
04MAR14:01:04:00
with the DATETIME format. I want to create a variable with decimal numbers for just time. For example, for the time above, it would be 01.00067 such as (01.(04/60)).
How do I go from SAS time to these numeric values?
Hi @lalaktgrau,
Try this:
data want;
set have;
hours=timepart(datetime)/3600;
format hours z8.5;
run;
Note that your example ("01.00067") is incorrect.
%let date_time= "04MAR14:01:04:00" ;
%let time_format=0%sysevalf(%substr(&date_time,10,2)+%sysfunc(round(%sysevalf(%sysfunc(inputn(%substr(&date_time,13,2),2.))/60),.00001)));
%put &=time_format;
Hi @lalaktgrau,
Try this:
data want;
set have;
hours=timepart(datetime)/3600;
format hours z8.5;
run;
Note that your example ("01.00067") is incorrect.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.