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
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
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?!
If I try
x=input('0010',hhmmss6.);
I'm still getting
x=10:00:00 y=12:30:45
Version of SAS dependency perhaps, I'm on 9.2.3
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
This is getting weird!
Geoonline, when you refer this to SAS tech support, be sure to point them at this discussion!!
Tom
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.
Related to this hotfix possibly?
39035 - The HHMMSS informat reads time values without delimiters
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:
I have tried it with the above examples and it works fine.
Thanks again for all your responses.
Regards,
Geo
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.