Hai guys ,
I have a requirement , where i have to split time into hours , minutes and seconds .
For example : time is 12 : 40 :12 . I need it as 12 hrs, 40 min and 12 seconds. Kindly give me the syntax for this.
Thanks in advance.
Here you go:
data have;
format datetime datetime.;
datetime = today();
run;
data want;
set have;
date = datepart(datetime);
hour = hour(datetime);
min = minute(datetime);
sec = second(datetime);
run;
Hello,
If your data is in character format, you always could use the SCAN function, with ":" as delimiter and select the position that you want
data want;
set have;
format WANT_var $20. hours minutes seconds $2.;
hours=scan(time,1,':');
minutes=scan(time,2,':');
seconds=scan(time,3,':');
WANT_var=hours||" hrs, "||minutes||" min and "||seconds||" seconds;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.