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

 

I have the date and time in Char as below

 

Date and time
2017-03-01T12:10
2017-03-01T13:02
2017-03-07T22:15
2017-03-19T09:32
2017-04-12T11:45

 

I want to converted to date and time into Numeric

What is the best way to handle this coversion?

 

THANKS!!

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

If you change the code, then it might not work. If you use the exact code I provided, I know that it does work.

--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

You use the INPUT() function with the proper informat.

 

Example:

num_date_time=input(char_date_time,e8601dt.);

You may also want to apply a format to num_date_time.

--
Paige Miller
zimcom
Pyrite | Level 9
num_date_time=input(char_date_time,datetime.);

I tried to convert using input as above, but it did not work (probably because there is a "T" in the character string to separate the date and time).

PaigeMiller
Diamond | Level 26

If you change the code, then it might not work. If you use the exact code I provided, I know that it does work.

--
Paige Miller
zimcom
Pyrite | Level 9
I really appreciated your help, Thank you so much!
Have a great day
ballardw
Super User

The T between the date and time portion means that the DATETIME informat will not work as that expects a single punctuation character such as colon, space or slash. The T indicatess a separate ISO layout hence the different informat.

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
  • 1234 views
  • 0 likes
  • 3 in conversation