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?
@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.
I changed the numeric variable to time format and line
"if '9:35:00't <= sect <= '15:55:00't;" worked here
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.