BookmarkSubscribeRSS Feed
davidnamh
Calcite | Level 5

Hi, I have time in HHMMSSS and would like to informat and  format it with (eg 12:23:123) in SAS dataset. 

I used time7. for informat, but returns with "." in the SAS dataset.. Could you please help me how to do that ? Thanks you so much.

data have;

input hhmmsss;

datalines;

1223123

0403267

;

run;

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

I used the picture format to get the result.

proc format;

picture times (default=10) low-high="99:99:990";

run;

data have;

input hhmmsss;

time=put(hhmmsss,times.);

datalines;

1223123

0403267

;

run;

Thanks,

Jag

Thanks,
Jag
ballardw
Super User

And you are having problems because your data as written is indicating more that 60 seconds to a minute.

You may want to get the fractional seconds using a different informat if want an actual time value:

data have;
informat hhmmsss b8601tm7.1;
input hhmmsss  ;
format hhmmsss   time12.1;
datalines;
1223123
0403267
;

run;

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