05-16-2014 10:09 AM
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...
put x=time8. y=time8.;
SAS Log FIle:
2 data _null_;
5 put x=time8. y=time8.;
05-16-2014 10:33 AM
I added these cases:
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!
05-16-2014 10:42 AM
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?!
05-16-2014 05:01 PM
Why I got different results:
6032 data _null_;
6037 put x=time8. y=time8. x2=time8. x3=time8.;
x=0:00:10 y=12:30:45 x2=0:01:10 x3=0:12:10
05-16-2014 05:49 PM
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.
05-20-2014 03:13 PM
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:
I have tried it with the above examples and it works fine.
Thanks again for all your responses.