comparing time12.3 format with a num variable

Reply
Contributor
Posts: 24

comparing time12.3 format with a num variable

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?

Super User
Posts: 13,498

Re: comparing time12.3 format with a num variable


@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.

Contributor
Posts: 24

Re: comparing time12.3 format with a num variable

I changed the numeric variable to time format and line

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

Ask a Question
Discussion stats
  • 2 replies
  • 120 views
  • 0 likes
  • 2 in conversation