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

Hi all, 

 

I have data like below:

data data;
input date $20.;
cards;
2019-11-16
2020-04-09T09:40
2020-04-09T13:30
2020-04-10T11:05
2020-05-07T11:00
2020-05-07T11:08
2020-05-08T11:05
2020-06-04T10:05
2020-06-04T11:22
2020-06-05
2020-07-02T10:41
2020-07-02T10:50
;
run;

 

I would like to change those dates to numeric format of datetime19. and if missing time then I want to show 00:00:00. Can anyone suggest which format  can use here?

 

I am using anydtdtm. but it's not wokring.

 

Thanks,

Adithya

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
data data;
input date b8601dt.;
format date datetime16.;
cards;
2019-11-16
2020-04-09T09:40
2020-04-09T13:30
2020-04-10T11:05
2020-05-07T11:00
2020-05-07T11:08
2020-05-08T11:05
2020-06-04T10:05
2020-06-04T11:22
2020-06-05
2020-07-02T10:41
2020-07-02T10:50
;
run;
--
Paige Miller

View solution in original post

5 REPLIES 5
Reeza
Super User
Show your code that doesn't work please.
chinna0369
Pyrite | Level 9
I am using below code and not getting value for all records:
data want;
set data;
want_date=input(put(date,$20.),anydtdtm.);
run;

Thanks,
Adithya
Reeza
Super User
Try =>
want_date = input(date, datetime16.)

PUT converts it to a character so if already have a character that step doesn't make sense.
PaigeMiller
Diamond | Level 26
data data;
input date b8601dt.;
format date datetime16.;
cards;
2019-11-16
2020-04-09T09:40
2020-04-09T13:30
2020-04-10T11:05
2020-05-07T11:00
2020-05-07T11:08
2020-05-08T11:05
2020-06-04T10:05
2020-06-04T11:22
2020-06-05
2020-07-02T10:41
2020-07-02T10:50
;
run;
--
Paige Miller
chinna0369
Pyrite | Level 9
Thank you Paige Miller!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 5 replies
  • 1136 views
  • 3 likes
  • 3 in conversation