Good afternoon. I'd be thankful for any help you might provide to me.
I have a date/time variable with 24-hour time as part of that. What I need to do is to not only strip out the time but to convert it to a simple number. So from 021318 14:30:00 I just need 143000. I can split out the date but each time I try to do the same with the time portion I get 14:30:00 (with special characters). I'd like them to be gone but I can't figure out a good way to do that.
Thank you very much.
start_time | want |
021318 14:30:00 | 143000 |
021318 13:10:00 | 131000 |
021318 13:30:00 | 133000 |
021318 13:37:00 | 133700 |
021318 15:30:00 | 153000 |
021318 15:30:00 | 153000 |
021318 18:30:00 | 183000 |
021318 19:00:00 | 190000 |
One way to get what I think you are asking for
want= input(compress(put(timepart(start_time),time8.),':'),F6.);
or
want = hour(start_time)*10000+minute(start_time)*100+second(start_time));
I do kind of wonder in what way that format is more useful though.
One way to get what I think you are asking for
want= input(compress(put(timepart(start_time),time8.),':'),F6.);
or
want = hour(start_time)*10000+minute(start_time)*100+second(start_time));
I do kind of wonder in what way that format is more useful though.
Thank you very much. I'm sure there may be other suggestions here that might work as well but this one was so easy even I could make it work!
Thank you.
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.
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.