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