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

I have a datetime variable that looks like this:

 

06JAN17:14:30:00

05APR15:10:15:15

07JUN12:08:12:05

08JUN15:09:10:00

07JUN16:11:12:13

 

Is there a straightforward way to remove datetimes with 00 seconds, so that the output looks like this:

 

05APR15:10:15:15

07JUN12:08:12:05

07JUN16:11:12:13

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
if second(datetime) = 0 then delete;

@Caetreviop543 wrote:

I have a datetime variable that looks like this:

 

06JAN17:14:30:00

05APR15:10:15:15

07JUN12:08:12:05

08JUN15:09:10:00

07JUN16:11:12:13

 

Is there a straightforward way to remove datetimes with 00 seconds, so that the output looks like this:

 

05APR15:10:15:15

07JUN12:08:12:05

07JUN16:11:12:13

 

 


https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p00gnqetase0i9n1rshg4sz5t607.htm...

View solution in original post

3 REPLIES 3
Reeza
Super User
if second(datetime) = 0 then delete;

@Caetreviop543 wrote:

I have a datetime variable that looks like this:

 

06JAN17:14:30:00

05APR15:10:15:15

07JUN12:08:12:05

08JUN15:09:10:00

07JUN16:11:12:13

 

Is there a straightforward way to remove datetimes with 00 seconds, so that the output looks like this:

 

05APR15:10:15:15

07JUN12:08:12:05

07JUN16:11:12:13

 

 


https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=p00gnqetase0i9n1rshg4sz5t607.htm...

Caetreviop543
Obsidian | Level 7

Thank you!

ballardw
Super User

If any of your values have fractional seconds and your current display format does not show them you could have a value that appears to have "zero seconds" still in your data.

Example code:

data example;
   x = '01JAN2020:15:30:59.888'dt;
   put x datetime18.;
run;

The log will show the time rounded to seconds, i.e. :00

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 881 views
  • 2 likes
  • 3 in conversation