BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ccaudillo100
Obsidian | Level 7

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

3 REPLIES 3
ballardw
Super User

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);

Tom
Super User Tom
Super User

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;
ccaudillo100
Obsidian | Level 7
Thank you! This worked quick and perfectly!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2714 views
  • 2 likes
  • 3 in conversation