BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lalaktgrau
Fluorite | Level 6

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?

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.

View solution in original post

2 REPLIES 2
sidpesar
Obsidian | Level 7
%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;
FreelanceReinh
Jade | Level 19

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 2 replies
  • 808 views
  • 3 likes
  • 3 in conversation