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: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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