Hello everybody,
I'm just trying to delete some obs - the ones that are created at the same date and hour.
There is a column "creation_time" from which I extrat the creation_hour by using
attrib
creation_hour length = 8 format = hour.
;
creation_hour = timepart(creation_time);
(That doesn't work as I expected it to because '11:47:32' becomes '12' but that is not really important for my task.)
But there is an actual problem: Even if '11:47:32' and '11:48:01' both lead to '12' the two obs still remain, if I try to delete one of them by using
proc sort nodupkey: by creation_hour;
That means the column creation_hour actually still contains the whole information, with minutes and seconds, doesn't it?
How can I change this? I really only want the column to contain the numbers from 1-12 - is that possible? How?
Or is there a better way to do the job?
Thanks for any ideas
Creation_hour= hour(creation_time);
Should return just the hour.
Thanks for the idea but unfortunately, this doesn't return the hour. Now creation_hour equals zero for all obs - without any errors or anything in the log.
Why do you apply the hour-format to creation_hour? I think the problems are a result of applying the format.
Ah, I see.
I used the format 'hour' because with
"creation_hour = timepart(creation_time); "
without this format, the column creation_hour contained numbers from zero to 86.399 (counting the seconds).
But with the correction
"creation_hour = hour(creation_time); "
the format is indeed not necessary.
Thanks a lot to both of 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.