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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 1726 views
  • 2 likes
  • 3 in conversation