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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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