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!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.