Hello,
Currently in a file the Created Date format is ddmmmyyyy:hh:mm:ss (ex 11JUL2022:23:49:55).
First we change the format to date9. and then we are deleting any incoming information using
Data Miles1;
Set Miles;
if CreatedDate1 >= (today()) then delete;
run;
What I would like to do is not change to date9 but instead leave it the way it is and then delete from a certain time on the current day.
Example
if CreatedDate1 >= (today at 01:00:00)
I am just not sure how to do that in sas since the file we are deleting form is a continually updating one with data coming in all day.
Might be faster to use a WHERE, especially if the source is some external database.
data Miles1;
set Miles;
where CreatedDate1 < "%sysfunc(today(),date9.):01:00:00"dt ;
run;
You can create a datetime value from a date plus hour minute and seconds with the DHMS function.
DHMS(today(),12,0,0) for example creates a date time value of today at hour 12.
I am afraid that "today at 01:00:00" is ambiguous as you did not supply AM/PM information. AM would b
DHMS(today(),1,0,0). 1 PM is hour 13, so DHMS(today(),13,0,0);
Might be faster to use a WHERE, especially if the source is some external database.
data Miles1;
set Miles;
where CreatedDate1 < "%sysfunc(today(),date9.):01:00:00"dt ;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.