BookmarkSubscribeRSS Feed
geoonline
Calcite | Level 5

Experts,

I am trying to read in the below data using hhmmss informat. While using hhmmss informat, when there are less that 6 digits in the input, as per SAS user guide, it appends zeros to the end to make it 6 digits and reads it in.

But when 0010 as read in using hhmmss in SAS, it is read as 10 hours instead of 10 minutes (as I would expect.)

Is it a SAS bug? Anyone knows a work around to it. Thanks a lot for the help...

Test Program:

data _null_;

  x=input('0010',hhmmss.);

  y=input('123045',hhmmss.);

  put x=time8. y=time8.;

run;

SAS Log FIle:

1        !              

2          data _null_;

3            x=input('0010',hhmmss.);

4            y=input('123045',hhmmss.);

5            put x=time8. y=time8.;

6          run;

x=10:00:00 y=12:30:45

9 REPLIES 9
TomKari
Onyx | Level 15

I added these cases:

x2=input('0110',hhmmss.);

x3=input('1210',hhmmss.);

and they both worked correctly. I agree with you that your "x" example should be 00:10:00, not 10:00:00. I suspect that SAS is disregarding left digits of zero, and this isn't correct.

I'd fire it off to tech support, if they haven't already noticed your post. Please post with the response!

Tom

ballardw
Super User

A work around would be to read the value as text and if the length is less than 6 to append 0 to make it the needed length and then input as in your example.

I did note that using a explicit length with the format such as hhmmss6. then it reads as seconds. If I used the B8601tm. format it did read 10 minutes but also had 12 seconds?!

TomKari
Onyx | Level 15

If I try

x=input('0010',hhmmss6.);

I'm still getting

x=10:00:00 y=12:30:45

ballardw
Super User

Version of SAS dependency perhaps, I'm on 9.2.3

Abdu
Calcite | Level 5

Why I got different results:

6032   data _null_;

6033     x=input('0010',hhmmss.);

6034     y=input('123045',hhmmss.);

6035     x2=input('0110',hhmmss.);

6036     x3=input('1210',hhmmss.);

6037     put x=time8. y=time8. x2=time8. x3=time8.;

6038   run;

x=0:00:10 y=12:30:45 x2=0:01:10 x3=0:12:10

TomKari
Onyx | Level 15

This is getting weird!

Geoonline, when you refer this to SAS tech support, be sure to point them at this discussion!!

Tom

geoonline
Calcite | Level 5

Thanks everyone for the response...I believe the difference in result is due to the SAS version. I have tried it in SAS 9.2 & SAS 9.3, both giving different results.

geoonline
Calcite | Level 5

Hi All,

  I contacted SAS Tech Support regarding this issue. They already seem to be aware of this issue and SAS R&D is currrently working on a fix to it.

In the meantime SAS suggests to use B8601TMw.d informat to read in these values correctly.

It's documented here:

http://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#n0tx8gqdnl4u...

I have tried it with the above examples and it works fine.

Thanks again for all your responses.

Regards,

   Geo

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 9 replies
  • 1898 views
  • 0 likes
  • 5 in conversation