BookmarkSubscribeRSS Feed
Sasadomo
Calcite | Level 5

So say I have a time12.3 format observation 9:09:39.359 and I have 8-digit number 093530 representing the time as hhmmss but I do not have the milliseconds, how do I compare these two observations? Will it work if I convert the numeric variable to a time8. format?

2 REPLIES 2
ballardw
Super User

@Sasadomo wrote:

So say I have a time12.3 format observation 9:09:39.359 and I have 8-digit number 093530 representing the time as hhmmss but I do not have the milliseconds, how do I compare these two observations? Will it work if I convert the numeric variable to a time8. format?


Just changing the format will not help for comparison purposes. Create a new time variable by pulling the hour, minute and second pieces out of that 8 digit number and using the HMS function.

The INTCK function would likely be the best way for the actual comparison as you would indicate what unit of interest you are concerned with, hours, minutes, seconds between the two values. You could do the conversion to time inside the intck function call but you may want the other variable for easier verification of results. Don't forget to assign a time format to the new variable.

Sasadomo
Calcite | Level 5

I changed the numeric variable to time format and line

"if '9:35:00't <= sect <= '15:55:00't;" worked here

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1314 views
  • 0 likes
  • 2 in conversation