BookmarkSubscribeRSS Feed
apxprdtr10
Calcite | Level 5

Hi all,

 

I have time format 515 and i want desired time format as 05:15.

could anybody help me with getting the desired format.

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Is time a character or numeric variable?

 

Either way, do something like this

 

data have;
   Time=515;
   CharTime=put(Time, 4.);
   RightTime=input(put(Time, 4.), hhmmss5.);
   format RightTime time5.;
run;
ballardw
Super User

Assuming your existing variable is actually numeric here is an example:

data junk;
   x=515;
   x=input(put(x,z4.),hhmmss.);
   format x time5.;
run;
apxprdtr10
Calcite | Level 5

I really appreciate your valuable reply but it just slightly differ from my desired result.

your replied answer gives me time as 5:15 but i want as 05:15

art297
Opal | Level 21

You could always just roll your own format. e.g.:

proc format; 
   picture todx other='%0H:%0M' (datatype=time);
run;

data junk;
   x=515;
   x=input(put(x,z4.),hhmmss.);
   format x todx.;
run;

Art, CEO, AnalystFinder.com

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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

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
  • 4 replies
  • 702 views
  • 1 like
  • 4 in conversation